Debian Codegraph @

src/network/tygemconnection.cpp

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2009 by The qGo Project *
3 * *
4 * This file is part of qGo. *
5 * *
6 * qGo is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, see <http://www.gnu.org/licenses/> *
18 * or write to the Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
21
22
23 #include <string.h>
24 #include <stdint.h>
25 #include <time.h>
26 #include <algorithm>
27 #include "tygemconnection.h"cxx . . $ `<file>/src/network/tygemconnection.h`/
28 #include "tygemprotocol.h"cxx . . $ `<file>/src/network/tygemprotocol.h`/
29 #include "consoledispatch.h"cxx . . $ `<file>/src/network/consoledispatch.h`/
30 #include "room.h"cxx . . $ `<file>/src/network/room.h`/
31 #include "boarddispatch.h"cxx . . $ `<file>/src/network/boarddispatch.h`/
32 #include "gamedialog.h"cxx . . $ `<file>/src/network/gamedialog.h`/
33 #include "talk.h"cxx . . $ `<file>/src/network/talk.h`/
34 #include "serverlistdialog.h"cxx . . $ `<file>/src/network/serverlistdialog.h`/
35 #include "codecwarndialog.h"cxx . . $ `<file>/src/network/codecwarndialog.h`/
36 #include "matchinvitedialog.h"cxx . . $ `<file>/src/network/matchinvitedialog.h`/
37 #include "gamedialogflags.h"cxx . . $ `<file>/src/network/gamedialogflags.h`/
38 //FIXME set phrases would be useful...
39 //#include "orosetphrasechat.h"
40 //#include "setphrasepalette.h"
41 #include "createroomdialog.h"cxx . . $ `<file>/src/network/createroomdialog.h`/
42 #include "gamedata.h"cxx . . $ `<file>/src/gamedata.h`/
43 #include "playergamelistings.h"cxx . . $ `<file>/src/network/playergamelistings.h`/
44 #include "matchnegotiationstate.h"cxx . . $ `<file>/src/network/matchnegotiationstate.h`/
45 #include <QMessageBox>
46
47 //#define RE_DEBUG
48
49 unsigned char zodiac_bytecxx . . $ zodiac_byte.;
50 /* I now think you have to buy avatar icons at the store,
51 * so we're not going to mess with this */
52 /* 57 is our zodiac sign
53 01 is rat, 02 is bull, 03 is tiger, 04 is rabbit
54 05 is dragon, 06 is snake, 07 is horse
55 08 is sheep (ram? goat?), 09 is monkey
56 0a is rooster, 0b is dog, 0c is pig
57
58 0d is mercury like chibi figure with golden shield
59 0e is red warrior palace chibi
60 0f is wild west gunman on horse
61 10 is chibi in snow sweeping
62 11 red warrior bamboo forest
63 12 calligrapher
64 13 red haired bureaucrat, purple cap?
65 14 red haired bureacrat, scroll, white cap
66 15 guy with shield on battlefield?
67 16 two blade zhong warrior night time balcony
68 17 same with no zhong, bigger blades
69 24 man running with bunny
70 30 sports uniform kid with korean flag
71 34 child spinning soccer ball on finger
72 35 small girl playing go on computer
73 40 soccer kid
74 43 woman reading book with headphones
75 50 purple mouse, bowtie, cheese on platter
76 55 snake around yellow stone
77 56 horse
78 57 giant chicken
79 58 strange blue purple dog with bone around neck
80 59 childs drawing of pig in love
81 5a woman walking dog
82 5b ballet dancer stretching
83 5c woman on balcony looking out over ocean
84 5d girl blue flowers in hair, blue dress
85 5e 31 gangster on dark blue background
86 5f pig tailed beach girl
87 60 blackhaired girl rainbow very blue
88 61 ghetto guy against graffiti wall
89 62 green haired boxing girl on sun like background
90 63 frightened cloaked guy holding skull
91 64 fierce blonde pigtailed girl on blue sky
92 65 dominatrix infront of night time castle
93 66 pigtailed brunette princess in red and gold background
94 67 studying girl
95 68 strong guy saying something, korean letters, blue star hat
96 69 woman purple sheath pink background
97 6a black haired girl black dress, roses
98 6b pink girl holding valentine at night with moon
99 7e ninja nighttime, gold crown
100 7f japanese warlord
101 80 new tygem congratulations, white smiling figure, gold badge
102 81 same with black smirking figure
103 82 same with out gold badge
104 90 green haired happy girl under night sky smiling moon?
105 91 grey pig eating or happy at table with food
106 92 2 kids in love
107 93 bowl of orange fruit
108 94 night life guy with flowers
109 95 night life business lady?
110 96 blonde smiling guy showbiz stars
111 97 korean infinity girl picture
112 98 white creature with brown hat, fall leaves
113 99 white creatures riding dolphins
114 9a white and black creatures playing game
115 a0 thin santa claus, merry christmas
116 b0 animated bouncing girl on pink hearts
117 c0 korean letters, boiling chicken, and dancing chickens
118 d0 scarecrow golden field
119 e0 no picture
120 FIXME */
121
122 TygemConnectioncxx . . $ TygemConnection#::TygemConnectioncxx . . $ TygemConnection#TygemConnection(231cf4fc7da7cd6f).(const ConnectionCredentialscxx . . $ ConnectionCredentials# credentials)
123 : NetworkConnectioncxx . . $ NetworkConnection#NetworkConnection(231cf4fc7da7cd6f).(credentials)
124 {
125 textCodeccxx . . $ TygemConnection#textCodec. = QTextCodeccxx . . $ QTextCodec#::codecForLocalecxx . . $ QTextCodec#codecForLocale(6599407a1b23811).();
126 serverCodeccxx . . $ TygemConnection#serverCodec. = QTextCodeccxx . . $ QTextCodec#::codecForLocalecxx . . $ QTextCodec#codecForLocale(6599407a1b23811).();
127 //FIXME check for validity of codecs ???
128 //ORO_setup_setphrases();
129
130 http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length. = 0;
131 current_server_indexcxx . . $ TygemConnection#current_server_index. = -1;
132 encode_offsetcxx . . $ TygemConnection#encode_offset. = 0;
133
134 matchKeepAliveTimerIDcxx . . $ TygemConnection#matchKeepAliveTimerID. = 0;
135 matchRequestKeepAliveTimerIDcxx . . $ TygemConnection#matchRequestKeepAliveTimerID. = 0;
136 retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID. = 0;
137 opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID. = 0;
138
139 /* We should either create the palette on creation of
140 * the connection, or have a button to activate it that
141 * appears when the room is connected */
142 //setphrasepalette = new SetPhrasePalette(this);
143 //setphrasepalette->show();
144
145 //for server list
146 //error handling FIXME
147 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTYGEMcxx . . $ TypeTYGEM.)
148 {
149 serverCodeccxx . . $ TygemConnection#serverCodec. = QTextCodeccxx . . $ QTextCodec#::codecForNamecxx . . $ QTextCodec#codecForName(914382192c9ca379).(getCodecStringcxx . . $ TygemConnection#getCodecString(33a1f659e94feb42).());
150 if(!serverCodeccxx . . $ TygemConnection#serverCodec.)
151 {
152 new CodecWarnDialogcxx . . $ CodecWarnDialog#(getCodecStringcxx . . $ TygemConnection#getCodecString(33a1f659e94feb42).());
153 serverCodeccxx . . $ TygemConnection#serverCodec. = QTextCodeccxx . . $ QTextCodec#::codecForLocalecxx . . $ QTextCodec#codecForLocale(6599407a1b23811).();
154 }
155 }
156
157 requestServerInfocxx . . $ TygemConnection#requestServerInfo(b126dc7c1de90089).();
158 }
159
160 /* I think we must not request this too often which is why hitting cancel and
161 * trying to reconnect screws things up. So I'm thinking we need to store
162 * this some where for at least the three tygem protocols and possibly oro
163 * as well. retrieve on application start, gray out the tabs if we can't
164 * get the info. */
165 int TygemConnectioncxx . . $ TygemConnection#::requestServerInfocxx . . $ TygemConnection#requestServerInfo(b126dc7c1de90089).(void)
166 {
167 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Requesting Tygem Server Info");
168 if(!openConnectioncxx . . $ NetworkConnection#openConnection(6f40ee5c4c30d87e).(hostnamecxx . . $ NetworkConnection#hostname., portcxx . . $ NetworkConnection#port., NOT_MAIN_CONNECTIONcxx . . $ `src/network/networkconnection.h:64:9`!))
169 {
170 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get server info");
171 return -1;
172 }
173 unsigned int length = 0x96;
174 unsigned char * packet = new unsigned char[length]; //term 0x00
175 snprintf((char *)packet, length,
176 "GET /service/down_korea/livebaduk3.cfg HTTP/1.1\r\n" \
177 "User-Agent: Tygem HTTP\r\n" \
178 "Host: service.tygem.com\r\n" \
179 "Connection: Keep-Alive\r\n" \
180 "Cache-Control: no-cache\r\n\r\n");
181 #ifdef RE_DEBUG
182 for(unsigned int i = 0; i < length; i++)
183 printf("%02x", packet[i]);
184 printf("\n");
185 #endif //RE_DEBUG
186 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
187 {
188 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending server info request");
189 return -1;
190 }
191 delete[] packet;
192
193 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Infocxx . . $ Info.);
194 return 0;
195 }
196
197 TygemConnectioncxx . . $ TygemConnection#::~cxx . . $ TygemConnection#`~TygemConnection`(ced63f7c635d850d).TygemConnectioncxx . . $ TygemConnection#()
198 {
199 //if(setphrasepalette)
200 // delete setphrasepalette;
201 // FIXME for non tygem subclasses!
202 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Destroying Tygem connection");
203 closeConnectioncxx . . $ NetworkConnection#closeConnection(b45ddcbc8423892c).();
204 //maybe backup serverList at this point
205 }
206
207 void TygemConnectioncxx . . $ TygemConnection#::OnConnectedcxx . . $ TygemConnection#OnConnected(49f6e7a06ebc5aa8).()
208 {
209 }
210
211 void TygemConnectioncxx . . $ TygemConnection#::sendDisconnectcxx . . $ TygemConnection#sendDisconnect(49f6e7a06ebc5aa8).(void)
212 {
213 /* Yeah, FIXME, we don't want to send this
214 * when we're reconnecting... which means we
215 * need a special connection state ... yada yada */
216 if(connectionStatecxx . . $ NetworkConnection#connectionState. == Connectedcxx . . $ Connected.)
217 sendDisconnectMsgcxx . . $ TygemConnection#sendDisconnectMsg(49f6e7a06ebc5aa8).();
218 }
219
220 void TygemConnectioncxx . . $ TygemConnection#::sendTextcxx . . $ TygemConnection#sendText(85c52e162fed56f9).(const char * text)
221 {
222 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Wanted to send %s", text);
223 return;
224 }
225
226 void TygemConnectioncxx . . $ TygemConnection#::sendTextcxx . . $ TygemConnection#sendText(7df51288a9ebd664).(QStringcxx . . $ QString# text)
227 {
228 sendServerChatcxx . . $ TygemConnection#sendServerChat(7df51288a9ebd664).(textcxx . . $ QString#QString(132dd6869045752b).);
229 }
230
231 void TygemConnectioncxx . . $ TygemConnection#::sendMsgcxx . . $ TygemConnection#sendMsg(c3abbc2f7b873519).(PlayerListingcxx . . $ PlayerListing# * player, QStringcxx . . $ QString# text)
232 {
233 Talkcxx . . $ Talk# * t = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getIfTalkcxx . . $ Room#getIfTalk(b72f705c6951e6b6).(player);
234 if(!t)
235 {
236 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("sendMsg called with no talk dialog");
237 return;
238 }
239 if(!t->getConversationOpenedcxx . . $ Talk#getConversationOpened(50ce9a9e25b4a850).())
240 {
241 sendOpenConversationcxx . . $ TygemConnection#sendOpenConversation(122195e397f39e1b).(player);
242 pendingConversationMsgcxx . . $ TygemConnection#pendingConversationMsg.[cxx . . $ std/map#`operator[]`(bbd415b616967878).player] =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). text;
243 }
244 else
245 {
246 sendConversationMsgcxx . . $ TygemConnection#sendConversationMsg(1598b02156041f24).(player, text.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
247 }
248 }
249
250 void TygemConnectioncxx . . $ TygemConnection#::sendTogglecxx . . $ TygemConnection#sendToggle(37c160c81b6367f7).(const QStringcxx . . $ QString# & param, bool val)
251 {
252 /* FIXME, more to do here probably */
253 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Setting open %d", val);
254 if(param ==cxx . . $ QString#`operator==`(7d4bdb1abc417636). "open")
255 sendInvitationSettingscxx . . $ TygemConnection#sendInvitationSettings(b45ddcbc8423892c).(val);
256 }
257
258 /* If we can observe something besides games,
259 * like rooms or people, then this name is a bit
260 * iffy too... */
261 void TygemConnectioncxx . . $ TygemConnection#::sendObservecxx . . $ TygemConnection#sendObserve(963dc8955d49573e).(const GameListingcxx . . $ GameListing# *game)
262 {
263 sendJoincxx . . $ TygemConnection#sendJoin(ed53e3bbd3fa2f69).(game->numbercxx . . $ GameListing#number.);
264 }
265
266 void TygemConnectioncxx . . $ TygemConnection#::sendJoincxx . . $ TygemConnection#sendJoin(ed53e3bbd3fa2f69).(unsigned short game_number)
267 {
268 unsigned int length = 24;
269 char *packet = new char[length];
270 int i;
271 if(getBoardDispatchescxx . . $ NetworkConnection#getBoardDispatches(b126dc7c1de90089).() == 3)
272 {
273 //legit client won't let you watch more than 3 games
274 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("3 Boards Open"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("You must close a board before you can open another one"));
275 //message box, FIXME
276 //it is allowed but probably taxes server, as server sets
277 //time, etc... and who watches more than three games at a time...
278 //besides people testing hacked together clients?
279 return;
280 }
281 /* We need to turn this to a join if its a room, not a game
282 * otherwise bad things happen FIXME */
283
284 packet[0] = 0x00;
285 packet[1] = 0x18;
286 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
287 packet[3] = 0x38;
288 packet[4] = (game_number >> 8);
289 packet[5] = game_number & 0x00ff;
290 packet[6] = 0x00;
291 packet[7] = 0x00;
292 for(i = 8; i < 0x18; i++)
293 packet[i] = 0x00;
294 #ifdef RE_DEBUG
295 //printf("Sending observe to %s vs %s: %d", game.white_name().toLatin1().constData(), game.black_name().toLatin1().constData(), game.game_code);
296 printf("Sending observe to %d\n", game_number);
297 for(i = 0; i < (int)length; i++)
298 printf("%02x ", (unsigned char)packet[i]);
299 printf("\n");
300 #endif //RE_DEBUG
301 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
302 #ifdef RE_DEBUG
303 printf("After encode\n");
304 for(i = 0; i < (int)length; i++)
305 printf("%02x ", (unsigned char)packet[i]);
306 printf("\n");
307 #endif //RE_DEBUG
308 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
309 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending observe outside");
310 delete[] packet;
311 }
312
313 /* This is sent after sendJoin when we've been disconnected.
314 * Presumably its to resume the game */
315 void TygemConnectioncxx . . $ TygemConnection#::sendResumecxx . . $ TygemConnection#sendResume(ed53e3bbd3fa2f69).(unsigned short game_number)
316 {
317 unsigned int length = 12;
318 char * packet = new char[length];
319 int i;
320
321 packet[0] = 0x00;
322 packet[1] = 0x0c;
323 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
324 packet[3] = 0x86;
325 packet[4] = (game_number >> 8);
326 packet[5] = game_number & 0x00ff;
327 for(i = 6; i < 12; i++)
328 packet[i] = 0x00;
329 #ifdef RE_DEBUG
330 printf("Sending resume %d", game_number);
331 for(i = 0; i < (int)length; i++)
332 printf("%02x ", (unsigned char)packet[i]);
333 printf("\n");
334 #endif //RE_DEBUG
335 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
336 #ifdef RE_DEBUG
337 printf("After encode\n");
338 for(i = 0; i < (int)length; i++)
339 printf("%02x ", (unsigned char)packet[i]);
340 printf("\n");
341 #endif //RE_DEBUG
342 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
343 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending resume");
344 delete[] packet;
345 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendAdjournResumecxx . . $ MatchNegotiationState#sendAdjournResume(49f6e7a06ebc5aa8).();
346 }
347
348 void TygemConnectioncxx . . $ TygemConnection#::closeTalkcxx . . $ TygemConnection#closeTalk(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * opponent)
349 {
350 Talkcxx . . $ Talk# * t = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getIfTalkcxx . . $ Room#getIfTalk(b72f705c6951e6b6).(opponent);
351 if(!t)
352 {
353 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("closing talk but no talk registered!!");
354 return;
355 }
356 if(t->getConversationOpenedcxx . . $ Talk#getConversationOpened(50ce9a9e25b4a850).())
357 sendCloseConversationcxx . . $ TygemConnection#sendCloseConversation(122195e397f39e1b).(opponent);
358 getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->closeTalkcxx . . $ Room#closeTalk(cac334474c82cf3a).(opponent);
359 }
360
361 void TygemConnectioncxx . . $ TygemConnection#::closeBoardDispatchcxx . . $ TygemConnection#closeBoardDispatch(cb2f890c2fdad230).(unsigned int game_id)
362 {
363 sendFinishObservingcxx . . $ TygemConnection#sendFinishObserving(ed53e3bbd3fa2f69).((unsigned short)game_id);
364 NetworkConnectioncxx . . $ NetworkConnection#::closeBoardDispatchcxx . . $ NetworkConnection#closeBoardDispatch(cb2f890c2fdad230).(game_id);
365 }
366
367
368 /* I'd like to just send the match invite, but only if we're not
369 * in the same room... actually, maybe its almost like a room invite */
370 void TygemConnectioncxx . . $ TygemConnection#::sendMatchRequestcxx . . $ TygemConnection#sendMatchRequest(969a5d62d7a1bd6e).(MatchRequestcxx . . $ MatchRequest# * mr)
371 {
372 #ifdef RE_DEBUG
373 qDebug("send match offer");
374 #endif //RE_DEBUG
375 if(mr->first_offercxx . . $ MatchRequest#first_offer.)
376 {
377 sendMatchOffercxx . . $ TygemConnection#sendMatchOffer(9e01310764b0ff93).(*mr, offercxx . . $ TygemConnection#offer.);
378 mr->first_offercxx . . $ MatchRequest#first_offer. = false;
379 }
380 else
381 sendMatchOffercxx . . $ TygemConnection#sendMatchOffer(9e01310764b0ff93).(*mr, modifycxx . . $ TygemConnection#modify.);
382 }
383
384 /* FIXME gamedialog maintime supports m:ss, not h:mm:ss,
385 * for some reason 90 minutes is getting set as 50 minutes
386 * certainly not an hour and a half, but its sent okay.
387 * but this is a BIG ISSUE for later, okay 5 hours screws
388 * things up even more.*/
389 unsigned long TygemConnectioncxx . . $ TygemConnection#::getGameDialogFlagscxx . . $ TygemConnection#getGameDialogFlags(f708dce9a8856c70).(void)
390 {
391 /* I think there is CANADIAN, but haven't seen it or implemented it yet */
392 return (/*GDF_CANADIAN | */GDF_BYOYOMIcxx . . $ `src/network/gamedialogflags.h:27:9`! | /*GDF_TVASIA |*/ GDF_FREE_RATED_CHOICEcxx . . $ `src/network/gamedialogflags.h:30:9`!
393 | GDF_RATED_SIZE_FIXEDcxx . . $ `src/network/gamedialogflags.h:31:9`! | GDF_RATED_HANDICAP_FIXEDcxx . . $ `src/network/gamedialogflags.h:32:9`!
394 | GDF_RATED_NO_HANDICAPcxx . . $ `src/network/gamedialogflags.h:33:9`!
395 | GDF_HANDICAP1cxx . . $ `src/network/gamedialogflags.h:37:9`!
396 | GDF_NIGIRI_EVENcxx . . $ `src/network/gamedialogflags.h:34:9`! /*| GDF_ONLY_DISPUTE_TIME*/
397 | GDF_BY_CAN_MAIN_MINcxx . . $ `src/network/gamedialogflags.h:36:9`!);
398 }
399
400 const char * TygemConnectioncxx . . $ TygemConnection#::getCodecStringcxx . . $ TygemConnection#getCodecString(33a1f659e94feb42).(void)
401 {
402 return "eucKR";
403 }
404
405 QStringcxx . . $ QString# TygemConnectioncxx . . $ TygemConnection#::getPlaceStringcxx . . $ TygemConnection#getPlaceString(4365c3963150523e).(void)
406 {
407 return "Tygem: " +cxx . . $ operator+(c75c3ae4eb9af1a8). serverListcxx . . $ TygemConnection#serverList.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).current_server_indexcxx . . $ TygemConnection#current_server_index.]->namecxx . . $ ServerItem#name.;
408 }
409
410 int TygemConnectioncxx . . $ TygemConnection#::gd_verifyBoardSizecxx . . $ TygemConnection#gd_verifyBoardSize(7864480464b09eea).(int v)
411 {
412 return 19;
413 /* If game is ranked, has to be 19x19 but right now
414 * game dialog has an old flag that sets that up */
415 if(v < 5)
416 return 5;
417 if(v > 13)
418 return 19;
419 if(v > 9)
420 return 13;
421 if(v > 7)
422 return 9;
423 if(v > 5)
424 return 7;
425 return v;
426 }
427
428 QTimecxx . . $ QTime# TygemConnectioncxx . . $ TygemConnection#::gd_checkMainTimecxx . . $ TygemConnection#gd_checkMainTime(71240b9f3410da6b).(TimeSystemcxx . . $ TimeSystem# s, const QTimecxx . . $ QTime# & t)
429 {
430 int seconds_options[] = {0, 60, 300, 600, 900, 1200, 1800, 2400, 3000, 3600, 5400, 7200,
431 10800, 18000, 28800, 54600 };
432 int seconds = (t.hourcxx . . $ QTime#hour(455f465bc33b4cdf).() * 3600) + (t.minutecxx . . $ QTime#minute(455f465bc33b4cdf).() * 60) + t.secondcxx . . $ QTime#second(455f465bc33b4cdf).();
433 bool increase;
434 int i, hours, minutes;
435 printf("maintime: %d %d", seconds, lastMainTimeCheckedcxx . . $ NetworkConnection#lastMainTimeChecked.);
436 if(lastMainTimeCheckedcxx . . $ NetworkConnection#lastMainTimeChecked. == seconds)
437 return t;
438 if(seconds < lastMainTimeCheckedcxx . . $ NetworkConnection#lastMainTimeChecked.)
439 increase = false;
440 else
441 increase = true;
442 switch(s)
443 {
444 default:
445 case byoyomicxx . . $ byoyomi.:
446 //it looks like there's an unlimited time
447 //option, its a dropdown menu...
448 if(increase)
449 {
450 i = 15;
451 while(seconds < seconds_options[i])
452 i--;
453 if(i != 15)
454 i++;
455 }
456 else
457 {
458 i = 1;
459 while(seconds >= seconds_options[i])
460 {
461 i++;
462 if(i == 16)
463 break;
464 }
465 i--;
466 }
467 seconds = seconds_options[i];
468 lastMainTimeCheckedcxx . . $ NetworkConnection#lastMainTimeChecked. = seconds;
469 minutes = seconds % 3600;
470 seconds -= minutes;
471 hours = seconds / 3600;
472 seconds = minutes % 60;
473 minutes -= seconds;
474 minutes /= 60;
475 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(hours, minutes, seconds);
476 break;
477 case canadiancxx . . $ canadian.:
478 //haven't seen yet FIXME
479 break;
480 }
481 return t;
482 }
483
484 QTimecxx . . $ QTime# TygemConnectioncxx . . $ TygemConnection#::gd_checkPeriodTimecxx . . $ TygemConnection#gd_checkPeriodTime(71240b9f3410da6b).(TimeSystemcxx . . $ TimeSystem# s, const QTimecxx . . $ QTime# & t)
485 {
486 int seconds_options[] = {20, 30, 40, 60};
487 int seconds = (t.minutecxx . . $ QTime#minute(455f465bc33b4cdf).() * 60) + t.secondcxx . . $ QTime#second(455f465bc33b4cdf).();
488 bool increase;
489 int i, minutes;
490 printf("periodtime: %d %d", seconds, lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked.);
491 if(lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked. == seconds)
492 return t;
493 if(seconds < lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked.)
494 increase = false;
495 else
496 increase = true;
497 if(lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked. == 60 && seconds == 0) //awkward
498 {
499 lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked. = 40;
500 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, 0, 40);
501 }
502 switch(s)
503 {
504 default:
505 case byoyomicxx . . $ byoyomi.:
506 if(increase)
507 {
508 i = 3;
509 while(seconds < seconds_options[i])
510 {
511 i--;
512 if(i == -1)
513 break;
514 }
515 if(i != 3)
516 i++;
517 }
518 else
519 {
520 i = 1;
521 while(seconds >= seconds_options[i])
522 {
523 i++;
524 if(i == 4)
525 break;
526 }
527 i--;
528 }
529 seconds = seconds_options[i]; //what this isn't called?!?!
530 lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked. = seconds;
531 minutes = seconds;
532 seconds = minutes % 60;
533 minutes -= seconds;
534 minutes /= 60;
535 return QTimecxx . . $ QTime#QTime(748afa4755bc9595).(0, minutes, seconds);
536 break;
537 case canadiancxx . . $ canadian.:
538 //haven't seen FIXME
539 break;
540 }
541 return t;
542 }
543
544 unsigned int TygemConnectioncxx . . $ TygemConnection#::gd_checkPeriodscxx . . $ TygemConnection#gd_checkPeriods(c827b1ce4ef0d032).(TimeSystemcxx . . $ TimeSystem# s, unsigned int p)
545 {
546 unsigned int newp;
547 if(lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. == (signed)p)
548 return p;
549 switch(s)
550 {
551 default:
552 case byoyomicxx . . $ byoyomi.:
553 if(p == 0)
554 newp = 1;
555 else if(lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. > 2 && p < 3)
556 newp = 1;
557 else if((lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. < 3 && p > 1) || (lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. > 4 && p < 5))
558 newp = 3;
559 else
560 newp = 5;
561 break;
562 case canadiancxx . . $ canadian.:
563 //haven't seen yet FIXME
564 break;
565 }
566 lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. = newp;
567 return newp;
568 }
569
570 void TygemConnectioncxx . . $ TygemConnection#::declineMatchOffercxx . . $ TygemConnection#declineMatchOffer(cac334474c82cf3a).(const PlayerListingcxx . . $ PlayerListing# * opponent)
571 {
572 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Declining match offer");
573 unsigned short playing_game_number = match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getGameIdcxx . . $ MatchNegotiationState#getGameId(32a7769d58713265).();
574 if(!playing_game_number)
575 return;
576 GameDialogcxx . . $ GameDialog# * gameDialogDispatch = getIfGameDialogcxx . . $ NetworkConnection#getIfGameDialog(3dcc94127826259).(opponent);
577 if(!gameDialogDispatch)
578 {
579 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No game dialog but just got decline!");
580 return;
581 }
582 MatchRequestcxx . . $ MatchRequest# * mr = gameDialogDispatch->getMatchRequestcxx . . $ GameDialog#getMatchRequest(bd616a0a6add31e0).();
583 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(playing_game_number);
584 if(boarddispatch)
585 {
586 /* Awkward but to prevent issues on board close */
587 GameResultcxx . . $ GameResult# gcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
588 g.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::NOGAMEcxx . . $ GameResult#NOGAME.;
589 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&g);
590 }
591 sendMatchOffercxx . . $ TygemConnection#sendMatchOffer(9e01310764b0ff93).(*mr, declinecxx . . $ TygemConnection#decline.);
592 }
593
594 void TygemConnectioncxx . . $ TygemConnection#::cancelMatchOffercxx . . $ TygemConnection#cancelMatchOffer(cac334474c82cf3a).(const PlayerListingcxx . . $ PlayerListing# * opponent)
595 {
596 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Canceling match offer");
597 declineMatchOffercxx . . $ TygemConnection#declineMatchOffer(cac334474c82cf3a).(opponent);
598 }
599
600 void TygemConnectioncxx . . $ TygemConnection#::acceptMatchOffercxx . . $ TygemConnection#acceptMatchOffer(27875a747def42ce).(const PlayerListingcxx . . $ PlayerListing# * opponent, MatchRequestcxx . . $ MatchRequest# * mr)
601 {
602 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("accept match offer");
603 if(!mr->opponent_is_challengercxx . . $ MatchRequest#opponent_is_challenger.) //should be our_invitation var name maybe
604 {
605 getAndCloseGameDialogcxx . . $ NetworkConnection#getAndCloseGameDialog(847f6df3a908f59b).(opponent);
606 sendStartGamecxx . . $ TygemConnection#sendStartGame(9f9e9a38fcfe00de).(*mr);
607 }
608 else
609 sendMatchOffercxx . . $ TygemConnection#sendMatchOffer(9e01310764b0ff93).(*mr, acceptcxx . . $ TygemConnection#accept.);
610 }
611
612 void TygemConnectioncxx . . $ TygemConnection#::handlePendingDatacxx . . $ TygemConnection#handlePendingData(49f6e7a06ebc5aa8).()
613 {
614 unsigned char * c;
615 unsigned char header[4];
616 unsigned int packet_size;
617 int bytes;
618
619 /* We need better connection states, but we'll use the old
620 * for now */
621
622 switch(connectionStatecxx . . $ NetworkConnection#connectionState.)
623 {
624 case Infocxx . . $ Info.:
625 bytes = qsocketcxx . . $ NetworkConnection#qsocket.->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).();
626 if(http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length. > 0)
627 {
628 if(bytes >= (int)http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length.) // There might be some unwanted trailing characters
629 {
630 c = new unsigned char[http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length. + 1];
631 qsocketcxx . . $ NetworkConnection#qsocket.->readcxx . . $ QIODevice#read(2e638bc8ed65be6c).((char *)c, http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length.);
632 handleServerInfocxx . . $ TygemConnection#handleServerInfo(e1e8b00c42c42532).(c, http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length.);
633 delete[] c;
634 }
635 break;
636 }
637 if(qsocketcxx . . $ NetworkConnection#qsocket.->canReadLinecxx . . $ QAbstractSocket#canReadLine(50ce9a9e25b4a850).())
638 {
639 QByteArraycxx . . $ QByteArray# data = qsocketcxx . . $ NetworkConnection#qsocket.->readLinecxx . . $ QIODevice#readLine(1117a85f2fd4e5c8).();
640 sscanf(data.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), "Content-Length: %d", &http_connect_content_lengthcxx . . $ TygemConnection#http_connect_content_length.);
641 }
642 break;
643 case Logincxx . . $ Login.:
644 bytes = qsocketcxx . . $ NetworkConnection#qsocket.->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).();
645 if(bytes)
646 {
647 c = new unsigned char[bytes];
648 qsocketcxx . . $ NetworkConnection#qsocket.->readcxx . . $ QIODevice#read(2e638bc8ed65be6c).((char *)c, bytes);
649 #ifdef RE_DEBUG
650 for(int i = 0; i < bytes; i++)
651 printf("%02x", c[i]);
652 printf("\n");
653 #endif //RE_DEBUG
654 /* First packet is list of servers and ips */
655 //handleServerList(c);
656
657 //00080698ff040068 //password incorrect
658 if(c[1] == 0x08)
659 {
660 //00080698ff010065 //maybe because too recent?
661 //could also be already
662 //logged in
663 //00080698ff040013 //error on reconnect...
664 //00080698ff060065 //room full
665 //0008069801000000 //everything okay?
666 if(c[5] == 0x04/*c[7] == 0x68*/ || c[5] == 0x03) //00080698ff040065 //(03 is Tom)
667 {
668 //0008 1398 ff03 0000 tom bad password
669 if(c[7] == 0x00 && connectionTypecxx . . $ NetworkConnection#connectionType. != TypeTOMcxx . . $ TypeTOM.)
670 {
671 //this might be okay for eweiqi and tygem
672 //on change server, probably not okay for tom
673 // Totally wrong FIXME
674 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Trying again...");
675 retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID. = startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(2000);
676 delete[] c;
677 return;
678 }
679 //00080698ff040000 tom returns from already logged in
680 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad password or login");
681 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(PassFailedcxx . . $ PassFailed.);
682 delete[] c;
683 //closeConnection();
684 return;
685 }
686 else if(c[5] == 0x06)
687 {
688 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Server full");
689 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Server full"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Server full, try another"));
690 if(reconnectToServercxx . . $ TygemConnection#reconnectToServer(b126dc7c1de90089).() < 0)
691 {
692 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("User canceled");
693 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Canceledcxx . . $ Canceled.);
694 delete[] c;
695 return;
696 }
697 delete[] c;
698 return;
699 }
700 else if(c[5] == 0x01) //c5 = 4?
701 {
702 if(c[7] == 0x72 || c[7] == 0x00) //00 is tom
703 {
704 //for eweiqi we get this on server change...
705 //so this seems to work better without
706 //connectionState = ALREADY_LOGGED_IN;
707 //delete[] c;
708 //return;
709 }
710 //we seem to get 01 65 every time
711 //we change servers which makes me
712 //think it might be like an already
713 //logged in message... then again,
714 //if we don't get the encode offset,
715 //we can't continue
716 //special response
717 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Already logged in? Too recent?");
718 fflush(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
719 //00080698ff010072
720 retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID. = startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(2000);
721 /* FIXME its real ugly if this happens
722 * more than once and we hammer the
723 * server until it lets us in. We need
724 * to sleep or put out a message or
725 * something. */
726 /* There's a chance that 0x38 vs 0x08
727 * isn't the only distinction here in
728 * which case, maybe we ought to
729 * try "handleLogin"? even from 0x08?
730 * requires testing to see what gets
731 * us cut off */
732 }
733 else
734 {
735 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Received %02x %02x from login", c[5], c[7]);
736 }
737 //00080698ff010000, this is after changing servers on TOM
738 //00080698ff010072, changing ervers tygem
739
740 }
741 else if(c[1] == 0x38)
742 handleLogincxx . . $ TygemConnection#handleLogin(e1e8b00c42c42532).(c, bytes);
743
744 delete[] c;
745 }
746 break;
747 case Setupcxx . . $ Setup.:
748 case Connectedcxx . . $ Connected.:
749 while((bytes = qsocketcxx . . $ NetworkConnection#qsocket.->bytesAvailablecxx . . $ QAbstractSocket#bytesAvailable(98833e9ab7de59a4).()))
750 {
751 qsocketcxx . . $ NetworkConnection#qsocket.->peekcxx . . $ QIODevice#peek(2e638bc8ed65be6c).((char *)header, 4);
752 #ifdef RE_DEBUG
753 #ifdef NOISY_DEBUG
754 printf("%02x%02x%02x%02x\n", header[0], header[1], header[2], header[3]);
755 #endif //NOISY_DEBUG
756 #endif //RE_DEBUG
757 packet_size = header[1] + (header[0] << 8);
758 if((unsigned)bytes < packet_size)
759 break;
760 c = new unsigned char[packet_size + 1];
761 qsocketcxx . . $ NetworkConnection#qsocket.->readcxx . . $ QIODevice#read(2e638bc8ed65be6c).((char *)c, packet_size);
762 handleMessagecxx . . $ TygemConnection#handleMessage(e1e8b00c42c42532).(c, packet_size);
763 delete[] c;
764 }
765 break;
766 case Canceledcxx . . $ Canceled.:
767 case Reconnectingcxx . . $ Reconnecting.:
768 break;
769 /*case AUTH_FAILED:
770 qDebug("Auth failed\n");
771 break;*/
772 default:
773 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("connection state not handled by Tygem type protocol");
774 break;
775 }
776 }
777
778 /* Really we should have a legitimate parse function, but I feel
779 * like this is the only time we're going to do this.
780 * Yeah, FIXME, I've decided we should write a parser just because...
781 * handleServerInfo?? not handleServerList?? anyway, we don't need both*/
782 void TygemConnectioncxx . . $ TygemConnection#::handleServerInfocxx . . $ TygemConnection#handleServerInfo(e1e8b00c42c42532).(unsigned char * msg, unsigned int length)
783 {
784 char * p = (char *)msg;
785 int i, j;
786 ServerItemcxx . . $ ServerItem# * si;
787
788 #ifdef RE_DEBUG
789 /*for(i = 0; i < length; i++)
790 printf("%c", p[i]);
791 printf("\n");*/
792 #endif //RE_DEBUG
793
794 /* We're having the connection handle the http header, nevertheless
795 * we should check something for it */
796 /*if(strncmp(p, "HTTP/1.1 200 OK\r\n", 17) != 0)
797 {
798 qDebug("Server info response not OK!");
799 closeConnection();
800 return;
801 }*/
802 while(p < ((char *)msg + length))
803 {
804 while(p < ((char *)msg + length - 10) && (p[0] != '\r' || p[1] != '\n'))
805 p++;
806 p += 2;
807 //FIXME, check for size
808 if(strncmp(p, "/LIVE ", 6) == 0)
809 {
810 //same as for /SERVER but with only 2 [], name and ip
811 }
812 else if(strncmp(p, "/LECTURE ", 9) == 0)
813 {
814 //same as for /SERVER but with only 2 [], name and ip
815 }
816 else if(strncmp(p, "/SERVER ", 8) == 0 ||
817 strncmp(p, "/_SERVER ", 9) == 0) //whats the "_" FIXME
818 {
819 if(p[1] == '_')
820 p++;
821 p += 8;
822 unsigned char ipaddr[16];
823 unsigned char name[20];
824 i = 0;
825 while(i < 7 && p < ((char *)msg + length))
826 {
827 if(*p != '[')
828 {
829 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Server info parse error");
830 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(ProtocolErrorcxx . . $ ProtocolError.);
831 closeConnectioncxx . . $ NetworkConnection#closeConnection(b45ddcbc8423892c).();
832 return;
833 }
834 p++;
835 si = new ServerItemcxx . . $ ServerItem#();
836 unsigned char * dest;
837 if(i == 1)
838 dest = ipaddr;
839 else if(i == 0)
840 dest = name;
841 j = 0;
842 while(*p != ']' && p < ((char *)msg + length))
843 {
844 if((i == 1 && j < 15) || (i == 0 && j < 19))
845 dest[j++] = *p;
846 p++;
847 }
848 if(i == 0 || i == 1)
849 {
850 dest[j++] = 0x00;
851 }
852 p += 2;
853 if(i == 1)
854 {
855 strncpy(si->ipaddresscxx . . $ ServerItem#ipaddress., (const char *)ipaddr, 16);
856 si->namecxx . . $ ServerItem#name. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
857 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Server: %s", ipaddr);
858 serverListcxx . . $ TygemConnection#serverList..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(si);
859 }
860 i++;
861 if(i == 7)
862 p--; //no space
863 }
864 }
865 else if(strncmp(p, "/ENCRYPT ", 9) == 0)
866 {
867 //FIXME
868 //[encode] [on]
869 }
870 }
871 /* We close here because this first time, its going to close
872 * anyway, and if we don't close here, we'll get an error
873 * and lose the object */
874 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Reconnectingcxx . . $ Reconnecting.);
875 closeConnectioncxx . . $ NetworkConnection#closeConnection(b45ddcbc8423892c).(false);
876
877 if(reconnectToServercxx . . $ TygemConnection#reconnectToServer(b126dc7c1de90089).() < 0)
878 {
879 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("User canceled");
880 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Canceledcxx . . $ Canceled.);
881 return;
882 }
883 }
884
885 void TygemConnectioncxx . . $ TygemConnection#::sendLogincxx . . $ TygemConnection#sendLogin(b0b38cda41d4ede4).(bool response_bit, bool change_server)
886 {
887 unsigned int length = 0x2c;
888 unsigned char * packet = new unsigned char[length];
889 unsigned int i;
890 packet[0] = (length >> 8);
891 packet[1] = length & 0x00ff;
892 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
893 packet[3] = 0xa5;
894 for(i = 0; i < (unsigned)usernamecxx . . $ NetworkConnection#username..lengthcxx . . $ QString#length(455f465bc33b4cdf).(); i++)
895 packet[i + 4] = usernamecxx . . $ NetworkConnection#username..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).()[i];
896 for(i = usernamecxx . . $ NetworkConnection#username..lengthcxx . . $ QString#length(455f465bc33b4cdf).() + 4; i < 16; i++)
897 packet[i] = 0x00;
898 for(i = 16; i < 20; i++)
899 packet[i] = 0x00;
900 packet[19] = response_bit;
901 packet[20] = change_server;
902 for(i = 21; i < 24; i++)
903 packet[i] = 0x00;
904 for(i = 0; i < (unsigned)passwordcxx . . $ NetworkConnection#password..lengthcxx . . $ QString#length(455f465bc33b4cdf).(); i++)
905 packet[24 + i] = passwordcxx . . $ NetworkConnection#password..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().datacxx . . $ QByteArray#data(41208ce6ca65dd58).()[i];
906 for(i = 24 + passwordcxx . . $ NetworkConnection#password..lengthcxx . . $ QString#length(455f465bc33b4cdf).(); i < length; i++)
907 packet[i] = 0x00;
908 //before encode
909 #ifdef RE_DEBUG
910 printf("Sending login: ");
911 for(i = 0; i < length; i++)
912 printf("%02x", packet[i]);
913 printf("\n");
914 #endif //RE_DEBUG
915 encode_offsetcxx . . $ TygemConnection#encode_offset. = 0; //clear for new server
916 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
917 //after encode
918 #ifdef RE_DEBUG
919 for(i = 0; i < length; i++)
920 printf("%02x", packet[i]);
921 printf("\n");
922 #endif //RE_DEBUG
923
924 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
925 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending login");
926 delete[] packet;
927 }
928
929 void TygemConnectioncxx . . $ TygemConnection#::handleLogincxx . . $ TygemConnection#handleLogin(e1e8b00c42c42532).(unsigned char * msg, unsigned int length)
930 {
931 if(length != 0x38)
932 {
933 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Login of strange size: %d", length);
934 }
935 unsigned char * p = msg;
936
937 //0038 0698 0100 0200 228b ae64 0000 0000
938 //0000 0000 0000 0000 0000 0000 0000 0000
939 //0000 0000 0000 0000 7065 7465 7269 7573
940 //0000 0002 0001 0000
941 /* Note that that 02 is likely our country code!! we should store that
942 * perhaps? (or maybe just get it from player lists*/
943 /* One of these is also the zodiac byte, but I don't know which one
944 * here, I'm thinking its probably not that first 1, so I'll use the
945 * second one, I think we get the country_id from the player lists*/
946 p += 8;
947 encode_offsetcxx . . $ TygemConnection#encode_offset. = *(unsigned long *)p;
948 p += 4;
949 p += 0x1c;
950 // this could be the nickname if we passed the username
951 //pretty certain this is the nickname, so that kind of
952 //casts some of this into question. FIXME
953 //we either have to change the username or... I just...
954 //we could check that its not the same
955 p += 11;
956 //country_id
957 p++;
958 p++;
959 zodiac_bytecxx . . $ zodiac_byte. = p[0];
960 #ifdef RE_DEBUG
961 for(unsigned int i = 0; i < length; i++)
962 printf("%02x ", msg[i]);
963 printf("\n");
964 //printf("encode offset: %08x\n", encode_offset);
965 #endif //RE_DEBUG
966
967 received_gamescxx . . $ TygemConnection#received_games. = false;
968 received_playerscxx . . $ TygemConnection#received_players. = false;
969
970 /* What happens if both players get disconnected FIXME */
971
972 initial_connectcxx . . $ TygemConnection#initial_connect. = true;
973
974 sendRequestGamescxx . . $ TygemConnection#sendRequestGames(49f6e7a06ebc5aa8).();
975 sendRequestcxx . . $ TygemConnection#sendRequest(49f6e7a06ebc5aa8).();
976 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Setupcxx . . $ Setup.);
977 sendNamecxx . . $ TygemConnection#sendName(49f6e7a06ebc5aa8).();
978 /* FIXME currently we have handleFriends doing setConnected which closes the please wait
979 * getting us out of SETUP. This means that the players haven't come in yet.
980 * the problem is that handleFriends puts the friends on a list that's then checked when
981 * we receive players. But there's some other issues with this as well and we should get
982 * CyberORO working better with this, as well as IGS Before we worry about this
983 * relatively minor problem */
984 sendFriendsBlocksRequestcxx . . $ TygemConnection#sendFriendsBlocksRequest(49f6e7a06ebc5aa8).();
985 sendRequest2cxx . . $ TygemConnection#sendRequest2(49f6e7a06ebc5aa8).(); //the 53
986 sendRequestPlayerscxx . . $ TygemConnection#sendRequestPlayers(49f6e7a06ebc5aa8).();
987 //53
988 //11 ae 14 name(91) 95 53
989 onReadycxx . . $ TygemConnection#onReady(49f6e7a06ebc5aa8).(); //sends invite settings as well
990 }
991
992 void TygemConnectioncxx . . $ TygemConnection#::sendRequestGamescxx . . $ TygemConnection#sendRequestGames(49f6e7a06ebc5aa8).(void)
993 {
994 unsigned int length = 8;
995 unsigned char * packet = new unsigned char[length];
996
997 packet[0] = 0x00;
998 packet[1] = 0x08;
999 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1000 packet[3] = 0x11;
1001 packet[4] = 0x00;
1002 packet[5] = 0x00;
1003 packet[6] = 0x00;
1004 packet[7] = 0x00;
1005
1006 //before encode
1007 #ifdef RE_DEBUG
1008 for(unsigned int i = 0; i < length; i++)
1009 printf("%02x", packet[i]);
1010 printf("\n");
1011 #endif //RE_DEBUG
1012 /*encode(packet, 0x8);
1013 //after encode
1014 for(i = 0; i < length; i++)
1015 printf("%02x", packet[i]);
1016 printf("\n");
1017 */
1018 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1019 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending login confirm");
1020 delete[] packet;
1021 }
1022
1023 //we send
1024 //00 0C 06 AE 5C C8 E9 D4 00 E8 03 00
1025 void TygemConnectioncxx . . $ TygemConnection#::sendRequestcxx . . $ TygemConnection#sendRequest(49f6e7a06ebc5aa8).(void)
1026 {
1027 unsigned int length = 12;
1028 unsigned char * packet = new unsigned char[length];
1029
1030 packet[0] = 0x00;
1031 packet[1] = 0x0c;
1032 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1033 packet[3] = 0xae;
1034 packet[4] = 0x0d;
1035 packet[5] = 0xf0;
1036 packet[6] = 0xad;
1037 packet[7] = 0xba;
1038 packet[8] = 0x0d;
1039 packet[9] = 0xf0;
1040 packet[10] = 0xad;
1041 packet[11] = 0xba;
1042 //a8a88cce
1043 //before encode
1044 #ifdef RE_DEBUG
1045 for(unsigned int i = 0; i < length; i++)
1046 printf("%02x", packet[i]);
1047 printf("\n");
1048 #endif //RE_DEBUG
1049
1050 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
1051
1052 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1053 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending request");
1054 delete[] packet;
1055 }
1056
1057 void TygemConnectioncxx . . $ TygemConnection#::sendRequest2cxx . . $ TygemConnection#sendRequest2(49f6e7a06ebc5aa8).(void)
1058 {
1059 unsigned int length = 8;
1060 unsigned char * packet = new unsigned char[length];
1061
1062 packet[0] = (length >> 8);
1063 packet[1] = length & 0x00ff;
1064 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1065 packet[3] = 0x53;
1066 packet[4] = 0x00;
1067 packet[5] = 0x00;
1068 packet[6] = 0x00;
1069 packet[7] = 0x00;
1070
1071 #ifdef RE_DEBUG
1072 for(unsigned int i = 0; i < length; i++)
1073 printf("%02x", packet[i]);
1074 printf("\n");
1075 #endif //RE_DEBUG
1076
1077 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1078 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending request 2");
1079 delete[] packet;
1080 }
1081
1082 /* Its possible we're supposed to send only ascii or only encode here */
1083 /* Note that this is also a request for some 0692 information */
1084 void TygemConnectioncxx . . $ TygemConnection#::sendNamecxx . . $ TygemConnection#sendName(49f6e7a06ebc5aa8).(void)
1085 {
1086 unsigned int length = 24;
1087 unsigned char * packet = new unsigned char[length];
1088
1089 packet[0] = 0x00;
1090 packet[1] = 0x18;
1091 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1092 packet[3] = 0x91;
1093 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).(), 20);
1094 //before encode
1095 #ifdef RE_DEBUG
1096 printf("Sending name");
1097 for(unsigned int i = 0; i < length; i++)
1098 printf("%02x", packet[i]);
1099 printf("\n");
1100 #endif //RE_DEBUG
1101 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
1102
1103 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1104 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending name");
1105 delete[] packet;
1106 }
1107
1108 void TygemConnectioncxx . . $ TygemConnection#::sendRequestPlayerscxx . . $ TygemConnection#sendRequestPlayers(49f6e7a06ebc5aa8).(void)
1109 {
1110 unsigned int length = 8;
1111 unsigned char * packet = new unsigned char[length];
1112
1113 packet[0] = 0x00;
1114 packet[1] = 0x08;
1115 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1116 packet[3] = 0x14;
1117 packet[4] = 0x00;
1118 packet[5] = 0x00;
1119 packet[6] = 0x00;
1120 packet[7] = 0x00;
1121
1122 //before encode
1123 #ifdef RE_DEBUG
1124 for(unsigned int i = 0; i < length; i++)
1125 printf("%02x", packet[i]);
1126 printf("\n");
1127 #endif //RE_DEBUG
1128
1129 /*encode(packet, 0x8);
1130 //after encode
1131 for(i = 0; i < length; i++)
1132 printf("%02x", packet[i]);
1133 printf("\n");
1134 */
1135 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1136 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending players list request");
1137 delete[] packet;
1138 }
1139
1140 /* Note that as currently set up, this MUST be sent
1141 * before the player list request since we only set
1142 * the friends/blocks flags when the player is received
1143 * and so the friends list must be filled out before
1144 * we receive any players on it */
1145 void TygemConnectioncxx . . $ TygemConnection#::sendFriendsBlocksRequestcxx . . $ TygemConnection#sendFriendsBlocksRequest(49f6e7a06ebc5aa8).(void)
1146 {
1147 unsigned int length = 8;
1148 unsigned char * packet = new unsigned char[length];
1149
1150 packet[0] = 0x00;
1151 packet[1] = 0x08;
1152 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1153 packet[3] = 0x95;
1154 packet[4] = 0x00;
1155 packet[5] = 0x00;
1156 packet[6] = 0x00;
1157 packet[7] = 0x00;
1158
1159 //before encode
1160 #ifdef RE_DEBUG
1161 for(unsigned int i = 0; i < length; i++)
1162 printf("%02x", packet[i]);
1163 printf("\n");
1164 #endif //RE_DEBUG
1165
1166 /*encode(packet, 0x8);
1167 //after encode
1168 for(i = 0; i < length; i++)
1169 printf("%02x", packet[i]);
1170 printf("\n");
1171 */
1172 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1173 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending friends/blocks list request");
1174 delete[] packet;
1175 }
1176
1177 void TygemConnectioncxx . . $ TygemConnection#::sendObserversRequestcxx . . $ TygemConnection#sendObserversRequest(ed53e3bbd3fa2f69).(unsigned short game_number)
1178 {
1179 unsigned int length = 12;
1180 unsigned char * packet = new unsigned char[length];
1181
1182 packet[0] = 0x00;
1183 packet[1] = 0x0c;
1184 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1185 packet[3] = 0x65;
1186 packet[4] = (game_number >> 8);
1187 packet[5] = game_number & 0x00ff;
1188 packet[6] = 0x00;
1189 packet[7] = 0x00;
1190 packet[8] = 0x00;
1191 packet[9] = 0x00;
1192 packet[10] = 0x00;
1193 packet[11] = 0x00;
1194
1195 #ifdef RE_DEBUG
1196 printf("observer list request:\n");
1197 //before encode
1198 for(unsigned int i = 0; i < length; i++)
1199 printf("%02x", packet[i]);
1200 printf("\n");
1201 #endif //RE_DEBUG
1202 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
1203
1204 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1205 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending observers request");
1206 delete[] packet;
1207 }
1208
1209 void TygemConnectioncxx . . $ TygemConnection#::changeServercxx . . $ TygemConnection#changeServer(49f6e7a06ebc5aa8).(void)
1210 {
1211 if(connectionStatecxx . . $ NetworkConnection#connectionState. != Connectedcxx . . $ Connected.)
1212 return;
1213 if(reconnectToServercxx . . $ TygemConnection#reconnectToServer(b126dc7c1de90089).() < 0)
1214 {
1215 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("User canceled");
1216 return;
1217 }
1218 }
1219
1220 void TygemConnectioncxx . . $ TygemConnection#::createRoomcxx . . $ TygemConnection#createRoom(49f6e7a06ebc5aa8).(void)
1221 {
1222 #ifdef FIXME
1223 CreateRoomDialog * createroomdialog = new CreateRoomDialog(this);
1224 createroomdialog->exec();
1225 #endif //FIXME
1226 }
1227
1228 /* FIXME we need error handling here, a return value, something
1229 * or at least we need to call the right destructors throughout,
1230 * and safely. */
1231 int TygemConnectioncxx . . $ TygemConnection#::reconnectToServercxx . . $ TygemConnection#reconnectToServer(b126dc7c1de90089).(void)
1232 {
1233 bool reconnecting;
1234 /* FIXME, why does the serverReconnectDialog disappear the ui
1235 * elements in the server window ?!?!? */
1236 ServerListDialogcxx . . $ ServerListDialog# * serverReconnectDialog = new ServerListDialogcxx . . $ ServerListDialog#(serverListcxx . . $ std/vector#vector(a1201200cf0efa42)., current_server_indexcxx . . $ TygemConnection#current_server_index.);
1237 int server_i = serverReconnectDialog->execcxx . . $ QDialog#exec(b126dc7c1de90089).();
1238 if(server_i < 0 || server_i == QDialogcxx . . $ QDialog#::Rejectedcxx . . $ QDialog#Rejected.)
1239 return -1;
1240 server_i--;
1241 if(!this)
1242 {
1243 /* FIXME, this needs to be much better. It should be,
1244 * to start with, irrelevant. */
1245 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Waited too long to connect");
1246 return -1;
1247 }
1248 current_server_indexcxx . . $ TygemConnection#current_server_index. = server_i;
1249 /* FIXME
1250 * Might be neat if we listed the server that one was currently on
1251 * somewhere, like on the main window. */
1252
1253 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Reconnecting to %s: %s...", serverListcxx . . $ TygemConnection#serverList.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).server_i]->namecxx . . $ ServerItem#name..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), serverListcxx . . $ TygemConnection#serverList.[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).server_i]->ipaddresscxx . . $ ServerItem#ipaddress.);
1254
1255 if(connectionStatecxx . . $ NetworkConnection#connectionState. == Connectedcxx . . $ Connected.)
1256 {
1257 sendDisconnectMsgcxx . . $ TygemConnection#sendDisconnectMsg(49f6e7a06ebc5aa8).();
1258 closeConnectioncxx . . $ NetworkConnection#closeConnection(b45ddcbc8423892c).(false);
1259 reconnecting = true;
1260 }
1261 else if(connectionStatecxx . . $ NetworkConnection#connectionState. == Logincxx . . $ Login.)
1262 {
1263 closeConnectioncxx . . $ NetworkConnection#closeConnection(b45ddcbc8423892c).(false);
1264 reconnecting = false;
1265 }
1266 else
1267 reconnecting = false;
1268 if(openConnectioncxx . . $ NetworkConnection#openConnection(6f40ee5c4c30d87e).(serverListcxx . . $ QString#QString(85c52e162fed56f9).[cxx . . $ std/vector#`operator[]`(81207c53da4b73ce).server_i]->ipaddresscxx . . $ ServerItem#ipaddress., 12320))
1269 {
1270 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Reconnected %d", reconnecting);
1271 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Logincxx . . $ Login.);
1272 sendLogincxx . . $ TygemConnection#sendLogin(b0b38cda41d4ede4).(false, false);
1273 //sendLogin(reconnecting, reconnecting);
1274 fflush(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
1275 fflush(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!);
1276 onAuthenticationNegotiatedcxx . . $ NetworkConnection#onAuthenticationNegotiated(49f6e7a06ebc5aa8).();
1277 }
1278 else
1279 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't open Connection!!");
1280
1281 return 0;
1282 }
1283
1284 unsigned short TygemConnectioncxx . . $ TygemConnection#::getRoomNumbercxx . . $ TygemConnection#getRoomNumber(32a7769d58713265).(void)
1285 {
1286 return match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getGameIdcxx . . $ MatchNegotiationState#getGameId(32a7769d58713265).();
1287 }
1288
1289 //change text to QString
1290 //FIXME why is this commented out?!?
1291 /* I'm not certain why this is commented out,
1292 * but there's an email type message and then
1293 * there's a conversation message. You have to
1294 * request the conversation message and then
1295 * there's a message sent when you leave. I have it
1296 * in tygem_endgame4.txt on spacecoyote I think FIXME */
1297 /* I think we can use existing messages in UI but that should be fixed up
1298 * anyway */
1299 /* Okay, there's a simple reason this is commented out. There's no UI element
1300 * to handle it. We'd need to set something up to send messages and I know there's
1301 * some facility for that, as in IGS, its like an on-server email service, but we
1302 * haven't set that feature up in general and that would need to be done first.
1303 * also note that that 0617 conflicts with the server announcement code as
1304 * far as I can tell. See handlePersonalChat with 069f I think. Good chance
1305 * this stuff is copy and pasted. FIXME */
1306 void TygemConnectioncxx . . $ TygemConnection#::sendPersonalChatcxx . . $ TygemConnection#sendPersonalChat(7ed01115d689877).(const PlayerListingcxx . . $ PlayerListing# * , const char * )
1307 {
1308 /*unsigned int length = 42 + text.size();
1309 while(length % 4 != 0)
1310 length++;
1311 length += 4;
1312 unsigned char * packet = new unsigned char[length];
1313 char * our_name, * msg;
1314 int i;
1315 int ordinal;
1316 unsigned char qualifier;
1317 Room * room = getDefaultRoom();
1318 PlayerListing * ourPlayer;
1319 ourPlayer = room->getPlayerListing(getUsername());
1320 if(!ourPlayer)
1321 {
1322 qDebug("Can't get our player listing");
1323 return;
1324 }
1325
1326 packet[0] = (length >> 8);
1327 packet[1] = length & 0x00ff;
1328 packet[2] = 0x06;
1329 packet[3] = 0x17;
1330 msg = (char *)text.toLatin1().constData();
1331 writeZeroPaddedString((char *)&(packet[4]), getUsername(), 14);
1332 packet[18] = 0x00;
1333 sscanf(ourPlayer->rank.toLatin1().constData(), "%d%c", &ordinal, &qualifier);
1334 if(qualifier == 'k')
1335 packet[19] = 0x12 - ordinal;
1336 else if(qualifier == 'p')
1337 packet[19] = ordinal + 0x1a;
1338 else
1339 packet[19] = ordinal + 0x11;
1340 //this would actually be our ascii name, with the earlier
1341 //being the encoded version
1342 for(i = 0; i < strlen(our_name); i++)
1343 packet[i + 20] = our_name[i];
1344 for(i = strlen(our_name) + 20; i < 30; i++)
1345 packet[i] = 0x00;
1346 packet[30] = 0x00;
1347 packet[31] = 0x02; //what is this?
1348 packet[32] = 0x00;
1349 packet[33] = 0x00;
1350 packet[34] = 0x00;
1351 packet[35] = ((strlen(msg) + 1) >> 8);
1352 packet[36] = (strlen(msg) + 1) & 0x00ff;
1353 packet[37] = 0x00;
1354 packet[38] = 0xff;
1355 packet[39] = 0xff; //possibly implied destination username?
1356 packet[40] = 0x33; //don't know, sometimes 0x32, something to do with encoding?
1357 for(i = 0; i < strlen(msg); i++)
1358 packet[41 + i] = msg[i];
1359 packet[41 + strlen(msg)] = 0x00;
1360 i = 42 + strlen(msg);
1361 while(i % 4 != 0)
1362 {
1363 packet[i] = 0x00;
1364 i++;
1365 }
1366 packet[i] = 0x00;
1367 packet[i + 1] = 0x00;
1368 packet[i + 2] = 0x00;
1369 packet[i + 3] = 0x00;
1370
1371 printf("personal chat before encode\n");
1372 for(i = 0; i < length; i++)
1373 printf("%02x", packet[i]);
1374 printf("\n");
1375
1376 encode(packet, (length / 4) - 2);
1377
1378 printf("personal chat after encode\n");
1379 for(i = 0; i < length; i++)
1380 printf("%02x", packet[i]);
1381 printf("\n");
1382 if(write((const char *)packet, length) < 0)
1383 qWarning("*** failed sending personal chat");
1384 delete[] packet;*/
1385 }
1386
1387 void TygemConnectioncxx . . $ TygemConnection#::sendOpenConversationcxx . . $ TygemConnection#sendOpenConversation(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1388 {
1389 unsigned int length = 0x4c;
1390 char * packet = new char[length];
1391 unsigned int i;
1392
1393 packet[0] = (length >> 8);
1394 packet[1] = (length & 0xff);
1395 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1396 packet[3] = 0x33;
1397
1398 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1399
1400 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), player);
1401 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
1402 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[36]), player);
1403 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[48]), ourPlayer);
1404 for(i = 60; i < 66; i++)
1405 packet[i] = 0x00;
1406 packet[66] = 0x02;
1407
1408 for(i = 67; i < length; i++)
1409 packet[i] = 0x00;
1410
1411 #ifdef RE_DEBUG
1412 qDebug("Sending open conversation");
1413 for(i = 0; i < length; i++)
1414 printf("%02x ", packet[i]);
1415 #endif //RE_DEBUG
1416 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1417 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1418 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending close conversation");
1419 delete[] packet;
1420 }
1421
1422 void TygemConnectioncxx . . $ TygemConnection#::sendConversationReplycxx . . $ TygemConnection#sendConversationReply(ca5adf404307529).(PlayerListingcxx . . $ PlayerListing# * player, enum MIVersioncxx . . $ TygemConnection#MIVersion# version)
1423 {
1424 if(version != acceptcxx . . $ TygemConnection#accept. && version != declinecxx . . $ TygemConnection#decline.)
1425 {
1426 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("sendConversationReply passed unhandled version");
1427 return;
1428 }
1429 unsigned int length = 0x60;
1430 char * packet = new char[length];
1431 unsigned int i;
1432
1433 packet[0] = (length >> 8);
1434 packet[1] = (length & 0xff);
1435 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1436 packet[3] = 0x34;
1437
1438 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1439
1440 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), player);
1441 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
1442 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[36]), player);
1443 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[48]), ourPlayer);
1444 for(i = 60; i < 66; i++)
1445 packet[i] = 0x00;
1446 if(version == acceptcxx . . $ TygemConnection#accept.)
1447 packet[66] = 0x01;
1448 else
1449 packet[66] = 0x00;
1450
1451 for(i = 67; i < length; i++)
1452 packet[i] = 0x00;
1453
1454 #ifdef RE_DEBUG
1455 qDebug("Sending open conversation reply");
1456 for(i = 0; i < length; i++)
1457 printf("%02x ", packet[i]);
1458 #endif //RE_DEBUG
1459 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1460 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1461 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending open converation reply");
1462 delete[] packet;
1463 }
1464
1465 void TygemConnectioncxx . . $ TygemConnection#::sendConversationMsgcxx . . $ TygemConnection#sendConversationMsg(1598b02156041f24).(PlayerListingcxx . . $ PlayerListing# * player, const char * text)
1466 {
1467 unsigned int text_length = strlen(text);
1468 unsigned int length = 0x44 + text_length;
1469 if(length % 4 == 0)
1470 length += 4;
1471 else
1472 {
1473 while(length % 4 != 0)
1474 length++;
1475 }
1476 length += 4;
1477 char * packet = new char[length];
1478 unsigned int i;
1479
1480 packet[0] = (length >> 8);
1481 packet[1] = (length & 0xff);
1482 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1483 packet[3] = 0x35;
1484
1485 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1486
1487 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), player);
1488 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
1489 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[36]), player);
1490 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[48]), ourPlayer);
1491 for(i = 60; i < 64; i++)
1492 packet[i] = 0x00;
1493 //these four zeroes have to do with text color I think
1494 //32 cd 32 00 //green
1495 //ff 00 00 00 //after a background change? also red
1496 //actually 63 maybe be the high byte of the text size
1497 //assuming text can be more than 255? double check FIXME
1498 packet[64] = text_length;
1499 packet[65] = 0x00;
1500 packet[66] = 0x05;
1501 packet[67] = 0x00;
1502 for(i = 0; i < text_length; i++)
1503 packet[68 + i] = text[i];
1504 packet[68 + text_length] = 0x00;
1505
1506 for(i = 69 + text_length; i < length; i++)
1507 packet[i] = 0x00;
1508
1509 #ifdef RE_DEBUG
1510 qDebug("Sending conversation msg");
1511 for(i = 0; i < length; i++)
1512 printf("%02x ", packet[i]);
1513 #endif //RE_DEBUG
1514 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1515 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1516 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending conversation msg");
1517 delete[] packet;
1518 }
1519
1520 void TygemConnectioncxx . . $ TygemConnection#::sendCloseConversationcxx . . $ TygemConnection#sendCloseConversation(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1521 {
1522 QStringcxx . . $ QString# closeMsg = '\'' +cxx . . $ operator+(d59e858ea18ae16d). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() +cxx . . $ operator+(501d4570f8fec4c9). '\'';
1523 //FIXME pretty sure close Msg says closeMsg in korean, only
1524 //our hacked client sends a bunch of ????????????
1525 const char * text = closeMsg.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).();
1526 unsigned int text_length = strlen(text);
1527 unsigned int length = 0x44 + text_length;
1528 while(length % 4 != 0)
1529 length++;
1530 length += 4;
1531 char * packet = new char[length];
1532 unsigned int i;
1533
1534 packet[0] = (length >> 8);
1535 packet[1] = (length & 0xff);
1536 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1537 packet[3] = 0x35;
1538
1539 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1540
1541 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), player);
1542 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
1543 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[36]), player);
1544 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[48]), ourPlayer);
1545 for(i = 60; i < 64; i++)
1546 packet[i] = 0x00;
1547 //these four zeroes have to do with text color I think
1548 //32 cd 32 00 //green
1549 //ff 00 00 00 //after a background change? also red
1550 //actually 63 maybe be the high byte of the text size
1551 //assuming text can be more than 255? double check FIXME
1552 packet[64] = text_length;
1553 packet[65] = 0x00;
1554 packet[66] = 0x04; //this would be the close bit, rather than 5
1555 packet[67] = 0x00;
1556 for(i = 0; i < text_length; i++)
1557 packet[68 + i] = text[i];
1558 packet[68 + text_length] = 0x00;
1559
1560 for(i = 69 + text_length; i < length; i++)
1561 packet[i] = 0x00;
1562
1563 #ifdef RE_DEBUG
1564 qDebug("Sending close conversation");
1565 for(i = 0; i < length; i++)
1566 printf("%02x ", packet[i]);
1567 #endif //RE_DEBUG
1568 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1569 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1570 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending close conversation");
1571 delete[] packet;
1572 }
1573
1574 /* FIXME I think both IGS and maybe even oro have a chat echo.
1575 * but with tygem its particularly ugly */
1576 /* This is in game, name should be changed */
1577 void TygemConnectioncxx . . $ TygemConnection#::sendMsgcxx . . $ TygemConnection#sendMsg(679a3afc1f0f3212).(unsigned int room_number, QStringcxx . . $ QString# text)
1578 {
1579 if(room_number == 0)
1580 {
1581 sendServerChatcxx . . $ TygemConnection#sendServerChat(7df51288a9ebd664).(textcxx . . $ QString#QString(132dd6869045752b).);
1582 return;
1583 }
1584 if(text.sizecxx . . $ QString#size(455f465bc33b4cdf).() > 0x7e)
1585 {
1586 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("send Message too large according to tygem standard");
1587 return;
1588 }
1589 unsigned int length = 74 + text.sizecxx . . $ QString#size(455f465bc33b4cdf).();
1590 if(length % 4 == 0)
1591 length += 4;
1592 else
1593 {
1594 while(length % 4 != 0)
1595 length++;
1596 }
1597 length += 4;
1598 unsigned char * packet = new unsigned char[length];
1599 unsigned int i;
1600 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1601
1602 packet[0] = (length >> 8);
1603 packet[1] = length & 0x00ff;
1604 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1605 packet[3] = 0x61;
1606 packet[4] = (room_number >> 8);
1607 packet[5] = room_number & 0x00ff;
1608 packet[6] = 0x00;
1609 packet[7] = 0x01; //our player?
1610 for(i = 8; i < 24; i++)
1611 packet[i] = 0x00;
1612 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[24]), ourPlayer);
1613 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[40]), ourPlayer);
1614 for(i = 53; i < 68; i++)
1615 packet[i] = 0x00;
1616 packet[68] = (text.sizecxx . . $ QString#size(455f465bc33b4cdf).() + 1) & 0x00ff;
1617 packet[69] = 0x00; //size cannot apparently be larger than 0x7f
1618 packet[70] = 0x00;
1619 packet[71] = 0x00;
1620 packet[72] = 0x33; //don't know, sometimes 0x32, something to do with encoding?
1621 for(i = 0; i < (unsigned)text.sizecxx . . $ QString#size(455f465bc33b4cdf).(); i++)
1622 packet[73 + i] = text.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()[i];
1623 packet[73 + text.sizecxx . . $ QString#size(455f465bc33b4cdf).()] = 0x20; //append space, don't know why
1624
1625 for(i = 74 + text.sizecxx . . $ QString#size(455f465bc33b4cdf).(); i < length; i++)
1626 packet[i] = 0x00;
1627
1628
1629 #ifdef RE_DEBUG
1630 printf("room chat before encode\n");
1631 for(i = 0; i < length; i++)
1632 printf("%02x", packet[i]);
1633 printf("\n");
1634 #endif //RE_DEBUG
1635 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
1636 #ifdef RE_DEBUG
1637 printf("room chat after encode\n");
1638 for(i = 0; i < length; i++)
1639 printf("%02x", packet[i]);
1640 printf("\n");
1641 #endif //RE_DEBUG
1642 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1643 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending room chat");
1644 delete[] packet;
1645 }
1646
1647 void TygemConnectioncxx . . $ TygemConnection#::sendServerChatcxx . . $ TygemConnection#sendServerChat(7df51288a9ebd664).(QStringcxx . . $ QString# text)
1648 {
1649 unsigned int length = 42 + text.sizecxx . . $ QString#size(455f465bc33b4cdf).();
1650 while(length % 4 != 0)
1651 length++;
1652 length += 4;
1653 unsigned char * packet = new unsigned char[length];
1654 char * msg;
1655 unsigned int i;
1656 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
1657
1658 packet[0] = (length >> 8);
1659 packet[1] = length & 0x00ff;
1660 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1661 packet[3] = 0x17;
1662
1663 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), ourPlayer);
1664 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
1665
1666 msg = (char *)text.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).();
1667 packet[32] = 0x00;
1668 packet[33] = 0x00;
1669 packet[34] = 0x00;
1670 packet[35] = ((strlen(msg) + 1) >> 8);
1671 packet[36] = (strlen(msg) + 1) & 0x00ff;
1672 packet[37] = 0x00;
1673 packet[38] = 0xff;
1674 packet[39] = 0xff; //possibly implied destination username?
1675 packet[40] = 0x33; //don't know, sometimes 0x32, something to do with encoding?
1676 for(i = 0; i < strlen(msg); i++)
1677 packet[41 + i] = msg[i];
1678 packet[41 + strlen(msg)] = 0x00;
1679 i = 42 + strlen(msg);
1680 while(i % 4 != 0)
1681 {
1682 packet[i] = 0x00;
1683 i++;
1684 }
1685 packet[i] = 0x00;
1686 packet[i + 1] = 0x00;
1687 packet[i + 2] = 0x00;
1688 packet[i + 3] = 0x00;
1689
1690 #ifdef RE_DEBUG
1691 printf("Server chat before encode\n");
1692 for(i = 0; i < length; i++)
1693 printf("%02x", packet[i]);
1694 printf("\n");
1695 #endif //RE_DEBUG
1696
1697 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
1698
1699 #ifdef RE_DEBUG
1700 printf("Server chat after encode\n");
1701 for(i = 0; i < length; i++)
1702 printf("%02x", packet[i]);
1703 printf("\n");
1704 #endif //RE_DEBUG
1705 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1706 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending server chat");
1707 delete[] packet;
1708 }
1709
1710 //FIXME fix this when we do create rooms
1711 void TygemConnectioncxx . . $ TygemConnection#::sendJoinRoomcxx . . $ TygemConnection#sendJoinRoom(27567cc4e87be946).(const RoomListingcxx . . $ RoomListing# & /*room*/, const char * /*password*/)
1712 {
1713 //FIXME
1714 }
1715
1716 void TygemConnectioncxx . . $ TygemConnection#::addFriendcxx . . $ TygemConnection#addFriend(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1717 {
1718 unsigned int length = 0x18;
1719 char * packet = new char[length];
1720 unsigned int i;
1721
1722 packet[0] = (length >> 8);
1723 packet[1] = (length & 0xff);
1724 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1725 packet[3] = 0x93;
1726 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1727 //there's some bytes here that the official client doesn't even zero I don't
1728 //think
1729 packet[19] = 0x00; //this is 0x00 if they are friend
1730 for(i = 20; i < length; i++)
1731 packet[i] = 0x00;
1732
1733 #ifdef RE_DEBUG
1734 qDebug("Sending add friend");
1735 #endif //RE_DEBUG
1736 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1737 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1738 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending add friend");
1739 delete[] packet;
1740
1741 NetworkConnectioncxx . . $ NetworkConnection#::addFriendcxx . . $ NetworkConnection#addFriend(122195e397f39e1b).(player);
1742 }
1743
1744 void TygemConnectioncxx . . $ TygemConnection#::removeFriendcxx . . $ TygemConnection#removeFriend(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1745 {
1746 unsigned int length = 0x18;
1747 char * packet = new char[length];
1748 unsigned int i;
1749
1750 packet[0] = (length >> 8);
1751 packet[1] = (length & 0xff);
1752 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1753 packet[3] = 0x94;
1754 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1755 //there's some bytes here that the official client doesn't even zero I don't
1756 //think
1757 packet[19] = 0x01; //this is weird because 93 to 94 distinguishes removal
1758 //why not 0 here for friend as with addFriend?!??
1759 for(i = 20; i < length; i++)
1760 packet[i] = 0x00;
1761
1762 #ifdef RE_DEBUG
1763 qDebug("Sending remove friend");
1764 #endif //RE_DEBUG
1765 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1766 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1767 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending remove friend");
1768 delete[] packet;
1769
1770 NetworkConnectioncxx . . $ NetworkConnection#::removeFriendcxx . . $ NetworkConnection#removeFriend(122195e397f39e1b).(player);
1771 }
1772
1773 /* This could be fan instead of block, need to double check, likely block though */
1774 void TygemConnectioncxx . . $ TygemConnection#::addBlockcxx . . $ TygemConnection#addBlock(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1775 {
1776 unsigned int length = 0x18;
1777 char * packet = new char[length];
1778 unsigned int i;
1779
1780 packet[0] = (length >> 8);
1781 packet[1] = (length & 0xff);
1782 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1783 packet[3] = 0x93;
1784 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1785
1786 //there's some bytes here that the official client doesn't even zero I don't
1787 //think
1788 packet[19] = 0xff; //this is 0x00 if they are friend
1789 for(i = 20; i < length; i++)
1790 packet[i] = 0x00;
1791
1792 #ifdef RE_DEBUG
1793 qDebug("Sending add block");
1794 #endif //RE_DEBUG
1795 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1796 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1797 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending add block");
1798 delete[] packet;
1799
1800 NetworkConnectioncxx . . $ NetworkConnection#::addBlockcxx . . $ NetworkConnection#addBlock(122195e397f39e1b).(player);
1801 }
1802
1803 void TygemConnectioncxx . . $ TygemConnection#::removeBlockcxx . . $ TygemConnection#removeBlock(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1804 {
1805 unsigned int length = 0x18;
1806 char * packet = new char[length];
1807 unsigned int i;
1808
1809 packet[0] = (length >> 8);
1810 packet[1] = (length & 0xff);
1811 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1812 packet[3] = 0x94;
1813 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1814
1815 //there's some bytes here that the official client doesn't even zero I don't
1816 //think
1817 packet[19] = 0xff; //this is 0x00 if they are friend
1818 for(i = 20; i < length; i++)
1819 packet[i] = 0x00;
1820
1821 #ifdef RE_DEBUG
1822 qDebug("Sending remove block");
1823 #endif //RE_DEBUG
1824 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1825 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1826 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending remove block");
1827 delete[] packet;
1828
1829 NetworkConnectioncxx . . $ NetworkConnection#::removeBlockcxx . . $ NetworkConnection#removeBlock(122195e397f39e1b).(player);
1830 }
1831
1832 /* Not sure what to do with this yet */
1833 void TygemConnectioncxx . . $ TygemConnection#::requestLongInfocxx . . $ TygemConnection#requestLongInfo(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1834 {
1835 unsigned int length = 0x18;
1836 char * packet = new char[length];
1837 unsigned int i;
1838
1839 packet[0] = (length >> 8);
1840 packet[1] = (length & 0xff);
1841 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1842 packet[3] = 0x91;
1843 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1844
1845 //there's some bytes here that the official client doesn't even zero I don't
1846 //think
1847 packet[19] = 0xff; //this is 0x00 if they are friend
1848 for(i = 20; i < length; i++)
1849 packet[i] = 0x00;
1850
1851 #ifdef RE_DEBUG
1852 qDebug("Sending request long info");
1853 #endif //RE_DEBUG
1854 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1855 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1856 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending request long info");
1857 delete[] packet;
1858 }
1859
1860 /* Not sure what to do with this yet: this may not even be
1861 * an info thing, its like a list of options, I don't know
1862 * why it sends anything but it might request some small
1863 * info */
1864 void TygemConnectioncxx . . $ TygemConnection#::requestShortInfocxx . . $ TygemConnection#requestShortInfo(122195e397f39e1b).(PlayerListingcxx . . $ PlayerListing# * player)
1865 {
1866 unsigned int length = 0x18;
1867 char * packet = new char[length];
1868 unsigned int i;
1869
1870 packet[0] = (length >> 8);
1871 packet[1] = (length & 0xff);
1872 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1873 packet[3] = 0xa3;
1874 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[4]), player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
1875
1876 //there's some bytes here that the official client doesn't even zero I don't
1877 //think
1878 packet[19] = 0xff; //this is 0x00 if they are friend
1879 for(i = 20; i < length; i++)
1880 packet[i] = 0x00;
1881
1882 #ifdef RE_DEBUG
1883 qDebug("Sending request short info");
1884 #endif //RE_DEBUG
1885 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1886 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1887 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending request short info");
1888 delete[] packet;
1889 }
1890
1891
1892 /* This looks like its also for leaving games were playing */
1893 void TygemConnectioncxx . . $ TygemConnection#::sendFinishObservingcxx . . $ TygemConnection#sendFinishObserving(ed53e3bbd3fa2f69).(unsigned short game_number)
1894 {
1895 unsigned int length = 12;
1896 char *packet = new char[length];
1897
1898 /* We need to turn this to a join if its a room, not a game
1899 * otherwise bad things happen FIXME */
1900
1901 packet[0] = 0x00;
1902 packet[1] = 0x0c;
1903 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1904 packet[3] = 0x3d;
1905 packet[4] = (game_number >> 8);
1906 packet[5] = game_number & 0x00ff;
1907 /* I'm pretty certain that 6 and 7 are just garbage
1908 * remember that bytes aren't zeroed */
1909 packet[6] = 0xad;
1910 packet[7] = 0xba;
1911 packet[8] = 0x00;
1912 packet[9] = 0x00;
1913 packet[10] = 0x00;
1914 packet[11] = 0x00;
1915 #ifdef RE_DEBUG
1916 printf("Sending finishing observe to %d ", game_number);
1917 for(unsigned int i = 0; i < length; i++)
1918 printf("%02x ", (unsigned char)packet[i]);
1919 printf("\n");
1920 #endif //RE_DEBUG
1921 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
1922
1923 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
1924 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending finish observing");
1925 delete[] packet;
1926 }
1927
1928 /* I get the feeling that this requests the room,
1929 * maybe we can specify password or name if we were creating
1930 * it from button rather than auto on match accept. And
1931 * then maybe a number comes back
1932 * Incidentally, if we break on this, take too long, we can get
1933 * a bad answer. Or maybe our invite response is bad and there's
1934 * decent checking on it now.*/
1935 void TygemConnectioncxx . . $ TygemConnection#::sendCreateRoomcxx . . $ TygemConnection#sendCreateRoom(49f6e7a06ebc5aa8).(void)
1936 {
1937 unsigned int length = 0x28;
1938 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTOMcxx . . $ TypeTOM.)
1939 length = 0x30; //at least for actual button
1940 char *packet = new char[length];
1941 unsigned int i;
1942
1943 packet[0] = (length >> 8);
1944 packet[1] = (length & 0xff);
1945 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
1946 packet[3] = 0x36;
1947 for(i = 4; i < length; i++)
1948 packet[i] = 0x00;
1949 #ifdef FIXME
1950 //*** create room first option
1951 for(i = 4; i < 26; i++)
1952 packet[i] = 0x00;
1953
1954 packet[26] = 0xff;
1955 packet[27] = 0xff;
1956 packet[28] = 0xff;
1957 packet[29] = 0xff;
1958 for(i = 30; i < length; i++)
1959 packet[i] = 0x00;
1960 //followed by a 0665 sendObserverRequest ?? weird
1961
1962 //*** create room second option with text "hello"
1963 packet[4] = 0x02;
1964 packet[5] = 0x00;
1965 packet[6] = 0x00;
1966 packet[7] = 0x00;
1967 for(i = 8; i < 26; i++)
1968 packet[i] = 0x00;
1969 packet[26] = 0xff;
1970 packet[27] = 0xff;
1971 packet[28] = 0xff;
1972 packet[29] = 0xff;
1973 packet[30] = 0x02;
1974 packet[31] = 0x00;
1975 packet[32] = 0x00;
1976 packet[33] = 0x00;
1977
1978 packet[34] = (text.size() >> 8);
1979 packet[35] = text.size & 0xff;
1980 packet[36] = //null terminated text string
1981 //6 more zeroes
1982
1983 //*** create room third option with 2 checkboxes below checked, same checkboxes on second option
1984 //there was a dropdown to select a room as I recall
1985 //4 and 5 are likely a room number to create a review room off of
1986 //6 and 7 are 0
1987 //up to 26 is 0
1988 //26 is 0, 27 is 1, 28 is 1, 29 is 0
1989 //then there's the 4 and 5 room number again, what I think is a room number
1990 //rest is 0 to 2c/40
1991
1992 //then there's weird packets
1993 //one I missed because I thought it was an 0665
1994 //after is 0018063b 00 01 00 01 with the rest 0s
1995 //then 00140683 stop time which I won't bother to copy right now
1996 //then the 0665 sendObserversRequest
1997 //I'm not going to screw with this one right now, but if I did, I'd have to get that one I missed.
1998 #endif //FIXME
1999 #ifdef RE_DEBUG
2000 printf("Sending create room");
2001 for(i = 0; i < length; i++)
2002 printf("%02x ", (unsigned char)packet[i]);
2003 printf("\n");
2004 #endif //RE_DEBUG
2005 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).((unsigned char *)packet, (length / 4) - 2);
2006 #ifdef RE_DEBUG
2007 printf("After encode\n");
2008 for(i = 0; i < length; i++)
2009 printf("%02x ", (unsigned char)packet[i]);
2010 printf("\n");
2011
2012 qDebug("Sending create room");
2013 #endif //RE_DEBUG
2014 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2015 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending create room");
2016 delete[] packet;
2017 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendCreateRoomcxx . . $ MatchNegotiationState#sendCreateRoom(49f6e7a06ebc5aa8).();
2018 }
2019
2020 //FIXME
2021 void TygemConnectioncxx . . $ TygemConnection#::sendCreateRoomcxx . . $ TygemConnection#sendCreateRoom(9db6e4897fed4acd).(RoomCreatecxx . . $ RoomCreate# * /*room*/)
2022 {
2023 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("create room unimplemented on tygem");
2024 return;
2025 }
2026
2027 /* Tygem has a different system. We send a basic invite and if
2028 * its accepted we enter a board room where there is then the debate
2029 * on match specifics. */
2030 void TygemConnectioncxx . . $ TygemConnection#::sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(cac334474c82cf3a).(const PlayerListingcxx . . $ PlayerListing# * player)
2031 {
2032 if(getBoardDispatchescxx . . $ NetworkConnection#getBoardDispatches(b126dc7c1de90089).() == 3)
2033 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("3 Boards Open"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("You must close a board before you can start a game"));
2034 else if(player->infocxx . . $ PlayerListing#info. ==cxx . . $ `operator==`(5bc2975d2d751687). QStringcxx . . $ QString#QString(f2c90172ce699d92).('X'cxx . . $ QChar#QChar(f349c77f591a7878).))
2035 {
2036 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Not open"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 is not accepting invitations").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
2037 }
2038 else
2039 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, offercxx . . $ TygemConnection#offer.);
2040 }
2041
2042 /* note that this only enters the match offer dialog
2043 * it doesn't accept the game. Haven't decided whether
2044 * to auto send this or to have a special popup for it.*/
2045 void TygemConnectioncxx . . $ TygemConnection#::sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(const PlayerListingcxx . . $ PlayerListing# * player, enum MIVersioncxx . . $ TygemConnection#MIVersion# version, unsigned short room_number)
2046 {
2047 unsigned int length = 0x44;
2048 unsigned char * packet = new unsigned char[length];
2049 int i;
2050 if(version == offercxx . . $ TygemConnection#offer.)
2051 opponent_is_challengercxx . . $ TygemConnection#opponent_is_challenger. = false;
2052 //else we actually might want to set it here instead of in handleMatchInvite
2053 packet[0] = (length >> 8);
2054 packet[1] = length & 0x00ff;
2055 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2056 if(version == acceptcxx . . $ TygemConnection#accept. || version == declinecxx . . $ TygemConnection#decline. || version == decline_allcxx . . $ TygemConnection#decline_all. || version == alreadyingamecxx . . $ TygemConnection#alreadyingame.)
2057 packet[3] = 0x44;
2058 else //offer or create
2059 packet[3] = 0x43;
2060
2061 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
2062
2063 /* Careful, they could have logged off in the mean time possibly? */
2064 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), player);
2065
2066 if(version == createcxx . . $ TygemConnection#create.)
2067 {
2068 /* This is after the room has been created */
2069 /* really erase rank, double double check?? FIXME */
2070 for(i = 19; i < 32; i++)
2071 packet[i] = 0x00;
2072 }
2073 else
2074 {
2075 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[20]), player);
2076 }
2077 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[32]), ourPlayer);
2078 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[48]), ourPlayer);
2079
2080 if(version == acceptcxx . . $ TygemConnection#accept.)
2081 {
2082 packet[60] = 0x01;
2083 packet[61] = 0x01;
2084 //packet[61] = FOURTH_BYTE(mi_flags);
2085 packet[62] = 0x00;
2086 packet[63] = 0x00;
2087 //below three had no effect
2088 //packet[61] = 0x13; //??
2089 //packet[62] = 0xff;
2090 //packet[63] = 0xff;
2091 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendMatchAcceptcxx . . $ MatchNegotiationState#sendMatchAccept(122195e397f39e1b).((PlayerListingcxx . . $ PlayerListing# *)&player);
2092 }
2093 else if(version == offercxx . . $ TygemConnection#offer. || version == declinecxx . . $ TygemConnection#decline.)
2094 {
2095 packet[60] = 0x01;
2096 if(getBoardDispatchescxx . . $ NetworkConnection#getBoardDispatches(b126dc7c1de90089).() == 3) //implied: version = decline
2097 packet[61] = 0x0d;
2098 else
2099 packet[61] = 0x00;
2100 packet[62] = 0xff;
2101 packet[63] = 0xff; //not implied username... see server chat comment
2102 if(version == offercxx . . $ TygemConnection#offer.)
2103 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendMatchInvitecxx . . $ MatchNegotiationState#sendMatchInvite(122195e397f39e1b).((PlayerListingcxx . . $ PlayerListing# *)&player);
2104 }
2105 else if(version == alreadyingamecxx . . $ TygemConnection#alreadyingame.)
2106 {
2107 //0x000b is sent out on TOM to decline when we have match invite
2108 //settings off
2109 packet[60] = 0x01;
2110 packet[61] = 0x0b; //doublecheck FIXME
2111 packet[62] = 0xff;
2112 packet[63] = 0xff;
2113 }
2114 else if(version == decline_allcxx . . $ TygemConnection#decline_all.)
2115 {
2116 packet[60] = 0x01;
2117 //packet[61] = 0x0c; //doublecheck FIXME
2118 packet[61] = 0x0e;
2119 packet[62] = 0xff;
2120 packet[63] = 0xff;
2121 }
2122 else if(version == createcxx . . $ TygemConnection#create.)
2123 {
2124 packet[60] = 0x02;
2125 packet[61] = 0x00;
2126 /* Mr Wang to Niu Yen:
2127 * I know, let's randomly change the byte order just on this one
2128 * piece of information, just to screw up people trying to reverse
2129 * the protocol: */
2130 packet[62] = room_number & 0x00ff;
2131 packet[63] = (room_number >> 8);
2132 /* No no, they're probably just inconsistent with their ntohs calls... */
2133 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->createdRoomcxx . . $ MatchNegotiationState#createdRoom(ed53e3bbd3fa2f69).(room_number);
2134 }
2135 for(i = 64; i < 68; i++)
2136 packet[i] = 0x00;
2137
2138 #ifdef RE_DEBUG
2139 printf("match %s packet before encoding: ", (version == offer ? "offer" :
2140 (version == accept ? "accept" :
2141 (version == decline || version == decline_all
2142 || version == alreadyingame ? "decline" : "create"))));
2143 for(int i = 0; i < (int)length; i++)
2144 printf("%02x ", packet[i]);
2145 printf("\n");
2146 #endif //RE_DEBUG
2147 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2148 #ifdef RE_DEBUG
2149 qDebug("Sending accept match request or invite");
2150 #endif //RE_DEBUG
2151 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2152 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending accept match request or invite");
2153 delete[] packet;
2154 }
2155
2156 /* This looks like its a declaration of the match for the game listings */
2157 void TygemConnectioncxx . . $ TygemConnection#::sendMatchMsg1cxx . . $ TygemConnection#sendMatchMsg1(35cead64ffbd9888).(const PlayerListingcxx . . $ PlayerListing# * player, unsigned short game_number)
2158 {
2159 unsigned int length = 0x2c;
2160 unsigned char * packet = new unsigned char[length];
2161 packet[0] = (length >> 8);
2162 packet[1] = length & 0x00ff;
2163 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2164 packet[3] = 0xc6;
2165 packet[4] = (game_number >> 8);
2166 packet[5] = game_number & 0x00ff;
2167 packet[6] = 0x00;
2168 packet[7] = 0x00;
2169
2170 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
2171
2172 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[8]), ourPlayer);
2173 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[24]), player);
2174 packet[40] = 0x00;
2175 packet[41] = 0x00;
2176 packet[42] = 0x00;
2177 packet[43] = 0x00;
2178
2179 #ifdef RE_DEBUG
2180 printf("Match msg 1: \n");
2181 for(int i = 0; i < (int)length; i++)
2182 printf("%02x ", packet[i]);
2183 printf("\n");
2184 #endif //RE_DEBUG
2185 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2186 #ifdef RE_DEBUG
2187 qDebug("Sending match msg 1");
2188 #endif //RE_DEBUG
2189 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2190 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending match msg 1");
2191 delete[] packet;
2192 }
2193
2194 void TygemConnectioncxx . . $ TygemConnection#::sendMatchOffercxx . . $ TygemConnection#sendMatchOffer(9e01310764b0ff93).(const MatchRequestcxx . . $ MatchRequest# & mr, enum MIVersioncxx . . $ TygemConnection#MIVersion# version)
2195 {
2196 unsigned int length = 0x5c;
2197 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTOMcxx . . $ TypeTOM.)
2198 length = 0x60;
2199 unsigned char * packet = new unsigned char[length];
2200 int i;
2201 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
2202 PlayerListingcxx . . $ PlayerListing# * opponent = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(mr.opponentcxx . . $ MatchRequest#opponent.);
2203 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
2204
2205 packet[0] = (length >> 8);
2206 packet[1] = length & 0x00ff;
2207 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2208 if(version == offercxx . . $ TygemConnection#offer.)
2209 packet[3] = 0x45;
2210 else //if(version == accept || version == modify)
2211 packet[3] = 0x46;
2212
2213 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[4]), opponent);
2214 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[20]), ourPlayer);
2215
2216 packet[36] = (mr.numbercxx . . $ MatchRequest#number. >> 8);
2217 packet[37] = mr.numbercxx . . $ MatchRequest#number. & 0x00ff;
2218 //012c 2801 0100 0100 0002 //offer?
2219 //012c 2801 0100 0100 0001 //accept?
2220 //0bb8 2803 0100 0100 0002 //offer
2221 //time settings
2222 //0007 012c 1e03 0100 0100
2223 /* Its not clear that declines have to have the time settings, but they do seem to */
2224 /*if(version == decline)
2225 {
2226 for(i = 38; i < 47; i++)
2227 packet[i] = 0x00;
2228 }
2229 else
2230 {*/
2231 /*I've seen an accept sent with these as 0s
2232 * and yet that literally sets time to 0 so... */
2233 //if(version == offer)
2234 //{
2235 packet[38] = (mr.maintimecxx . . $ MatchRequest#maintime. >> 8);
2236 packet[39] = mr.maintimecxx . . $ MatchRequest#maintime. & 0x00ff;
2237 packet[40] = mr.periodtimecxx . . $ MatchRequest#periodtime.;
2238 packet[41] = mr.stones_periodscxx . . $ MatchRequest#stones_periods.;
2239 if(version != declinecxx . . $ TygemConnection#decline.)
2240 {
2241 packet[42] = mr.handicapcxx . . $ MatchRequest#handicap.; //this is handicap bit!!!
2242 /* FIXME it sets the handicap but doesn't know
2243 * whos turn it is or something !?!?! */
2244 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Handicap %d\n", mr.handicapcxx . . $ MatchRequest#handicap.);
2245 /* Not sure if tygem has negative komis, it might, but for right now
2246 * we're getting -1 here, so FIXME */
2247 if(mr.komicxx . . $ MatchRequest#komi. > 0.0)
2248 packet[43] = (unsigned char)(mr.komicxx . . $ MatchRequest#komi. - 0.5);
2249 else
2250 packet[43] = 0x00;
2251
2252 /*}
2253 else if(version == accept)
2254 {
2255 for(i = 38; i < 44; i++)
2256 packet[i] = 0x00;
2257 }*/
2258 switch(mr.color_requestcxx . . $ MatchRequest#color_request.)
2259 {
2260 case MatchRequestcxx . . $ MatchRequest#::WHITEcxx . . $ MatchRequest#WHITE.:
2261 if(version == offercxx . . $ TygemConnection#offer.)
2262 packet[44] = 0x01;
2263 else
2264 packet[44] = 0x00;
2265 break;
2266 case MatchRequestcxx . . $ MatchRequest#::BLACKcxx . . $ MatchRequest#BLACK.:
2267 if(version == offercxx . . $ TygemConnection#offer.) //their color when we offer?
2268 packet[44] = 0x00;
2269 else
2270 packet[44] = 0x01;//our color when we accept
2271 break;
2272 case MatchRequestcxx . . $ MatchRequest#::NIGIRIcxx . . $ MatchRequest#NIGIRI.:
2273 packet[44] = 0x02;
2274 break;
2275 default:
2276 break;
2277
2278 }
2279 }
2280 /* This bit, if we're offering is basically ignored since
2281 * sent 0671 sendStartGame overrides colors, etc. */
2282 //if(version == accept)
2283 // packet[44] = 0x00; //definitely we're black in tests right now
2284 /* Changing the accept above from 01 to 00 fixed the names but broke our move
2285 * ability as white */
2286 /* On the other hand, changing the offer from 01 to 00 screwed the names
2287 * but allows us to play white */
2288 /* Trying both as 01 with 01 below instead of 02 after our name */
2289 /* That last 02 to 01 broke our move ability, so thinking, that's
2290 * offerer's color? */
2291 //02 seemed to do something strange
2292 //maybe swapped the pictures but not the names
2293 /* For 44, 0x00 means that, for this as an accept send,
2294 * the challenger, that first name, is black, and we're white
2295 * 0x01 probably means the opposite, 02 might be nigiri or something
2296 * but there's flags later, that also need to be set I think */
2297 /* Actually 02 instantly makes challenger black and allow them to play...
2298 * but then looks like inconsistent, so yeah, nigiri */
2299 //00 here is, as accept send, we play white, they play black,
2300 //according to bits below and name orders as they are, this seems
2301 // to work except we can't play
2302 /* Okay. These bits, 45 and 46 determine bits 47 and 49 in
2303 * 0671 sendStartGame, whose name should be changed to sendMatchOpen
2304 * the also seem to be carried through from here in 0645 to 0646 the
2305 * accept, to 0671 to open the game */
2306 if(mr.free_ratedcxx . . $ MatchRequest#free_rated. == FREEcxx . . $ FREE.)
2307 {
2308 /* FIXME doublecheck */
2309 packet[45] = 0x01;
2310 packet[46] = 0x01;
2311 }
2312 else //RATED
2313 {
2314 packet[45] = 0x00;
2315 packet[46] = 0x00;
2316 }
2317 //on tom sending accept I've seen 45 and 46 as 10 00
2318 //might even be critical
2319 //}
2320 if(version == offercxx . . $ TygemConnection#offer.)
2321 {
2322 packet[47] = 0x02;
2323 packet[48] = 0x00;
2324 packet[49] = 0x00;
2325 packet[50] = 0x00;
2326 packet[51] = 0x00;
2327 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->offerMatchTermscxx . . $ MatchNegotiationState#offerMatchTerms(969a5d62d7a1bd6e).((MatchRequestcxx . . $ MatchRequest# *)&mr);
2328 }
2329 else if(version == acceptcxx . . $ TygemConnection#accept.)
2330 {
2331 packet[47] = 0x01;
2332 /* Could also be challenger bit, but if we change 47 to 02
2333 * it definitely rechallenges or disputes or something */
2334 packet[48] = 0xff;
2335 packet[49] = 0xff;
2336 packet[50] = 0xff;
2337 packet[51] = 0xff;
2338 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->acceptMatchTermscxx . . $ MatchNegotiationState#acceptMatchTerms(969a5d62d7a1bd6e).((MatchRequestcxx . . $ MatchRequest# *)&mr);
2339 }
2340 else if(version == modifycxx . . $ TygemConnection#modify.)
2341 {
2342 packet[47] = 0x02;
2343 packet[48] = 0xff;
2344 packet[49] = 0xff;
2345 packet[50] = 0xff;
2346 packet[51] = 0xff;
2347 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->modifyMatchTermscxx . . $ MatchNegotiationState#modifyMatchTerms(969a5d62d7a1bd6e).((MatchRequestcxx . . $ MatchRequest# *)&mr);
2348 }
2349 else if(version == declinecxx . . $ TygemConnection#decline.)
2350 {
2351 /*packet[47] = 0x03;
2352 packet[48] = 0xff;
2353 packet[49] = 0xff;
2354 packet[50] = 0xff;
2355 packet[51] = 0xff;*/
2356 /* zeroes seem to work better here although there's still an autodecline if we try to modify
2357 * their modify */
2358 for(i = 47; i < 52; i++)
2359 packet[i] = 0x00;
2360 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->resetcxx . . $ MatchNegotiationState#reset(49f6e7a06ebc5aa8).();
2361 }
2362
2363 if(version == offercxx . . $ TygemConnection#offer.)
2364 {
2365 /* Apparently we don't have opponent's nickname before
2366 * they've responded to the offer ? */
2367 for(i = 52; i < 76; i++)
2368 packet[i] = 0x00;
2369 }
2370 else //if(version == accept || version == modify || version == decline)
2371 {
2372 for(i = 52; i < 56; i++)
2373 packet[i] = 0x00;
2374 packet[56] = 0x00;
2375 packet[57] = zodiac_bytecxx . . $ zodiac_byte.;
2376 packet[58] = 0x00;
2377 packet[59] = 0x00; //their pic?
2378 for(i = 60; i < 64; i++)
2379 packet[i] = 0x00;
2380
2381 /* Below doesn't seem to matter, if its this. The major thing was the 03ffffff */
2382 /*if(mr.opponent_is_challenger)
2383 packet[63] = 0x01; */ //seen on modify and decline
2384
2385 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[64]), opponent);
2386 }
2387
2388 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[76]), ourPlayer);
2389
2390 for(i = 88; i < 92; i++)
2391 packet[i] = 0x00;
2392 //tom has 91 = 0x61 92 = 0xea and then 4 more bytes with a size of 60?
2393
2394 #ifdef RE_DEBUG
2395 printf("match packet we are sending now: ");
2396 for(i = 0; i < (int)length; i++)
2397 printf("%02x", packet[i]);
2398 printf("\n");
2399 #endif //RE_DEBUG
2400
2401 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2402 #ifdef RE_DEBUG
2403 qDebug("Sending match offer");
2404 #endif //RE_DEBUG
2405 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2406 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending match offer");
2407 delete[] packet;
2408 return;
2409 }
2410
2411 /* Somewhat inconsistent name... */
2412 void TygemConnectioncxx . . $ TygemConnection#::sendStartGamecxx . . $ TygemConnection#sendStartGame(9f9e9a38fcfe00de).(const MatchRequestcxx . . $ MatchRequest# & mr)
2413 {
2414 unsigned int length = 0x60;
2415 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTOMcxx . . $ TypeTOM.)
2416 length = 0x64;
2417 unsigned char * packet = new unsigned char[length];
2418 int i;
2419 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
2420 const PlayerListingcxx . . $ PlayerListing# * ourPlayer = getOurListingcxx . . $ NetworkConnection#getOurListing(c84291d55c8466c6).();
2421 PlayerListingcxx . . $ PlayerListing# * opponent = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(mr.opponentcxx . . $ MatchRequest#opponent.);
2422
2423 packet[0] = (length >> 8);
2424 packet[1] = length & 0x00ff;
2425 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2426 packet[3] = 0x71;
2427 packet[4] = (mr.numbercxx . . $ MatchRequest#number. >> 8);
2428 packet[5] = mr.numbercxx . . $ MatchRequest#number. & 0x00ff;
2429 packet[6] = 0x00;
2430 packet[7] = 0x01; //probably color
2431
2432 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[8]), opponent);
2433 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[24]), ourPlayer);
2434
2435 //012c 2801 0100 0100 0002
2436 //time settings
2437 packet[40] = (mr.maintimecxx . . $ MatchRequest#maintime. >> 8);
2438 packet[41] = mr.maintimecxx . . $ MatchRequest#maintime. & 0x00ff;
2439 packet[42] = mr.periodtimecxx . . $ MatchRequest#periodtime.;
2440 packet[43] = mr.stones_periodscxx . . $ MatchRequest#stones_periods.;
2441 packet[44] = mr.handicapcxx . . $ MatchRequest#handicap.;
2442 #ifdef OLD
2443 /* Just make sure this works okay */
2444 //for now since time isn't really set right
2445 packet[40] = 0x01; //04 //time setting type?
2446 packet[41] = 0x2c; //b0 //minutes?
2447 packet[42] = 0x28; //1e //seconds?
2448 packet[43] = 0x01; //03 //periods?
2449 //packet[44] = 0x01;
2450 #endif //OLD
2451
2452 packet[45] = 0x00;
2453 //this is our color
2454 switch(mr.color_requestcxx . . $ MatchRequest#color_request.)
2455 {
2456 case MatchRequestcxx . . $ MatchRequest#::WHITEcxx . . $ MatchRequest#WHITE.:
2457 packet[46] = 0x00;
2458 break;
2459 case MatchRequestcxx . . $ MatchRequest#::BLACKcxx . . $ MatchRequest#BLACK.:
2460 packet[46] = 0x01;
2461 break;
2462 case MatchRequestcxx . . $ MatchRequest#::NIGIRIcxx . . $ MatchRequest#NIGIRI.:
2463 packet[46] = 0x02;
2464 break;
2465
2466 }
2467
2468 packet[47] = 0x01; //was 0
2469 packet[48] = 0x01;
2470 packet[49] = 0x01; //was 0
2471 packet[50] = 0x00;
2472 packet[51] = 0x12;
2473
2474 packet[52] = 0xff;
2475 packet[53] = 0xff;
2476 packet[54] = 0xff;
2477 packet[55] = 0xff;
2478
2479 packet[56] = 0xff;
2480 packet[57] = 0xff;
2481 packet[58] = 0xff;
2482 packet[59] = 0xff;
2483
2484 packet[60] = 0x00;
2485 /* This is likely their zodiac_byte but I think its ignored */
2486 packet[61] = 0x01; //pics?
2487 packet[62] = 0x00;
2488 packet[63] = zodiac_bytecxx . . $ zodiac_byte.;
2489 #ifdef FIXME
2490 //proper order here seems to be their name then our name
2491 //careful might change if we play black
2492 writeZeroPaddedString((char *)&(packet[64]), opponent->notnickname, 10);
2493 packet[74] = 0x00;
2494 /* The 0x02 bytes (75 and 87) are most likely the country and these second
2495 * names are refered to by tygem as "WHITENICK" as opposed to
2496 * "WHITENAME" which is the first name. So as far as I know,
2497 * nothing to do with ascii, versus encoding which makes sense */
2498 //packet[75] = 0x02; //changed from 2 in the hope of making opp black
2499 packet[75] = opponent->country_id;
2500 writeZeroPaddedString((char *)&(packet[76]), getUsername(), 10);
2501 packet[86] = 0x00;
2502 packet[87] = ourPlayer->country_id;
2503 #endif //FIXME
2504 /* This could be a problem, typically, the below is right, but I have "notnickname"
2505 * used above. Often it doesn't matter, but I'm assuming this packet conforms
2506 * to the general format and maybe it doesn't. Doublecheck FIXME */
2507 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[64]), opponent);
2508 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[76]), ourPlayer);
2509
2510 for(i = 88; i < 96; i++)
2511 packet[i] = 0x00;
2512
2513 #ifdef RE_DEBUG
2514 printf("start match we are sending now: ");
2515 for(i = 0; i < (int)length; i++)
2516 printf("%02x", packet[i]);
2517 printf("\n");
2518 #endif //RE_DEBUG
2519
2520 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2521 #ifdef RE_DEBUG
2522 qDebug("Sending start match");
2523 #endif //RE_DEBUG
2524 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2525 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending start match");
2526 delete[] packet;
2527 }
2528
2529 void TygemConnectioncxx . . $ TygemConnection#::sendServerKeepAlivecxx . . $ TygemConnection#sendServerKeepAlive(cb2f890c2fdad230).(uint32_tcxx . . $ uint32_t# keepaliveIV)
2530 {
2531 if(!keepaliveIV)
2532 {
2533 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No server keep alive IV");
2534 return;
2535 }
2536 unsigned int length = 0xc;
2537 unsigned char * packet = new unsigned char[length];
2538
2539 packet[0] = (length >> 8);
2540 packet[1] = length & 0x00ff;
2541 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2542 packet[3] = 0x4e;
2543 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTOMcxx . . $ TypeTOM.)
2544 {
2545 packet[4] = 0xc4;//??
2546 packet[5] = 0x9b;//??
2547 packet[6] = 0xba;//??
2548 packet[7] = 0x11;//??
2549 }
2550 else
2551 {
2552 packet[7] = (keepaliveIV >> 24);
2553 packet[6] = (keepaliveIV >> 16) & 0x000000ff;
2554 packet[5] = (keepaliveIV >> 8) & 0x000000ff;
2555 packet[4] = keepaliveIV & 0x000000ff;
2556 }
2557 packet[8] = 0x00;
2558 packet[9] = 0x00;
2559 packet[10] = 0x00;
2560 packet[11] = 0x00;
2561
2562 #ifdef RE_DEBUG
2563 /*printf("server keep alive: ");
2564 for(int i = 0; i < (int)length; i++)
2565 printf("%02x", packet[i]);
2566 printf("\n");*/
2567 #endif //RE_DEBUG
2568
2569 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2570 #ifdef RE_DEBUG
2571 /*printf("encoded server keep alive: ");
2572 for(int i = 0; i < (int)length; i++)
2573 printf("%02x", packet[i]);
2574 printf("\n");
2575
2576 qDebug("Sending server keep alive");*/
2577 #endif //RE_DEBUG
2578 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2579 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending server keep alive");
2580 delete[] packet;
2581 }
2582
2583 uint32_tcxx . . $ uint32_t# TygemConnectioncxx . . $ TygemConnection#::encodeKeepAliveIVcxx . . $ TygemConnection#encodeKeepAliveIV(2141b656ce2cc063).(uint32_tcxx . . $ uint32_t# server)
2584 {
2585 uint32_tcxx . . $ uint32_t# magic1 = 0x54268553;
2586 uint32_tcxx . . $ uint32_t# magic2 = 0x347f1064;
2587 uint32_tcxx . . $ uint32_t# magic3 = 0xb92af7fe;
2588 uint32_tcxx . . $ uint32_t# magic4 = 0x1301a49a;
2589
2590 uint32_tcxx . . $ uint32_t# temp1, temp2;
2591 int i;
2592 for(i = 0; i < 4; i++)
2593 ((unsigned char *)&temp1)[i] = ((unsigned char *)&server)[i] - ((unsigned char *)&magic1)[i];
2594 ((unsigned char *)&temp2)[0] = ((unsigned char *)&temp1)[2];
2595 ((unsigned char *)&temp2)[1] = ((unsigned char *)&temp1)[0];
2596 ((unsigned char *)&temp2)[2] = ((unsigned char *)&temp1)[3];
2597 ((unsigned char *)&temp2)[3] = ((unsigned char *)&temp1)[1];
2598 for(i = 0; i < 4; i++)
2599 ((unsigned char *)&temp1)[i] = ((unsigned char *)&temp2)[i] ^ ((unsigned char *)&magic2)[i];
2600 for(i = 0; i < 4; i++)
2601 ((unsigned char *)&temp2)[i] = ((unsigned char *)&temp1)[i] ^ ((unsigned char *)&magic3)[i];
2602 ((unsigned char *)&temp1)[0] = ((unsigned char *)&temp2)[2];
2603 ((unsigned char *)&temp1)[1] = ((unsigned char *)&temp2)[1];
2604 ((unsigned char *)&temp1)[2] = ((unsigned char *)&temp2)[3];
2605 ((unsigned char *)&temp1)[3] = ((unsigned char *)&temp2)[0];
2606 for(i = 0; i < 4; i++)
2607 ((unsigned char *)&temp2)[i] = ((unsigned char *)&temp1)[i] + ((unsigned char *)&magic4)[i];
2608
2609 return temp2;
2610 }
2611
2612 void TygemConnectioncxx . . $ TygemConnection#::timerEventcxx . . $ TygemConnection#timerEvent(b9e57d1150f23bf5).(QTimerEventcxx . . $ QTimerEvent# * event)
2613 {
2614 if(event->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).() == retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID.)
2615 {
2616 //response bit seems necessary here for tygem
2617 //at least, double check for tom
2618 //still screwy FIXME
2619 sendLogincxx . . $ TygemConnection#sendLogin(b0b38cda41d4ede4).(true); //was true (nothing seems to work for tom)
2620 killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID.);
2621 retryLoginTimerIDcxx . . $ TygemConnection#retryLoginTimerID. = 0;
2622 }
2623 else if(event->timerIdcxx . . $ QTimerEvent#timerId(455f465bc33b4cdf).() == opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID.)
2624 {
2625 unsigned short playing_game_number = match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getGameIdcxx . . $ MatchNegotiationState#getGameId(32a7769d58713265).();
2626 if(!playing_game_number)
2627 return;
2628 sendOpponentDisconnectTimercxx . . $ TygemConnection#sendOpponentDisconnectTimer(cb2f890c2fdad230).(playing_game_number);
2629 }
2630 }
2631
2632 /* FIXME This may be sent even if clock is stopped (with stopped time)*/
2633 void TygemConnectioncxx . . $ TygemConnection#::sendTimecxx . . $ TygemConnection#sendTime(f9aae4eee533680e).(BoardDispatchcxx . . $ BoardDispatch# * boarddispatch)
2634 {
2635 unsigned int length = 0x14;
2636 unsigned char * packet = new unsigned char[length];
2637 GameDatacxx . . $ GameData# * gd = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
2638
2639 packet[0] = (length >> 8);
2640 packet[1] = length & 0x00ff;
2641 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2642 packet[3] = 0x7d;
2643 packet[4] = (gd->numbercxx . . $ GameData#number. >> 8);
2644 packet[5] = gd->numbercxx . . $ GameData#number. & 0x00ff;
2645 //we're black sending this
2646 // f p s m
2647 //0101 013b 0440 0100 0580 0000 0000
2648 packet[6] = (gd->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) ^ gd->white_first_flagcxx . . $ GameData#white_first_flag.;
2649 //packet[6] = (gd->black_name == getUsername());
2650 packet[7] = 0x01;
2651
2652 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[8]));
2653
2654 packet[16] = 0x00;
2655 packet[17] = 0x00;
2656 packet[18] = 0x00;
2657 packet[19] = 0x00;
2658 #ifdef RE_DEBUG
2659 printf("TIME SENT: ");
2660 for(int i = 0; i < 20; i++)
2661 printf("%02x ", packet[i]);
2662 printf("\n");
2663 #endif //RE_DEBUG
2664 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2665
2666 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2667 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending time");
2668 delete[] packet;
2669 return;
2670 }
2671
2672 void TygemConnectioncxx . . $ TygemConnection#::fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(BoardDispatchcxx . . $ BoardDispatch# * boarddispatch, unsigned char * packet)
2673 {
2674 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
2675 TimeRecordcxx . . $ TimeRecord# us = boarddispatch->getOurTimeRecordcxx . . $ BoardDispatch#getOurTimeRecord(3d89b73610291578).();
2676 TimeRecordcxx . . $ TimeRecord# them = boarddispatch->getTheirTimeRecordcxx . . $ BoardDispatch#getTheirTimeRecord(3d89b73610291578).();
2677
2678 if(us.stones_periodscxx . . $ TimeRecord#stones_periods. == -1)
2679 packet[0] = game->stones_periodscxx . . $ GameData#stones_periods.;
2680 else
2681 packet[0] = us.stones_periodscxx . . $ TimeRecord#stones_periods.;
2682 packet[1] = us.timecxx . . $ TimeRecord#time. % 60;
2683 packet[2] = (us.timecxx . . $ TimeRecord#time. - packet[1]) / 60;
2684 //0x40 and 0x80 are also used for something as
2685 //well as a time loss flag as well
2686 if(game->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
2687 packet[3] = 0x40;
2688 else
2689 packet[3] = 0x80;
2690 if(us.stones_periodscxx . . $ TimeRecord#stones_periods. != -1)
2691 packet[3] |= 0x20
2692 ;
2693 if(them.stones_periodscxx . . $ TimeRecord#stones_periods. == -1)
2694 packet[4] = game->stones_periodscxx . . $ GameData#stones_periods.;
2695 else
2696 packet[4] = them.stones_periodscxx . . $ TimeRecord#stones_periods.;
2697 packet[5] = them.timecxx . . $ TimeRecord#time. % 60;
2698 packet[6] = (them.timecxx . . $ TimeRecord#time. - packet[5]) / 60;
2699 if(game->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
2700 packet[7] = 0x80;
2701 else
2702 packet[7] = 0x40;
2703 if(them.stones_periodscxx . . $ TimeRecord#stones_periods. != -1)
2704 packet[7] |= 0x20;
2705 }
2706
2707 void TygemConnectioncxx . . $ TygemConnection#::sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(unsigned int game_id, MoveRecordcxx . . $ MoveRecord# * move)
2708 {
2709 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_id);
2710 if(!boarddispatch)
2711 {
2712 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for send move: %d", game_id);
2713 return;
2714 }
2715 GameDatacxx . . $ GameData# * r = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
2716
2717 char move_str[32];
2718 int player_number;
2719 unsigned int i;
2720 /*if(move->number + 2 > move_message_number)
2721 move_message_number = move->number + 2;
2722 else*/
2723 if(move->flagscxx . . $ MoveRecord#flags. != MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE. && move->flagscxx . . $ MoveRecord#flags. != MoveRecordcxx . . $ MoveRecord#::REQUESTUNDOcxx . . $ MoveRecord#REQUESTUNDO. && move->flagscxx . . $ MoveRecord#flags. != MoveRecordcxx . . $ MoveRecord#::REFUSEUNDOcxx . . $ MoveRecord#REFUSEUNDO.)
2724 move_message_numbercxx . . $ TygemConnection#move_message_number.++;
2725 //0001 //color
2726 //0000 0000 0000 ADBA //probably like 8 zeroes
2727 //text string ending in 200a and 0 padded out to the full 32
2728 //like:
2729 //SUR 0 2 2 white surrenders
2730 //STO 0 move_number player_number x y 0a
2731 //SUR 0 move_number player_number 0a
2732 //REM 0 312 -1 -1 0 1
2733 //REM 0 307 5 6 1 0
2734 //REM 0 306 10 14 2 0 un remove?
2735 //REM 0 number x y player_number 0
2736 //DSC 1 0 1 //dead stone clear, I think, maybe not
2737 //DSC 1 0 2
2738
2739 //BAC 0 246 1 //part of review
2740 //CSP 0 233 0
2741 //CST 0 234
2742 //FOR 0 186 1
2743 //BEG 0 47
2744 //INI is in gibo files also as move number 1
2745 /* Might also just be stone color here without the flag */
2746 //player_number = ((r->black_name == getUsername()) ^ r->white_first_flag) + 1;
2747 //1 is likely black, 2, white
2748 player_number = (r->black_namecxx . . $ GameData#black_name. !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) + 1;
2749 //player_number = SECOND_BYTE(send_flags);
2750 switch(move->flagscxx . . $ MoveRecord#flags.)
2751 {
2752 case MoveRecordcxx . . $ MoveRecord#::RESIGNcxx . . $ MoveRecord#RESIGN.:
2753 //if this is resign, we also have to
2754 //send the 0670 or 0672 or whatever if its our offer/game
2755 sprintf(move_str, "SUR %d %d %d \n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number., player_number);
2756 break;
2757 case MoveRecordcxx . . $ MoveRecord#::DONE_SCORINGcxx . . $ MoveRecord#DONE_SCORING.:
2758 case MoveRecordcxx . . $ MoveRecord#::REMOVE_AREAcxx . . $ MoveRecord#REMOVE_AREA.: //very awkward, this is really return to match mode, but don't want to trigger done_scoring endgame msg below
2759 /* Looks like this is a little different at the end...
2760 * doesn't seem to be a player number*/
2761 sprintf(move_str, "REM %d %d -1 -1 %d %d \n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number., 0, 1 );
2762 break;
2763 case MoveRecordcxx . . $ MoveRecord#::REMOVEcxx . . $ MoveRecord#REMOVE.:
2764 //move number continues here ! FIXME
2765 /* I sent a move_message_number here of 33763 by accident and
2766 * it crashed the official eWeiQi client. There's no error checking
2767 * there, its potentially an exploit even, not that our client
2768 * doesn't have those as well but... our client's not done yet... */
2769 sprintf(move_str, "REM %d %d %d %d %d %d \n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number., move->xcxx . . $ MoveRecord#x. - 1, move->ycxx . . $ MoveRecord#y. - 1, player_number, 0 );
2770 break;
2771 case MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE.:
2772 //we can only unremove all stones!, dead stone clear
2773 if(move->colorcxx . . $ MoveRecord#color. == stoneErasecxx . . $ stoneErase.)
2774 {
2775 if(player_number == 1)
2776 player_number = 2;
2777 else
2778 player_number = 1;
2779 }
2780 sprintf(move_str, "DSC %d %d %d \n", 1, 0, player_number);
2781 break;
2782 case MoveRecordcxx . . $ MoveRecord#::PASScxx . . $ MoveRecord#PASS.:
2783 //we might always send a 0669 as well before the SKI
2784 //0669 might be the real pass and SKI just the board skip
2785 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(r, passcxx . . $ TygemConnection#pass.);
2786 sprintf(move_str, "SKI %d %d \n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number.); //is that space newline okay? FIXME
2787 break;
2788 case MoveRecordcxx . . $ MoveRecord#::REQUESTUNDOcxx . . $ MoveRecord#REQUESTUNDO.:
2789 //shouldn't be sent during rated games I don't think
2790 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(r, request_undocxx . . $ TygemConnection#request_undo.);
2791 return;
2792 break;
2793 case MoveRecordcxx . . $ MoveRecord#::REFUSEUNDOcxx . . $ MoveRecord#REFUSEUNDO.:
2794 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(r, refuse_undo_requestcxx . . $ TygemConnection#refuse_undo_request.);
2795 return;
2796 break;
2797 case MoveRecordcxx . . $ MoveRecord#::UNDOcxx . . $ MoveRecord#UNDO.:
2798 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(r, accept_undo_requestcxx . . $ TygemConnection#accept_undo_request.);
2799 int undo_player_number;
2800 // double check FIXME
2801 if(r->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
2802 undo_player_number = 2;//(player_number == 1 ? 2 : 1);
2803 else
2804 undo_player_number = 1;//player_number;
2805 sprintf(move_str, "WIT %d %d %d\n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number., undo_player_number);
2806 break;
2807 case MoveRecordcxx . . $ MoveRecord#::NONEcxx . . $ MoveRecord#NONE.:
2808 default:
2809 sprintf(move_str, "STO %d %d %d %d %d \n", 0, move_message_numbercxx . . $ TygemConnection#move_message_number., player_number, move->xcxx . . $ MoveRecord#x. - 1, move->ycxx . . $ MoveRecord#y. - 1);
2810 break;
2811 }
2812 unsigned int length = 16 + strlen(move_str);
2813 while(length % 4 != 0)
2814 length++;
2815 length += 4;
2816 unsigned char * packet = new unsigned char[length];
2817
2818 packet[0] = (length >> 8);
2819 packet[1] = length & 0x00ff;
2820 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2821 packet[3] = 0x68;
2822 packet[4] = (r->numbercxx . . $ GameData#number. >> 8);
2823 packet[5] = r->numbercxx . . $ GameData#number. & 0x00ff;
2824 //definitely seen black here with 0, and our invite
2825 //also seen black here with 1 and not our invite
2826 //FIXME we could really try our_invitation here
2827 //but remember there's that 8th byte that gets
2828 //wrapped to the next row in the packet dumps
2829 /*if(!r->our_invitation)
2830 packet[6] = (r->black_name != getUsername());
2831 else
2832 packet[6] = (r->black_name == getUsername());*/
2833 packet[6] = !r->our_invitationcxx . . $ GameData#our_invitation.;
2834 //packet[6] = 0x00;
2835 //packet[6] = (r->black_name != getUsername());
2836 //packet[6] = r->white_first_flag;
2837 //packet[6] = FIRST_BYTE(send_flags);
2838 packet[7] = 0x01; //this as 0 didn't come back
2839 //packet[8] is definitely whether we accepted game
2840 packet[8] = !r->our_invitationcxx . . $ GameData#our_invitation.;
2841 for(i = 9; i < 16; i++)
2842 packet[i] = 0x00;
2843
2844 //int m = move_message_number;
2845 //if(move->flags == MoveRecord::UNREMOVE)
2846 // m++; //expects next message?
2847 packet[12] = (move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. >> 8); //this seems like its okay as 0, at least as far as I've seen
2848 packet[13] = move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. & 0x00ff;
2849
2850 strncpy((char *)&(packet[16]), move_str, strlen(move_str));
2851 for(i = strlen(move_str) + 16; i < length; i++)
2852 packet[i] = 0x00;
2853
2854 #ifdef RE_DEBUG
2855 printf("movepacket: ");
2856 for(i = 0; i < length; i++)
2857 printf("%02x ", packet[i]);
2858 printf("\n");
2859 for(i = 0; i < length; i++)
2860 printf("%c", packet[i]);
2861 printf("\n");
2862 #endif //RE_DEBUG
2863 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
2864 #ifdef RE_DEBUG
2865 qDebug("Sending move");
2866 #endif //RE_DEBUG
2867 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
2868 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending move packet");
2869 delete[] packet;
2870
2871 if(move->flagscxx . . $ MoveRecord#flags. == MoveRecordcxx . . $ MoveRecord#::RESIGNcxx . . $ MoveRecord#RESIGN.)
2872 {
2873 //FIXME, pretty sure this is just if its our game
2874 //actually maybe loser does always send this
2875 // !!person who accepted offer sends 0672!! FIXME
2876 // or maybe not on the above?
2877 sendMatchResultcxx . . $ TygemConnection#sendMatchResult(ed53e3bbd3fa2f69).(r->numbercxx . . $ GameData#number.);
2878 if(r->movescxx . . $ GameData#moves. < 14)
2879 {
2880 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
2881 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
2882 if(r->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
2883 {
2884 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). r->black_namecxx . . $ GameData#black_name.;
2885 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneBlackcxx . . $ stoneBlack.;
2886 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). r->white_namecxx . . $ GameData#white_name.;
2887 }
2888 else
2889 {
2890 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). r->white_namecxx . . $ GameData#white_name.;
2891 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneWhitecxx . . $ stoneWhite.;
2892 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). r->black_namecxx . . $ GameData#black_name.;
2893 }
2894 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
2895 }
2896 }
2897 else if(move->flagscxx . . $ MoveRecord#flags. == MoveRecordcxx . . $ MoveRecord#::DONE_SCORINGcxx . . $ MoveRecord#DONE_SCORING.)
2898 {
2899 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(r, done_scoringcxx . . $ TygemConnection#done_scoring.);
2900 }
2901 }
2902
2903 /* Move this elsewhere in file to be appropriately ordered */
2904 void TygemConnectioncxx . . $ TygemConnection#::writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).(char * p, const PlayerListingcxx . . $ PlayerListing# *player)
2905 {
2906 unsigned int ordinal;
2907 char qualifier;
2908
2909 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).(p, player->notnicknamecxx . . $ PlayerListing#notnickname., 14);
2910 p[14] = 0x00; //correct? doublecheck FIXME
2911 sscanf(player->rankcxx . . $ PlayerListing#rank..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), "%d%c", &ordinal, &qualifier);
2912 if(qualifier == 'k')
2913 p[15] = 0x12 - ordinal;
2914 else if(qualifier == 'p')
2915 p[15] = ordinal + 0x1a;
2916 else
2917 p[15] = ordinal + 0x11;
2918 }
2919
2920 void TygemConnectioncxx . . $ TygemConnection#::writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).(char * p, const PlayerListingcxx . . $ PlayerListing# * player)
2921 {
2922 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).(p, player->namecxx . . $ PlayerListing#name., 11);
2923 p[11] = player->country_idcxx . . $ PlayerListing#country_id.;
2924 }
2925
2926 /* We could use this in handlePlayerListing except that that would double the calls
2927 * to new since player listings are copied by room in entering them into the registry.
2928 * FIXME however, I can't off hand remember why it does that, so I should consider
2929 * fixing that to not copy construct the registry entries if that's okay
2930 * with all the registries. */
2931 PlayerListingcxx . . $ PlayerListing# * TygemConnectioncxx . . $ TygemConnection#::getOrCreatePlayerListingFromRecordcxx . . $ TygemConnection#getOrCreatePlayerListingFromRecord(c707c4736c9748ef).(char * r)
2932 {
2933 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
2934 unsigned char name[15];
2935 name[14] = 0x00;
2936
2937 strncpy((char *)name, r, 14);
2938 //QString encoded_name = QString((char *)name);
2939 QStringcxx . . $ QString# rankcxx . . $ QString#QString(ced63f7c635d850d).;
2940 unsigned char country_id;
2941 QStringcxx . . $ QString# encoded_name = serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
2942 if(r[15] < 0x12)
2943 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - r[15]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
2944 else if(r[15] > 0x1a)
2945 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(r[15] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
2946 else
2947 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(r[15] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
2948 strncpy((char *)name, &(r[16]), 11);
2949 //QString encoded_name2 = QString((char *)name);
2950 QStringcxx . . $ QString# encoded_name2 = serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
2951 country_id = r[27];
2952 PlayerListingcxx . . $ PlayerListing# * player = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
2953 return player;
2954 }
2955 /* This is in addition to and before the board SKI msg from sendMove()
2956 * and since its the same form, we're adding the counting messages to
2957 * it as well. Remember to delete sendCountMsg() FIXME*/
2958 void TygemConnectioncxx . . $ TygemConnection#::sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(const GameDatacxx . . $ GameData# * game, enum EGVersioncxx . . $ TygemConnection#EGVersion# version)
2959 {
2960 unsigned int length;
2961 if(version == opponent_disconnect_timercxx . . $ TygemConnection#opponent_disconnect_timer.)
2962 length = 0x38;
2963 else if(version == opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects.)
2964 length = 0x34;
2965 else
2966 length = 0x30;
2967 unsigned char * packet = new unsigned char[length];
2968 unsigned int i;
2969 PlayerListingcxx . . $ PlayerListing# * opponent;
2970
2971 packet[0] = (length >> 8);
2972 packet[1] = length & 0x00ff;
2973 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
2974 if(version == passcxx . . $ TygemConnection#pass.)
2975 packet[3] = 0x69;
2976 else if(version == request_countcxx . . $ TygemConnection#request_count.)
2977 packet[3] = 0x6a;
2978 else if(version == accept_count_requestcxx . . $ TygemConnection#accept_count_request. ||
2979 version == refuse_count_requestcxx . . $ TygemConnection#refuse_count_request.)
2980 packet[3] = 0x6b;
2981 else
2982 packet[3] = 0x7b;
2983 packet[4] = (game->numbercxx . . $ GameData#number. >> 8);
2984 packet[5] = game->numbercxx . . $ GameData#number. & 0x00ff;
2985 /*if(!game->our_invitation)
2986 packet[6] = (game->black_name != getUsername());
2987 else
2988 packet[6] = (game->black_name == getUsername());*/
2989 packet[6] = !game->our_invitationcxx . . $ GameData#our_invitation.;
2990 //packet[6] = (game->black_name == getUsername());
2991 if(version == opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects.) //try this FIXME?
2992 packet[7] = 0x00;
2993 else
2994 packet[7] = 0x01; //see discussions in sendMove about bytes 6, 7 and 8
2995
2996 //is opp_name encoded or normal? we need to look up so, this matters FIXME
2997 // Also, there's a boarddispatch->getOpponentName() function, clean this stuff up FIXME
2998 opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).((game->black_namecxx . . $ GameData#black_name. !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? game->black_namecxx . . $ GameData#black_name. : game->white_namecxx . . $ GameData#white_name.));
2999
3000 if(version == opponent_disconnect_timercxx . . $ TygemConnection#opponent_disconnect_timer.)
3001 {
3002 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[8]), getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).(), 14);
3003 for(i = 22; i < 36; i++)
3004 packet[i] = 0x00;
3005 }
3006 else if(version == opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects.)
3007 {
3008 writeZeroPaddedStringcxx . . $ NetworkConnection#writeZeroPaddedString(13ac1ff599cf8ed8).((char *)&(packet[8]), opponent->notnicknamecxx . . $ PlayerListing#notnickname., 14);
3009 for(i = 22; i < 36; i++)
3010 packet[i] = 0x00;
3011 }
3012 else
3013 {
3014 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[8]), opponent);
3015 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[24]), opponent);
3016 }
3017
3018 for(i = 36; i < length; i++)
3019 packet[i] = 0x00;
3020
3021 switch(version)
3022 {
3023 case done_scoringcxx . . $ TygemConnection#done_scoring.:
3024 packet[37] = 0xc5;
3025 break;
3026 case reject_countcxx . . $ TygemConnection#reject_count.:
3027 {
3028 MoveRecordcxx . . $ MoveRecord# aMovecxx . . $ MoveRecord#MoveRecord(49f6e7a06ebc5aa8).;
3029 aMove.flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::REMOVE_AREAcxx . . $ MoveRecord#REMOVE_AREA.; //really return to match mode
3030 sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(game->numbercxx . . $ GameData#number., &aMove);
3031 packet[37] = 0xc6;
3032 }
3033 break;
3034 case accept_countcxx . . $ TygemConnection#accept_count.:
3035 packet[36] = 0x01;
3036 packet[37] = 0xc6;
3037 break;
3038 // sure this is draw and not adjourn ?!?!
3039 // looks like it but translate the chinese
3040 // FIXME
3041 case request_drawcxx . . $ TygemConnection#request_draw.:
3042 packet[36] = 0x01;
3043 packet[37] = 0xc3;
3044 break;
3045 case accept_draw_requestcxx . . $ TygemConnection#accept_draw_request.:
3046 packet[36] = 0x01;
3047 packet[37] = 0xc4;
3048 break;
3049 case refuse_draw_requestcxx . . $ TygemConnection#refuse_draw_request.:
3050 //packet[36] = 0x00; //implied, same below
3051 packet[37] = 0xc4;
3052 break;
3053 case accept_count_requestcxx . . $ TygemConnection#accept_count_request.:
3054 packet[36] = 0x01;
3055 break;
3056 case opponent_disconnect_timercxx . . $ TygemConnection#opponent_disconnect_timer.:
3057 {
3058 packet[36] = 0x01;
3059 packet[37] = 0xf1;
3060 packet[38] = 0x0c;
3061 //packet[39] = 0x00;
3062 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game->numbercxx . . $ GameData#number.);
3063 if(!boarddispatch)
3064 {
3065 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opponent disconnect but no board dispatch");
3066 return;
3067 }
3068 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[40]));
3069 packet[48] = seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. & 0x00ff;
3070 packet[49] = (seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. >> 8);
3071 }
3072 break;
3073 case we_resumecxx . . $ TygemConnection#we_resume.:
3074 packet[36] = 0x01;
3075 packet[37] = 0xf0;
3076 //packet[38] = 0x00;
3077 //packet[39] = 0x00;
3078 break;
3079 case opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects.:
3080 {
3081 //packet[36] = 0x00;
3082 packet[37] = 0xf1;
3083 packet[38] = 0x08;
3084 //packet[39] = 0x00;
3085 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game->numbercxx . . $ GameData#number.);
3086 if(!boarddispatch)
3087 {
3088 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opponent disconect but no board dispatch");
3089 return;
3090 }
3091 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[40]));
3092 }
3093 break;
3094 case request_undocxx . . $ TygemConnection#request_undo.:
3095 packet[37] = 0xc1;
3096 break;
3097 case refuse_undo_requestcxx . . $ TygemConnection#refuse_undo_request.:
3098 packet[37] = 0xc2;
3099 break;
3100 case accept_undo_requestcxx . . $ TygemConnection#accept_undo_request.:
3101 packet[36] = 0x01;
3102 packet[37] = 0xc2;
3103 break;
3104 default:
3105 break;
3106 }
3107
3108 #ifdef RE_DEBUG
3109 printf("Endgame packet:\n");
3110 for(i = 0; i < length; i++)
3111 printf("%02x ", packet[i]);
3112 printf("\n");
3113 #endif //RE_DEBUG
3114
3115 /* FIXME, we should somehow have this standard thing attached to all send
3116 * messages instead of duplicating the code everywhere */
3117 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3118 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending endgame msg");
3119 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3120 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending endgame msg packet");
3121 delete[] packet;
3122
3123 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getBoardDispatchcxx . . $ NetworkConnection#getBoardDispatch(f34f0704202202).(game->numbercxx . . $ GameData#number.);
3124 if(!boarddispatch)
3125 {
3126 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for our game: %d", game->numbercxx . . $ GameData#number.);
3127 return;
3128 }
3129
3130 if(version != passcxx . . $ TygemConnection#pass. && version != opponent_disconnect_timercxx . . $ TygemConnection#opponent_disconnect_timer. &&
3131 version != we_resumecxx . . $ TygemConnection#we_resume. && version != opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects. &&
3132 version != request_undocxx . . $ TygemConnection#request_undo. && version != refuse_undo_requestcxx . . $ TygemConnection#refuse_undo_request. &&
3133 version != accept_undo_requestcxx . . $ TygemConnection#accept_undo_request.) //double check undo and stop time 0683 FIXME
3134 sendStopTimecxx . . $ TygemConnection#sendStopTime(77d63710c4751141).(boarddispatch, version);
3135 }
3136
3137 /* These seem like they're sent really liberally:
3138 - after match offerer hits done_scoring first
3139 - after match offerer accepts count
3140 - after match accepter hits done_scoring first
3141 - after match accepter rejects count
3142 - after match accepter hits done_scoring second
3143 - after match acccepter accepts count
3144 And they're all basically the same... I imagine they're some kind of
3145 server update but clients could use them for info too, they do get
3146 them as far as I know so the server does pass them on.
3147
3148 There also might be a stop/start flag... maybe... FIXME
3149 */
3150 void TygemConnectioncxx . . $ TygemConnection#::sendStopTimecxx . . $ TygemConnection#sendStopTime(77d63710c4751141).(BoardDispatchcxx . . $ BoardDispatch# * boarddispatch, enum EGVersioncxx . . $ TygemConnection#EGVersion# version)
3151 {
3152 unsigned int length = 0x18;
3153 unsigned char * packet = new unsigned char[length];
3154 unsigned int i;
3155 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3156
3157 packet[0] = (length >> 8);
3158 packet[1] = length & 0x00ff;
3159 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3160 packet[3] = 0x83;
3161 packet[4] = (game->numbercxx . . $ GameData#number. >> 8);
3162 packet[5] = game->numbercxx . . $ GameData#number. & 0x00ff;
3163
3164 packet[6] = 0xaa; //no idea
3165 packet[7] = 0x01; //color == black ?
3166 packet[8] = (version == done_scoringcxx . . $ TygemConnection#done_scoring. ? 0x03 : 0x05);
3167 packet[9] = 0x00;
3168 packet[10] = 0x00; //this might be 0x01 if after accept count
3169 packet[11] = 0x00;
3170
3171 /* Below is taken from sendTime(): (and shifted by 4 bytes, gd => game)*/
3172 //03 0a 12 80 03 19 12 40 00 00 00 00
3173 //03 07 0f 80 03 30 11 40 00 00 00 00
3174 //03 33 13 80 03 23 13 40 00 00 00 00
3175
3176 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[12]));
3177 for(i = 20; i < length; i++)
3178 packet[i] = 0x00;
3179
3180 #ifdef RE_DEBUG
3181 printf("stop time packet:\n");
3182 for(i = 0; i < length; i++)
3183 printf("%02x ", packet[i]);
3184 printf("\n");
3185 #endif //RE_DEBUG
3186
3187 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3188 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending stop time");
3189 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3190 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending stop time packet");
3191 delete[] packet;
3192 //boarddispatch->stopTime();
3193 }
3194
3195 /* This appears to be sent by both players as part of
3196 * resuming a game after a disconnect, could restart time
3197 * more likely alters game listing in lobby */
3198 void TygemConnectioncxx . . $ TygemConnection#::sendResumeFromDisconnectcxx . . $ TygemConnection#sendResumeFromDisconnect(cb2f890c2fdad230).(unsigned int game_number)
3199 {
3200 unsigned int length = 0x0c;
3201 unsigned char * packet = new unsigned char[length];
3202 unsigned int i;
3203
3204 packet[0] = (length >> 8);
3205 packet[1] = length & 0x00ff;
3206 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3207 packet[3] = 0x8d;
3208 packet[4] = (game_number >> 8);
3209 packet[5] = game_number & 0x00ff;
3210 for(i = 6; i < length; i++)
3211 packet[i] = 0x00;
3212
3213 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3214 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending resume from disconnect");
3215 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3216 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending resume from disconnect");
3217 delete[] packet;
3218 }
3219
3220 void TygemConnectioncxx . . $ TygemConnection#::sendOpponentDisconnectcxx . . $ TygemConnection#sendOpponentDisconnect(89ee62dcaa58bdba).(unsigned int game_number, enum OpponentDisconnectUpdatecxx . . $ TygemConnection#OpponentDisconnectUpdate# opp)
3221 {
3222 unsigned int length = 0x18;
3223 unsigned char * packet = new unsigned char[length];
3224 unsigned int i;
3225 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
3226
3227 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
3228 if(!boarddispatch)
3229 {
3230 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't send opponent disconnect, no board for %d", game_number);
3231 return;
3232 }
3233 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3234 packet[0] = (length >> 8);
3235 packet[1] = length & 0x00ff;
3236 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3237 packet[3] = 0x81;
3238 packet[4] = (game->numbercxx . . $ GameData#number. >> 8);
3239 packet[5] = game->numbercxx . . $ GameData#number. & 0x00ff;
3240
3241 for(i = 8; i < length; i++)
3242 packet[i] = 0x00;
3243
3244 if(opp == opponent_disconnectcxx . . $ TygemConnection#opponent_disconnect.)
3245 {
3246 packet[6] = 0x06;
3247 //packet[6] = !game->our_invitation;
3248 packet[7] = 0x01; //not color
3249 }
3250 else if(opp == opponent_reconnectcxx . . $ TygemConnection#opponent_reconnect.)
3251 {
3252 packet[6] = 0x01;
3253 //packet[6] = !game->our_invitation;
3254 packet[7] = 0x01; //could this be the not invitation of the person to drop?
3255 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[8]));
3256 }
3257
3258 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3259 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending opp disconnect");
3260 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3261 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending opp disconnect packet");
3262 delete[] packet;
3263 }
3264
3265 /* Sent following the normal one */
3266 void TygemConnectioncxx . . $ TygemConnection#::sendLongOpponentDisconnectcxx . . $ TygemConnection#sendLongOpponentDisconnect(cb2f890c2fdad230).(unsigned int game_number)
3267 {
3268 unsigned int length = 0x40;
3269 unsigned char * packet = new unsigned char[length];
3270 unsigned int i;
3271 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
3272
3273 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
3274 if(!boarddispatch)
3275 {
3276 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't send long opponent disconnect, no board for %d", game_number);
3277 return;
3278 }
3279 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3280 packet[0] = (length >> 8);
3281 packet[1] = length & 0x00ff;
3282 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3283 packet[3] = 0x52;
3284
3285 game->opponentdropcountcxx . . $ GameData#opponentdropcount.++;
3286 QStringcxx . . $ QString# disconnect_info = "**Halt Daekuk GAME_BLOCK_IND! - room:" +cxx . . $ operator+(c75c3ae4eb9af1a8).
3287 QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(game_number) +cxx . . $ operator+(3d22f08efddf8107). " <" +cxx . . $ operator+(fab9b4f80031f353).
3288 //be careful here because there's usernames and nicknames FIXME
3289 (game->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? game->black_namecxx . . $ GameData#black_name. : game->white_namecxx . . $ GameData#white_name.) +cxx . . $ operator+(3d22f08efddf8107).
3290 "> cnt:" +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(game->opponentdropcountcxx . . $ GameData#opponentdropcount.);
3291 unsigned int str_len = strlen(disconnect_info.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
3292 for(i = 4; i < str_len; i++)
3293 packet[i] = disconnect_info.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()[i - 4];
3294 for(i = 4 + str_len; i < length; i++)
3295 packet[i] = 0x00;
3296
3297 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3298 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending long opp disconnect");
3299 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3300 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending long opp disconnect packet");
3301 delete[] packet;
3302
3303 seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. = 300;
3304 }
3305
3306 /* FIXME header uses "game_code" everywhere, but that's for oro,
3307 * tygem uses game_numbers */
3308 void TygemConnectioncxx . . $ TygemConnection#::sendOpponentDisconnectTimercxx . . $ TygemConnection#sendOpponentDisconnectTimer(cb2f890c2fdad230).(unsigned int game_number)
3309 {
3310 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
3311
3312 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
3313 if(!boarddispatch)
3314 {
3315 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't send opponent disconnect timer, no board for %d", game_number);
3316 return;
3317 }
3318 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3319 seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits.--;
3320 if(seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. == -1)
3321 {
3322 //just send a straight 0x0672
3323 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
3324 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::FORFEITcxx . . $ GameResult#FORFEIT.;
3325 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).();
3326 if(game->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
3327 {
3328 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneWhitecxx . . $ stoneWhite.;
3329 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). game->black_namecxx . . $ GameData#black_name.;
3330 }
3331 else
3332 {
3333 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneBlackcxx . . $ stoneBlack.;
3334 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). game->white_namecxx . . $ GameData#white_name.;
3335 }
3336 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
3337 sendLongMatchResultcxx . . $ TygemConnection#sendLongMatchResult(ed53e3bbd3fa2f69).(game_number);
3338 killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID.);
3339 opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID. = 0;
3340 /* FIXME we probably shouldn't have to look this up */
3341 PlayerListingcxx . . $ PlayerListing# * opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.);
3342 opponent->onlinecxx . . $ PlayerListing#online. = false;
3343 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! playerListingReceivedcxx . . $ NetworkConnection#playerListingReceived(122195e397f39e1b).(opponent);
3344 /* Note that we also need to do this if we get tired of waiting and resign the game FIXME FIXME */
3345 return;
3346 }
3347 /* Next, we need to figure when all these things get sent
3348 * as well as their being some other messages and custom 0672s
3349 * both for forfeits as well as DRAW messages
3350 * but the three bytes in the move and other headers are still
3351 * wrong, so we should fix that so we can, for instance, send resigns
3352 * again at least.
3353 * And then I think that the accepted_match_player needs to be cleared
3354 * or something and anyway, its an ugly way of doing it, but that
3355 * affects all the protocols so its a big deal */
3356 if((seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. + 1) % 60 == 0)
3357 {
3358 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(0cxx . . $ QString#QString(85c52e162fed56f9)., QStringcxx . . $ QString#QString(85c52e162fed56f9).("Opponent forfeits game in %1 minutes.").argcxx . . $ QString#arg(64ab2ed17cc11715).((seconds_until_opp_forfeitscxx . . $ TygemConnection#seconds_until_opp_forfeits. + 1) / 60));
3359 }
3360 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(game, opponent_disconnect_timercxx . . $ TygemConnection#opponent_disconnect_timer.);
3361 }
3362
3363 /* As far as I can tell, we send the match result if we win... */
3364 void TygemConnectioncxx . . $ TygemConnection#::sendResultcxx . . $ TygemConnection#sendResult(f9859626c725809).(GameDatacxx . . $ GameData# * game, GameResultcxx . . $ GameResult# * result)
3365 {
3366 //if(!game->our_invitation)
3367 if(result->winner_namecxx . . $ GameResult#winner_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
3368 sendLongMatchResultcxx . . $ TygemConnection#sendLongMatchResult(ed53e3bbd3fa2f69).(game->numbercxx . . $ GameData#number.);
3369 }
3370
3371 void TygemConnectioncxx . . $ TygemConnection#::sendRequestCountcxx . . $ TygemConnection#sendRequestCount(cb2f890c2fdad230).(unsigned int game_id)
3372 {
3373 BoardDispatchcxx . . $ BoardDispatch# * bd = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_id);
3374 if(!bd)
3375 {
3376 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for %d", game_id);
3377 }
3378 GameDatacxx . . $ GameData# * gd = bd->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3379 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(gd, request_countcxx . . $ TygemConnection#request_count.);
3380 }
3381
3382 void TygemConnectioncxx . . $ TygemConnection#::sendAcceptCountRequestcxx . . $ TygemConnection#sendAcceptCountRequest(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3383 {
3384 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, accept_count_requestcxx . . $ TygemConnection#accept_count_request.);
3385 }
3386
3387 void TygemConnectioncxx . . $ TygemConnection#::sendRefuseCountRequestcxx . . $ TygemConnection#sendRefuseCountRequest(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3388 {
3389 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, refuse_count_requestcxx . . $ TygemConnection#refuse_count_request.);
3390 }
3391
3392 void TygemConnectioncxx . . $ TygemConnection#::sendRequestDrawcxx . . $ TygemConnection#sendRequestDraw(cb2f890c2fdad230).(unsigned int game_id)
3393 {
3394 BoardDispatchcxx . . $ BoardDispatch# * bd = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_id);
3395 if(!bd)
3396 {
3397 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for %d", game_id);
3398 }
3399 GameDatacxx . . $ GameData# * gd = bd->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3400 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(gd, request_drawcxx . . $ TygemConnection#request_draw.);
3401 }
3402
3403 void TygemConnectioncxx . . $ TygemConnection#::sendAcceptDrawRequestcxx . . $ TygemConnection#sendAcceptDrawRequest(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3404 {
3405 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, accept_draw_requestcxx . . $ TygemConnection#accept_draw_request.);
3406 }
3407
3408 void TygemConnectioncxx . . $ TygemConnection#::sendRefuseDrawRequestcxx . . $ TygemConnection#sendRefuseDrawRequest(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3409 {
3410 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, refuse_draw_requestcxx . . $ TygemConnection#refuse_draw_request.);
3411 }
3412
3413 void TygemConnectioncxx . . $ TygemConnection#::sendRejectCountcxx . . $ TygemConnection#sendRejectCount(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3414 {
3415 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, reject_countcxx . . $ TygemConnection#reject_count.);
3416 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#(); //here?? FIXME
3417 //aMove->color = stoneErase;
3418 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE.;
3419 sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(data->numbercxx . . $ GameData#number., aMove);
3420 delete aMove;
3421 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->startMatchcxx . . $ MatchNegotiationState#startMatch(49f6e7a06ebc5aa8).(); //reset passes
3422 }
3423
3424 void TygemConnectioncxx . . $ TygemConnection#::sendAcceptCountcxx . . $ TygemConnection#sendAcceptCount(53acbc9cc3152f0d).(GameDatacxx . . $ GameData# * data)
3425 {
3426 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(data, accept_countcxx . . $ TygemConnection#accept_count.);
3427 }
3428 /* FIXME pretty much all messages that I can think of off the top of my head
3429 * come back from the server meaning that perhaps we should not act on any
3430 * messages until they come back? Much like placing stones? */
3431
3432
3433 /* Loser sends this after resign, but I think only if they offered
3434 * the game
3435 * Not sure here, looks like winner sends 0672, but again, I've so
3436 * far only seen that when it was the person offering...
3437 * offer loser does not send, non-offer-loser does send, I think (0672)
3438 * also, FIXME, we use "match" and "game" inconsistently */
3439 /* I think loser has to send this upon accepting a lost match... ?
3440 * or maybe I just screwed up the 7b */
3441 void TygemConnectioncxx . . $ TygemConnection#::sendMatchResultcxx . . $ TygemConnection#sendMatchResult(ed53e3bbd3fa2f69).(unsigned short game_code)
3442 {
3443 unsigned int length = 0x30;
3444 unsigned char * packet = new unsigned char[length];
3445 unsigned int i;
3446 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_code);
3447 if(!boarddispatch)
3448 {
3449 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for %d for match result send", game_code);
3450 return;
3451 }
3452 /* We need to notify boarddispatch of finished game so we can
3453 * get the full result */
3454 //boarddispatch->recvResult(0); //doublecheck FIXME don't think we need to do this anymore
3455 /* Unless we ever send it with the score margin from somewhere else */
3456 GameDatacxx . . $ GameData# *aGameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3457 packet[0] = (length >> 8);
3458 packet[1] = length & 0x00ff;
3459 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3460 packet[3] = 0x70;
3461 packet[4] = (game_code >> 8);
3462 packet[5] = game_code & 0x00ff;
3463
3464 //packet[6] = 0x00; //winner color
3465 //packet[6] = (aGameData->black_name == getUsername()) ^ aGameData->white_first_flag;
3466 //definitely who offered
3467 packet[6] = !aGameData->our_invitationcxx . . $ GameData#our_invitation.;
3468 packet[7] = 0x01;
3469
3470 PlayerListingcxx . . $ PlayerListing# * opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(aGameData->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? aGameData->white_namecxx . . $ GameData#white_name. : aGameData->black_namecxx . . $ GameData#black_name.);
3471
3472 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[8]), opponent);
3473 writeNicknameAndCIDcxx . . $ TygemConnection#writeNicknameAndCID(68fc2a8c6a57e4cc).((char *)&(packet[24]), opponent);
3474
3475 //certainly all zeroes if resign
3476 /*
3477 if(!aGameData->fullresult)
3478 {
3479 qDebug("No result on game data to send result");
3480 return;
3481 }
3482 float margin = aGameData->fullresult->winner_score - aGameData->fullresult->loser_score;
3483 packet[10] = (int)margin & 0x00ff;
3484 packet[11] = ((int)margin >> 8);
3485 */
3486 for(i = 36; i < length; i++)
3487 packet[i] = 0x00;
3488 #ifdef RE_DEBUG
3489 printf("Sending match result:\n");
3490 for(i = 0; i < length; i++)
3491 printf("%02x", packet[i]);
3492 printf("\n");
3493 #endif //RE_DEBUG
3494 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3495 #ifdef RE_DEBUG
3496 qDebug("Sending match result");
3497 #endif //RE_DEBUG
3498 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3499 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending match result");
3500 delete[] packet;
3501 }
3502
3503 /* FIXME we also use game_code and number inconsistently as holdover from
3504 * oro code. */
3505 void TygemConnectioncxx . . $ TygemConnection#::sendLongMatchResultcxx . . $ TygemConnection#sendLongMatchResult(ed53e3bbd3fa2f69).(unsigned short game_code)
3506 {
3507 unsigned int tygem_game_record_str_length;
3508 unsigned int i;
3509
3510 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_code);
3511 if(!boarddispatch)
3512 {
3513 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for %d for match result send", game_code);
3514 return;
3515 }
3516 /* We need to notify boarddispatch of finished game so we can
3517 * get the full result */
3518 //boarddispatch->recvResult(0);
3519 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
3520
3521
3522 QByteArraycxx . . $ QByteArray# tygem_game_record = getTygemGameRecordQByteArraycxx . . $ TygemConnection#getTygemGameRecordQByteArray(921a24916160e04).(game);
3523 if(tygem_game_record ==cxx . . $ `operator==`(be1acefd00fee2fd). QByteArraycxx . . $ QByteArray#QByteArray(ced63f7c635d850d).())
3524 return; //error already reported by function
3525 tygem_game_record_str_length = tygem_game_record.sizecxx . . $ QByteArray#size(455f465bc33b4cdf).();
3526 #ifdef RE_DEBUG
3527 printf("Tygem game record length: %d\n", tygem_game_record_str_length);
3528 #endif //RE_DEBUG
3529 unsigned int length = 0x28 + tygem_game_record_str_length;
3530 while(length % 0x10 != 0)
3531 length++;
3532 unsigned char * packet = new unsigned char[length];
3533 packet[0] = (length >> 8);
3534 packet[1] = length & 0x00ff;
3535 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3536 packet[3] = 0x72;
3537 packet[4] = (game_code >> 8);
3538 packet[5] = game_code & 0x00ff;
3539 //6 may not matter?
3540 //FIXME need to consolidate these headers
3541 //packet[6] = (game->black_name == getUsername());
3542 /*if(!game->our_invitation)
3543 packet[6] = (game->black_name != getUsername());
3544 else
3545 packet[6] = (game->black_name == getUsername());*/
3546 packet[6] = !game->our_invitationcxx . . $ GameData#our_invitation.;
3547 packet[7] = 0x01; //see discussions in sendMove about bytes 6, 7 and 8
3548
3549 PlayerListingcxx . . $ PlayerListing# * opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.);
3550 writeNotNicknameAndRankcxx . . $ TygemConnection#writeNotNicknameAndRank(68fc2a8c6a57e4cc).((char *)&(packet[8]), opponent);
3551
3552 packet[24] = getVictoryCodecxx . . $ TygemConnection#getVictoryCode(28ad371a65273a73).(*(game->fullresultcxx . . $ GameData#fullresult.));
3553 packet[25] = 0x00;
3554 packet[26] = 0x00;
3555 //packet[27] = 0x3c; //what is this FIXME (score?)
3556 packet[27] = 0x00;
3557 packet[28] = (game->movescxx . . $ GameData#moves. >> 8);
3558 packet[29] = game->movescxx . . $ GameData#moves. & 0xff;
3559 packet[30] = 0x00;
3560 packet[31] = 0x00;
3561 //03 00 00 00 00 01 00 00 //opp white resigns
3562 //04 00 00 00 00 0e 00 00 //opp black resigns
3563 // 0b //draw
3564 //01 00 05 73 00 6c 00 00 //likely scores
3565 //
3566 fillTimeChunkcxx . . $ TygemConnection#fillTimeChunk(4dabb2484803c741).(boarddispatch, &(packet[32]));
3567
3568 for(i = 40; i < tygem_game_record_str_length + 40; i++)
3569 packet[i] = tygem_game_record.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).()[i - 40];
3570 for(i = 40 + tygem_game_record_str_length; i < length; i++)
3571 packet[i] = 0x00;
3572
3573 #ifdef RE_DEBUG
3574 printf("long match packet:\n");
3575 for(i = 0; i < length; i++)
3576 printf("%c ", packet[i]);
3577 printf("\nandinhex:\n");
3578 for(i = 0; i < length; i++)
3579 printf("%02x ", packet[i]);
3580 printf("\n");
3581 fflush(stdout);
3582
3583 //printf("And we're not sending this yet\n");
3584 //delete[] packet;
3585 //return;
3586 #endif //RE_DEBUG
3587
3588 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3589 #ifdef RE_DEBUG
3590 qDebug("Sending long match result");
3591 #endif //RE_DEBUG
3592 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3593 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending long match result");
3594 delete[] packet;
3595 }
3596
3597 /* FIXME convert from the tygem packets */
3598 /* Okay, I think this also happens to be the ".gib" gibo game file format
3599 * and further, I think you can request listings of players games. Now while
3600 * that latter requires some other windows to display and track games which
3601 * might even warrant a thumbnail explorer type window, etc., etc., which
3602 * basically puts it behind the "watch/fans/friends" list windows and
3603 * features for me, although I still might want to get the protocol
3604 * part down... but anyway, the point is, we might eventually change these
3605 * to a more generic function where the virtuals would just return the
3606 * specific labels somehow, or fill those labels in, for the different
3607 * servers and places
3608 * Actually, I think we should investigate the gamerecord retrieve protocols
3609 * because that might hint at what sort of info is used where and also
3610 * allow us to more precisely pin down the differences between the three
3611 * servers.*/
3612 /* Another note is that, I almost feel like putting english words in here
3613 * or something. For the most part only that last tag is I think read.
3614 * They also seem to change it sometimes. Like they change which words
3615 * are used, etc.. Anything mildly appropriate is probably fine. The worst
3616 * that could happen is someone would have an illegible game record, maybe
3617 * and even that's assuming the tag isn't read */
3618 QByteArraycxx . . $ QByteArray# TygemConnectioncxx . . $ TygemConnection#::getTygemGameRecordQByteArraycxx . . $ TygemConnection#getTygemGameRecordQByteArray(921a24916160e04).(GameDatacxx . . $ GameData# * game)
3619 {
3620 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
3621 const PlayerListingcxx . . $ PlayerListing# * black, * white;
3622 int black_ordinal, white_ordinal;
3623 char black_qualifier, white_qualifier;
3624 QByteArraycxx . . $ QByteArray# white_qualifier_stringcxx . . $ QByteArray#QByteArray(ced63f7c635d850d)., black_qualifier_stringcxx . . $ QByteArray#QByteArray(ced63f7c635d850d).;
3625 unsigned char black_level, white_level;
3626 unsigned short year;
3627 unsigned char month, day, hour, minute, second;
3628 secondsToDatecxx . . $ TygemConnection#secondsToDate(4b79e85d1d97ff5b).(year, month, day, hour, minute, second);
3629
3630 int margin = 0;
3631
3632 black = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->black_namecxx . . $ GameData#black_name.);
3633 white = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->white_namecxx . . $ GameData#white_name.);
3634 /* FIXME we need the korean dan qualifier character */
3635 sscanf(black->rankcxx . . $ PlayerListing#rank..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), "%d%c", &black_ordinal, &black_qualifier);
3636 if(black_qualifier == 'k')
3637 {
3638 black_level = 0x12 - black_ordinal;
3639 black_qualifier_string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb1\xde");
3640 }
3641 else if(black_qualifier == 'p')
3642 black_level = black_ordinal + 0x1a;
3643 else
3644 {
3645 black_level = black_ordinal + 0x11;
3646 black_qualifier_string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb4\xdc");
3647 }
3648 sscanf(white->rankcxx . . $ PlayerListing#rank..toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).(), "%d%c", &white_ordinal, &white_qualifier);
3649 if(white_qualifier == 'k')
3650 {
3651 white_level = 0x12 - white_ordinal;
3652 white_qualifier_string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb1\xde");
3653 }
3654 else if(white_qualifier == 'p')
3655 white_level = white_ordinal + 0x1a;
3656 else
3657 {
3658 white_level = white_ordinal + 0x11;
3659 white_qualifier_string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb4\xdc");
3660 }
3661
3662 QByteArraycxx . . $ QByteArray# stringcxx . . $ QByteArray#QByteArray(ced63f7c635d850d).;
3663 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GIBOKIND=China\\]\r\n";
3664 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[TYPE=0\\]\r\n";
3665 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMECONDITION=";
3666
3667 //there's also:
3668 //bbe7c8b02031203a20c8a3bcb1
3669 //which might be not enough moves
3670 //or no actually that was when I played a friendly
3671 //game with a huge handicap
3672 //c8a3bcb1203a20
3673 //room number??
3674 //c1fdb9dd20
3675 //b0f8c1a6
3676 //white player forfeits
3677 //c8a3bcb1203a20
3678 //room number (I think)
3679 //c1fdb9dd20
3680 //b0f8c1a6
3681 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc1\xa4\xbc\xb1");
3682 //c1a4bcb1 seems sufficient for a finished
3683 //game
3684 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n";
3685 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMETIME=";
3686 //FIXME doublecheck
3687 //c1a6 c7d1 bdc3 b0a3 20 minutes ba d0 0d 0a number c3 ca 20 c3 ca c0
3688 //d0 b1e2 20 periods b9f8
3689 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc1\xa6\xc6\xd1\xbd\xc3\xb0\xa3");
3690 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). " " +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->maintimecxx . . $ GameData#maintime.);
3691 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xba\xd0\x0d\x0a");
3692 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->periodtimecxx . . $ GameData#periodtime.);
3693 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc3\xca \xc3\xca\xc0\xd0\xb1\xe2");
3694 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). " " +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->stones_periodscxx . . $ GameData#stones_periods.);
3695 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb9\xf8");
3696 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n";
3697 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMERESULT="; //tygem is 3f203332393f203f with the 2 spaces in there
3698 //3f3332353f3f //w + 325 margin ONLY, no color
3699 //badac6e5cab1bce4caa4 B + T
3700
3701 switch(game->fullresultcxx . . $ GameData#fullresult.->resultcxx . . $ GameResult#result.)
3702 {
3703 case GameResultcxx . . $ GameResult#::DRAWcxx . . $ GameResult#DRAW.:
3704 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb9\xab\xbd\xc2\xba\xce");
3705 break;
3706 case GameResultcxx . . $ GameResult#::FORFEITcxx . . $ GameResult#FORFEIT.:
3707 if(game->fullresultcxx . . $ GameData#fullresult.->winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3708 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb9\xe9");
3709 else
3710 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc8\xe6");
3711 //c8e6 20 bdc3 b0a3 20 c3ca b0fa bdc2 //white forfeits
3712 string.appendcxx . . $ QByteArray#append(715145f812399bcb).(" \xbd\xc3\xb0\xa3 \xc3\xca\xb0\xfa\xbd\xc2");
3713 break;
3714 case GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.:
3715 if(game->fullresultcxx . . $ GameData#fullresult.->winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3716 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb9\xe9");
3717 else
3718 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc8\xe6");
3719 //c8e6 20 bdc3 b0a3 bdc2 //white loses on time
3720 string.appendcxx . . $ QByteArray#append(715145f812399bcb).(" \xbd\xc3\xb0\xa3\xbd\xc2");
3721 break;
3722 case GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.:
3723 if(game->fullresultcxx . . $ GameData#fullresult.->winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3724 {
3725 //b9e9 20 bad2 b0e8 bdc2
3726 //b0d7 c6e5 d6d0 c5cc caa4 W + R
3727 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xb9\xe9");
3728 }
3729 else
3730 {
3731 //c8e6 20 bad2 b0e8 bdc2
3732 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc8\xe6");
3733 }
3734 string.appendcxx . . $ QByteArray#append(715145f812399bcb).(" \xba\xd2\xb0\xe8\xbd\xc2");
3735 break;
3736 case GameResultcxx . . $ GameResult#::SCOREcxx . . $ GameResult#SCORE.:
3737 {
3738 float fmargin = game->fullresultcxx . . $ GameData#fullresult.->winner_scorecxx . . $ GameResult#winner_score. = game->fullresultcxx . . $ GameData#fullresult.->loser_scorecxx . . $ GameResult#loser_score.;
3739 margin = (int)fmargin;
3740 if(fmargin > (float)margin)
3741 margin = (margin * 10) + 5;
3742 else
3743 margin *= 10;
3744 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("FIXME margin: %d\n", margin); //margin 200? instead of 303? bug somewhere, somehow?
3745 //3f20 margin 3f3f203f //black wins
3746 //3f20 margin 3f203f //white wins?
3747 //string += QChar(0x3f);
3748 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). " " +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(margin);
3749 // QChar(0x3f3f) + " " + QChar(0x3f);
3750 //pretty sure these ??? are a mistake
3751 }
3752 break;
3753 default:
3754 break;
3755 }
3756 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n";
3757 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEZIPSU=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(margin) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3758 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEDUM=0\\]\r\n";
3759 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEGONGJE=0\\]\r\n";
3760 //often 65
3761 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMETOTALNUM="; //0xd7dc: 3335cafd" 35?
3762 //c3d13a20 moves bcf6
3763 //this has the number of moves in it I think
3764 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc3\xd1\x3a");
3765 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). " " +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(7a8a8d4503ae8074).(game->movescxx . . $ GameData#moves.);
3766 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xbc\xf6");
3767 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n";
3768 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[SZAUDIO=0\\]\r\n";
3769 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMENAME=";
3770 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xd3\xd1\xd2\xea\xb6\xd4\xbe\xd6");
3771 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n"; //c8b3bcb1
3772 /* Be careful here also, no idea what this says, we should
3773 * probably leave it blank */
3774 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEDATE=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(year) +cxx . . $ operator+(8f17b704cda0d21f). "-";
3775 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc4\xea");
3776 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(month);
3777 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xd4\xc2");
3778 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(day);
3779 string.appendcxx . . $ QByteArray#append(715145f812399bcb).("\xc8\xd5 \xcf\xc2\xce\xe7");
3780 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). " " +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(hour % 12) +cxx . . $ operator+(8f17b704cda0d21f).
3781 (minute < 10 ? ":0" : ":") +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(minute) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3782 /* Note that its very likely that one of the above strings contains a PM versus
3783 * AM */
3784 const char tygem_game_place_array[] = {static_cast<const char>(0xc5),static_cast<const char>(0xb8),
3785 static_cast<const char>(0xc0),static_cast<const char>(0xcc),
3786 static_cast<const char>(0xc1),static_cast<const char>(0xaa),
3787 static_cast<const char>(0x4c),static_cast<const char>(0x69),
3788 static_cast<const char>(0x76),static_cast<const char>(0x65),
3789 static_cast<const char>(0xb9),static_cast<const char>(0xd9),
3790 static_cast<const char>(0xb5),static_cast<const char>(0xcf)};
3791 QByteArraycxx . . $ QByteArray# tygem_game_placecxx . . $ QByteArray#QByteArray(34d26762b42c433a).(tygem_game_place_array, 14);
3792 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEPLACE=";
3793 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). tygem_game_place;
3794 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\]\r\n";
3795 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMELECNAME=\\]\r\n";
3796 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEWHITENAME=" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). "("
3797 +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white_ordinal)
3798 +cxx . . $ operator+(49e2485dc0bda598). white_qualifier_string +cxx . . $ operator+(8f17b704cda0d21f). ")\\]\r\n";
3799 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEWHITELEVEL=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white_level)
3800 +cxx . . $ operator+(49e2485dc0bda598). white_qualifier_string +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3801 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEWHITENICK=" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3802 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEWHITECOUNTRY=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3803 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEWAVATA=1\\]\r\n";
3804 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEWIMAGE=\\]\r\n";
3805 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEBLACKNAME=" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). "("
3806 +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black_ordinal)
3807 +cxx . . $ operator+(49e2485dc0bda598). black_qualifier_string +cxx . . $ operator+(8f17b704cda0d21f). ")\\]\r\n";
3808 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEBLACKLEVEL=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black_level)
3809 +cxx . . $ operator+(49e2485dc0bda598). black_qualifier_string +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3810 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEBLACKNICK=" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3811 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEBLACKCOUNTRY=" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3812 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEBAVATA=1\\]\r\n";
3813 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEBIMAGE=\\]\r\n";
3814 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMECOMMENT=\\]\r\n";
3815 //country = 2 = gbkind = gibokind
3816 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[GAMEINFOMAIN=GBKIND:2,GTYPE:0,GCDT:1,GTIME:" +cxx . . $ operator+(c76e440e68d4afec).
3817 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->maintimecxx . . $ GameData#maintime.) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598).
3818 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->periodtimecxx . . $ GameData#periodtime.) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598).
3819 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->stones_periodscxx . . $ GameData#stones_periods.) +cxx . . $ operator+(8f17b704cda0d21f). ",GRLT:0";
3820 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",ZIPSU:" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(margin) +cxx . . $ operator+(8f17b704cda0d21f).
3821 ",DUM:0,GONGJE:0,TCNT:" +cxx . . $ operator+(49e2485dc0bda598).
3822 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(7a8a8d4503ae8074).(game->movescxx . . $ GameData#moves.);
3823 //FIXME doublecheck game->moves is accurate
3824 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("FIXME Game moves: %d\n", game->movescxx . . $ GameData#moves.);
3825 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). ",AUSZ:0\\]\r\n";
3826 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). "\\[GAMEINFOSUB=GNAMEF:0,GPLCF:0,GNAME:"; //name is c8a3bcb1 just like name of game
3827 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "GDATE:" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(year) +cxx . . $ operator+(8f17b704cda0d21f). "- " +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(month)
3828 +cxx . . $ operator+(8f17b704cda0d21f). "- " +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(day) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(hour)
3829 +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(minute) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(second);
3830 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",GPLC:" +cxx . . $ operator+(c76e440e68d4afec). tygem_game_place;
3831 string +=cxx . . $ QByteArray#`operator+=`(715145f812399bcb). ",GCMT:\\]\r\n";
3832 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[WUSERINFO=WID:" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). ",WLV:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white_level) +cxx . . $ operator+(8f17b704cda0d21f).
3833 ",WNICK:" +cxx . . $ operator+(49e2485dc0bda598). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f). ",WNCD:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f).
3834 ",WAID:60001,WIMG:\\]\r\n";
3835 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). "\\[BUSERINFO=BID:" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). ",BLV:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black_level) +cxx . . $ operator+(8f17b704cda0d21f).
3836 ",BNICK:" +cxx . . $ operator+(49e2485dc0bda598). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f). ",BNCD:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f).
3837 ",BAID:60001,BIMG:\\]\r\n";
3838 /* I've seen 60001 for the BAID and WAID,
3839 * could be the image they use... maybe, ... */
3840 /* Here, I'm thinking S0 is black wins, S1 is white wins
3841 * then again, there's also W1 indicating white win with W0 as white loss */
3842 /* I've also seen W4 as indicating W + R */
3843 /* I've also seen S1 W7 as B + T also with Z0 indicating that's time remaining
3844 * or something */
3845 /* T is likely time settings, 30 seconds, 3 periods, 1200 total time maybe (20min)*/
3846 /* Also, I'm thinking Z and ZIPSU are the score, the margin */
3847
3848 /* From tygem: W0 B wins by score
3849 W3 B + R */
3850 /* if 3 and 4 are resigns, we might assume 6 and 7 are time, but then there's
3851 * the question of what 2 and 5 are... we need to see W win by score and by time */
3852 /* I suspect this is the stuff that really matters */
3853 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). getTygemGameTagQByteArraycxx . . $ TygemConnection#getTygemGameTagQByteArray(aa2910e9f95d7575).(game, white_level, black_level, margin);
3854
3855 //tag is simple of earlier info
3856 return stringcxx . . $ QByteArray#QByteArray(9f1b912973d89fea).;
3857 }
3858
3859 /* Arguably, this is the only part that matters */
3860 QByteArraycxx . . $ QByteArray# TygemConnectioncxx . . $ TygemConnection#::getTygemGameTagQByteArraycxx . . $ TygemConnection#getTygemGameTagQByteArray(aa2910e9f95d7575).(GameDatacxx . . $ GameData# * game, unsigned char white_level, unsigned char black_level, int margin)
3861 {
3862 /* This first bit is redundant with the only caller, but
3863 * I'm starting to feel lazier tonight and I don't want to pass
3864 * all those arguments or find some more elegant way of doing
3865 * this nonsense. FIXME */
3866 unsigned short year;
3867 unsigned char month, day, hour, minute, second;
3868 secondsToDatecxx . . $ TygemConnection#secondsToDate(4b79e85d1d97ff5b).(year, month, day, hour, minute, second);
3869
3870 const PlayerListingcxx . . $ PlayerListing# * white, * black;
3871
3872 black = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->black_namecxx . . $ GameData#black_name.);
3873 white = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(game->white_namecxx . . $ GameData#white_name.);
3874
3875 QByteArraycxx . . $ QByteArray# stringcxx . . $ QByteArray#QByteArray(ced63f7c635d850d).;
3876 string =cxx . . $ QByteArray#`operator=`(715145f812399bcb). "\\[GAMETAG=S0,R1,D0,GO";
3877 //I see a lot of R0 and G65
3878 //R could be rated...
3879 //S1 or maybe R3 could refer to a rated game
3880 //R0 means something too though
3881 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",W" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(getVictoryCodecxx . . $ TygemConnection#getVictoryCode(28ad371a65273a73).(*(game->fullresultcxx . . $ GameData#fullresult.)));
3882 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",Z" +cxx . . $ operator+(c76e440e68d4afec). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(margin);
3883 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",T" +cxx . . $ operator+(c76e440e68d4afec).
3884 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->periodtimecxx . . $ GameData#periodtime.) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598).
3885 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->stones_periodscxx . . $ GameData#stones_periods.) +cxx . . $ operator+(8f17b704cda0d21f). "-" +cxx . . $ operator+(49e2485dc0bda598).
3886 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(game->maintimecxx . . $ GameData#maintime.) +cxx . . $ operator+(8f17b704cda0d21f). ",C" +cxx . . $ operator+(49e2485dc0bda598).
3887 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(year) +cxx . . $ operator+(8f17b704cda0d21f). (month < 10 ? ":0" : ":") +cxx . . $ operator+(49e2485dc0bda598).
3888 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(month) +cxx . . $ operator+(8f17b704cda0d21f). (day < 10 ? ":0" : ":") +cxx . . $ operator+(49e2485dc0bda598).
3889 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(day) +cxx . . $ operator+(8f17b704cda0d21f). (hour < 10 ? ":0" : ":") +cxx . . $ operator+(49e2485dc0bda598).
3890 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(hour) +cxx . . $ operator+(8f17b704cda0d21f). (minute < 10 ? ":0" : ":") +cxx . . $ operator+(49e2485dc0bda598).
3891 QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(minute);/* + (second < 10 ? ":0" : ":") +
3892 QByteArray::number(second);*/
3893 string +=cxx . . $ QByteArray#`operator+=`(85c7caed82076bbb). ",I:" +cxx . . $ operator+(c76e440e68d4afec). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). ",L:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white_level) +cxx . . $ operator+(8f17b704cda0d21f).
3894 ",M:" +cxx . . $ operator+(49e2485dc0bda598). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->notnicknamecxx . . $ PlayerListing#notnickname.) +cxx . . $ operator+(8f17b704cda0d21f). ",N:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black_level) +cxx . . $ operator+(8f17b704cda0d21f).
3895 ",A:" +cxx . . $ operator+(49e2485dc0bda598). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(white->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f). ",B:" +cxx . . $ operator+(49e2485dc0bda598). serverCodeccxx . . $ TygemConnection#serverCodec.->fromUnicodecxx . . $ QTextCodec#fromUnicode(e72629479c734b12).(black->namecxx . . $ PlayerListing#name.) +cxx . . $ operator+(8f17b704cda0d21f).
3896 ",J:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(white->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f).
3897 ",K:" +cxx . . $ operator+(49e2485dc0bda598). QByteArraycxx . . $ QByteArray#::numbercxx . . $ QByteArray#number(4869bc8897d11479).(black->country_idcxx . . $ PlayerListing#country_id.) +cxx . . $ operator+(8f17b704cda0d21f). "\\]\r\n";
3898 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("GAMETAG: %s", string.constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
3899 return stringcxx . . $ QByteArray#QByteArray(9f1b912973d89fea).;
3900 }
3901
3902 unsigned char TygemConnectioncxx . . $ TygemConnection#::getVictoryCodecxx . . $ TygemConnection#getVictoryCode(28ad371a65273a73).(GameResultcxx . . $ GameResult# & aGameResult)
3903 {
3904 switch(aGameResult.resultcxx . . $ GameResult#result.)
3905 {
3906 case GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.:
3907 if(aGameResult.winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3908 return 8;
3909 else
3910 return 7;
3911 break;
3912 case GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.:
3913 if(aGameResult.winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3914 return 4;
3915 else
3916 return 3;
3917 break;
3918 case GameResultcxx . . $ GameResult#::SCOREcxx . . $ GameResult#SCORE.:
3919 if(aGameResult.winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3920 return 1;
3921 else
3922 return 0;
3923 break;
3924 case GameResultcxx . . $ GameResult#::FORFEITcxx . . $ GameResult#FORFEIT.:
3925 if(aGameResult.winner_colorcxx . . $ GameResult#winner_color. == stoneWhitecxx . . $ stoneWhite.)
3926 return 6;
3927 else
3928 return 5;
3929 break;
3930 case GameResultcxx . . $ GameResult#::DRAWcxx . . $ GameResult#DRAW.:
3931 return 2;
3932 break;
3933 default:
3934 break;
3935 }
3936 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unhandled GameResult code!!");
3937 return 0;
3938 }
3939
3940 /* It seems like this appears like a match invite if opponent closes
3941 * the window FIXME */
3942 void TygemConnectioncxx . . $ TygemConnection#::sendRematchRequestcxx . . $ TygemConnection#sendRematchRequest(49f6e7a06ebc5aa8).(void)
3943 {
3944 }
3945
3946 void TygemConnectioncxx . . $ TygemConnection#::sendRematchAcceptcxx . . $ TygemConnection#sendRematchAccept(49f6e7a06ebc5aa8).(void)
3947 {
3948 }
3949
3950 /* This really needs to be a whole packet of stuff but for now,
3951 * since the full thing requires some chinese translation: */
3952 void TygemConnectioncxx . . $ TygemConnection#::sendInvitationSettingscxx . . $ TygemConnection#sendInvitationSettings(b45ddcbc8423892c).(bool invite)
3953 {
3954 unsigned int length = 0x0c;
3955 unsigned char * packet = new unsigned char[length];
3956
3957 packet[0] = 0x00;
3958 packet[1] = 0x0c;
3959 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3960 packet[3] = 0xa2;
3961 packet[4] = (invite ? 0 : 2);
3962 packet[5] = 0xf0;
3963 packet[6] = 0xad;
3964 packet[7] = 0xba;
3965 packet[8] = 0x00;
3966 packet[9] = 0x00;
3967 packet[10] = 0x00;
3968 packet[11] = 0x00; //weird byte???
3969
3970 #ifdef RE_DEBUG
3971 printf("Sending invite settings: ");
3972 for(int i = 0; i < (int)length; i++)
3973 printf("%02x ", packet[i]);
3974 printf("\n");
3975 #endif //RE_DEBUG
3976 encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(packet, (length / 4) - 2);
3977 #ifdef RE_DEBUG
3978 printf("encoded: ");
3979 for(int i = 0; i < (int)length; i++)
3980 printf("%02x ", packet[i]);
3981 printf("\n");
3982 #endif //RE_DEBUG
3983 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending invitation settings\n");
3984 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
3985 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending invitation settings");
3986 delete[] packet;
3987 }
3988
3989 void TygemConnectioncxx . . $ TygemConnection#::sendDisconnectMsgcxx . . $ TygemConnection#sendDisconnectMsg(49f6e7a06ebc5aa8).(void)
3990 {
3991 unsigned int length = 8;
3992 unsigned char * packet = new unsigned char[length];
3993
3994 packet[0] = 0x00;
3995 packet[1] = 0x08;
3996 packet[2] = TYGEM_PROTOCOL_VERSIONcxx . . $ `src/network/tygemprotocol.h:22:9`!;
3997 packet[3] = TYGEM_SERVERDISCONNECTcxx . . $ `src/network/tygemprotocol.h:43:9`!;
3998 packet[4] = 0x00;
3999 packet[5] = 0x00;
4000 packet[6] = 0x00;
4001 packet[7] = 0x00;
4002
4003 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Sending server disconnect");
4004 if(writecxx . . $ NetworkConnection#write(1df18506ef0a631b).((const char *)packet, length) < 0)
4005 qWarningcxx . . $ `<external>/10450329605257866924/qlogging.h:166:9`!("*** failed sending server disconnect");
4006 delete[] packet;
4007 }
4008
4009 void TygemConnectioncxx . . $ TygemConnection#::encodecxx . . $ TygemConnection#encode(e1e8b00c42c42532).(unsigned char * p, unsigned int cycles)
4010 {
4011 uint32_tcxx . . $ uint32_t# b, c = 0;
4012 uint32_tcxx . . $ uint32_t# header = *(uint32_tcxx . . $ uint32_t# *)p;
4013 header ^= encode_offsetcxx . . $ TygemConnection#encode_offset.;
4014 p += 4;
4015 while(cycles--)
4016 {
4017 b = *(uint32_tcxx . . $ uint32_t# *)p;
4018 c ^= b;
4019 b ^= header;
4020 *(uint32_tcxx . . $ uint32_t# *)p = b;
4021 p += 4;
4022 }
4023 *(uint32_tcxx . . $ uint32_t# *)p = c;
4024 }
4025
4026 void TygemConnectioncxx . . $ TygemConnection#::handleMessagecxx . . $ TygemConnection#handleMessage(7df51288a9ebd664).(QStringcxx . . $ QString#)
4027 {
4028 }
4029
4030 /* We may convert everything here to unsigned char *s, delete the old...
4031 * we're still sort of hung up on all the things we were doing
4032 * to work with the IGS code. */
4033 void TygemConnectioncxx . . $ TygemConnection#::handleMessagecxx . . $ TygemConnection#handleMessage(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
4034 {
4035 unsigned short message_type = msg[3] + (msg[2] << 8);
4036 int i;
4037 //message_type = msg[0];
4038 //message_type >>= 8;
4039 //message_type += msg[1];
4040 /* Third byte is likely the size of the message meaning multiple
4041 * messages per packet, etc. */
4042 /*if((message_type & 0x00ff) == 0x00b3)
4043 {*/
4044 /*printf("\n****: \n");
4045 for(i = 0; i < (int)size; i++)
4046 printf("%02x", msg[i]);
4047 printf("\n\n");*/
4048 /*}*/
4049
4050 msg += 4;
4051 size -=4;
4052 switch(message_type)
4053 {
4054 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_GAMESINITcxx . . $ `src/network/tygemprotocol.h:24:9`!):
4055 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_GAMESUPDATEcxx . . $ `src/network/tygemprotocol.h:25:9`!):
4056 handleGamesListcxx . . $ TygemConnection#handleGamesList(e1e8b00c42c42532).(msg, size);
4057 break;
4058 // possibly update after game won, first 00df
4059 //009806130002000000df0000000100020000ff00706c6d64000000000000000000000011706c6d64003200390000000294ca
4060 //8ee1944c000000000000000000116c6c36366c6c006e673200010004000000110000010000020000ff00d0c4ccacc8e7c7ef
4061 //31000000000000006c6f6f706f706f7000390002ccecc9bdc0cf4b0000000000000000086c616f6b31320068657200020001
4062 //0000
4063
4064
4065 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_PLAYERSINITcxx . . $ `src/network/tygemprotocol.h:26:9`!):
4066 handlePlayerListcxx . . $ TygemConnection#handlePlayerList(e1e8b00c42c42532).(msg, size);
4067 //0653 request should also be sent here FIXME
4068 break;
4069 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_PLAYERSUPDATEcxx . . $ `src/network/tygemprotocol.h:27:9`!):
4070 handlePlayerListcxx . . $ TygemConnection#handlePlayerList(e1e8b00c42c42532).(msg, size);
4071 break;
4072 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x17):
4073 handleServerRoomChatcxx . . $ TygemConnection#handleServerRoomChat(e1e8b00c42c42532).(msg, size);
4074 break;
4075 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x18):
4076 //baec cec0 b1f8 0000 0000 0000 0000 0012
4077 //6877 6200 0000 0000 0000 0002
4078 //3030ff003d007a00
4079 //323fc7ebc7f3b0efd6faa3ac5b3132325db7bfbce4baeccec0b1f8c7ebc7f3b0efd6faa1a
4080 //328b6d4b2bbcec4c3f7b5c4c6e5d3d1cdb6cbdfa1a3290000000000
4081 //some kind of game announcement likely
4082
4083 //obviously announcements
4084 /* I got one of these on windows shortly before a server disconnect! weird FIXME */
4085 #ifdef RE_DEBUG
4086 printf("0x0618: ");
4087 for(i = 0; i < (int)size; i++)
4088 printf("%02x", msg[i]);
4089 printf("\n");
4090 #endif //RE_DEBUG
4091 break;
4092 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_OPENCONVERSATIONcxx . . $ `src/network/tygemprotocol.h:49:9`!):
4093 handleOpenConversationcxx . . $ TygemConnection#handleOpenConversation(e1e8b00c42c42532).(msg, size);
4094 break;
4095 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_CONVERSATIONREPLYcxx . . $ `src/network/tygemprotocol.h:50:9`!):
4096 handleConversationReplycxx . . $ TygemConnection#handleConversationReply(e1e8b00c42c42532).(msg, size);
4097 break;
4098 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_CONVERSATIONMSGcxx . . $ `src/network/tygemprotocol.h:51:9`!):
4099 handleConversationMsgcxx . . $ TygemConnection#handleConversationMsg(e1e8b00c42c42532).(msg, size);
4100 break;
4101 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_ROOMCREATEDcxx . . $ `src/network/tygemprotocol.h:29:9`!):
4102 handleCreateRoomResponsecxx . . $ TygemConnection#handleCreateRoomResponse(e1e8b00c42c42532).(msg, size);
4103 break;
4104 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x38):
4105 #ifdef RE_DEBUG
4106 printf("0x0638: ");
4107 for(i = 0; i < (int)size; i++)
4108 printf("%02x", msg[i]);
4109 printf("\n");
4110 #endif //RE_DEBUG
4111 //break;
4112 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_BOARDOPENEDcxx . . $ `src/network/tygemprotocol.h:30:9`!): //in response to 0638 sendJoin
4113 handleBoardOpenedcxx . . $ TygemConnection#handleBoardOpened(e1e8b00c42c42532).(msg, size);
4114 break;
4115 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHINVITEcxx . . $ `src/network/tygemprotocol.h:38:9`!):
4116 //0x0643: 70657465726975730000000000000001706574657269757300000000696e74727573696f6e00000000000
4117 // 009696e74727573696f6e0000020100ffff
4118 handleMatchInvitecxx . . $ TygemConnection#handleMatchInvite(e1e8b00c42c42532).(msg, size);
4119 break;
4120 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHINVITERESPONSEcxx . . $ `src/network/tygemprotocol.h:39:9`!):
4121 handleMatchInviteResponsecxx . . $ TygemConnection#handleMatchInviteResponse(e1e8b00c42c42532).(msg, size);
4122 break;
4123 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHOFFERcxx . . $ `src/network/tygemprotocol.h:40:9`!):
4124 #ifdef RE_DEBUG
4125 printf("0645: ");
4126 for(i = 0; i < (int)size; i++)
4127 printf("%02x", msg[i]);
4128 printf("\n");
4129 #endif //RE_DEBUG
4130 if(msg[43] == 0x02)
4131 handleMatchOffercxx . . $ TygemConnection#handleMatchOffer(892cc42ac5eea747).(msg, size, offercxx . . $ TygemConnection#offer.);
4132 else if(msg[43] == 0x03) //double check
4133 handleMatchOffercxx . . $ TygemConnection#handleMatchOffer(892cc42ac5eea747).(msg, size, declinecxx . . $ TygemConnection#decline.);
4134 else
4135 printf("*** 0645 match offer has strange type: %02x!!!\n", msg[43]);
4136 //type 0x1e could be rematch, or something else
4137 break;
4138 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHOFFERRESPONSEcxx . . $ `src/network/tygemprotocol.h:41:9`!):
4139 if(msg[43] == 0x01)
4140 handleMatchOffercxx . . $ TygemConnection#handleMatchOffer(892cc42ac5eea747).(msg, size, acceptcxx . . $ TygemConnection#accept.);
4141 else if(msg[43] == 0x02)
4142 handleMatchOffercxx . . $ TygemConnection#handleMatchOffer(892cc42ac5eea747).(msg, size, modifycxx . . $ TygemConnection#modify.);
4143 //match offer accept
4144 //00580646
4145 //0x0646: 70657465726975730000000000000008696e74727573696f6e000000000000090032012c2801010001
4146 //000001ffffffff000000000001000000000000706574657269757300000002696e74727573696f6e000002
4147 //00a00616
4148
4149
4150 //rematch related?
4151 //0646
4152 //c4ba d3ea b3bf d4c6 0000 0000 0000 0014
4153 //6269 7473 0000 0000 0000 0000 0000 0014
4154 //0003 012c 1e03 0000 0000 001e ffff ffff
4155 //ffff ffff 0001 0001 0000 0100 6a65 7070
4156 //3100 0000 0000 0002 6269 7473 0000 0000
4157 //0000 0002
4158 break;
4159 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_SERVERPINGcxx . . $ `src/network/tygemprotocol.h:31:9`!):
4160 #ifdef RE_DEBUG
4161 /*printf("0x064d: ");
4162 for(i = 0; i < (int)size; i++)
4163 printf("%02x", msg[i]);
4164 printf("\n");*/
4165 #endif //RE_DEBUG
4166 handleRequestKeepAlivecxx . . $ TygemConnection#handleRequestKeepAlive(e1e8b00c42c42532).(msg, size);
4167 break;
4168 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_GAMECHATcxx . . $ `src/network/tygemprotocol.h:52:9`!): //in game chat
4169 handleGameChatcxx . . $ TygemConnection#handleGameChat(e1e8b00c42c42532).(msg, size);
4170 break;
4171 //0633:
4172 //063370657465726975730000000000000008696e74727573696f6e00000000000009706574657269757300000002696e7
4173 //4727573696f6e000002000000000000020000000000
4174
4175 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_OBSERVERSINITcxx . . $ `src/network/tygemprotocol.h:33:9`!):
4176 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_OBSERVERSUPDATEcxx . . $ `src/network/tygemprotocol.h:34:9`!):
4177 //maybe we do have to request with oro...
4178 handleObserverListcxx . . $ TygemConnection#handleObserverList(e1e8b00c42c42532).(msg, size);
4179 break;
4180 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MOVEcxx . . $ `src/network/tygemprotocol.h:35:9`!):
4181 handleMovecxx . . $ TygemConnection#handleMove(e1e8b00c42c42532).(msg, size);
4182 break;
4183 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x69): //first pass
4184 handlePasscxx . . $ TygemConnection#handlePass(24a4435ba77f1dc6).(msg, size, 1);
4185 break;
4186 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x6a):
4187 handleCountRequestcxx . . $ TygemConnection#handleCountRequest(e1e8b00c42c42532).(msg, size);
4188 break;
4189 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x6b):
4190 handleCountRequestResponsecxx . . $ TygemConnection#handleCountRequestResponse(e1e8b00c42c42532).(msg, size);
4191 break;
4192 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x70):
4193 handleGameResult2cxx . . $ TygemConnection#handleGameResult2(e1e8b00c42c42532).(msg, size);
4194 break;
4195 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHcxx . . $ `src/network/tygemprotocol.h:53:9`!):
4196 handleMatchOpenedcxx . . $ TygemConnection#handleMatchOpened(e1e8b00c42c42532).(msg, size);
4197 break;
4198 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_MATCHRESULTcxx . . $ `src/network/tygemprotocol.h:54:9`!):
4199 handleGameResultcxx . . $ TygemConnection#handleGameResult(e1e8b00c42c42532).(msg, size);
4200 break;
4201 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x74):
4202 //067401f90001
4203 //0x0674: 00910101
4204 //I think this is the enter score message...
4205 //seems to happen after counts... but I don't get
4206 //who sends it... we get it if we request the count
4207 //from them and they agree FIXME
4208 //game number two bytes for colors sender something, also seen CSP nearby
4209 printf("0x0674: ");
4210 for(i = 0; i < (int)size; i++)
4211 printf("%02x", msg[i]);
4212 printf("\n");
4213 //I think this starts the review, maybe not
4214 break;
4215 //an REM -1 -1 likely proceeds these as meaning done?
4216 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_ENDGAMEMSGcxx . . $ `src/network/tygemprotocol.h:47:9`!):
4217 handleEndgameMsgcxx . . $ TygemConnection#handleEndgameMsg(e1e8b00c42c42532).(msg, size);
4218 break;
4219 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_TIMEcxx . . $ `src/network/tygemprotocol.h:36:9`!):
4220 handleTimecxx . . $ TygemConnection#handleTime(e1e8b00c42c42532).(msg, size);
4221 break;
4222 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x81):
4223 handleGameStateChangecxx . . $ TygemConnection#handleGameStateChange(e1e8b00c42c42532).(msg, size);
4224 break;
4225 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x83): //clock stop? //enter score?
4226 /* This comes a lot during broadcasted games, not
4227 * certain but could be time update, like stopped time
4228 * at the time listed */
4229 handleScoreMsg1cxx . . $ TygemConnection#handleScoreMsg1(e1e8b00c42c42532).(msg, size);
4230 break;
4231
4232 // probably 068d requests
4233 //068e 004d 0000 7065 7465 7269 7573 0000
4234 //0000 0000 0000 696e 7472 7573 696f 6e00
4235 //0000 0000 0001
4236
4237 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_SERVERPLAYERCOUNTScxx . . $ `src/network/tygemprotocol.h:32:9`!): //0653 requests
4238 //0651 might request this
4239 //in which case 0651 might not be
4240 //a disconnect
4241 handleServerPlayerCountscxx . . $ TygemConnection#handleServerPlayerCounts(e1e8b00c42c42532).(msg, size);
4242 break;
4243 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_RESUMEBROKENMATCHcxx . . $ `src/network/tygemprotocol.h:56:9`!):
4244 handleResumeMatchcxx . . $ TygemConnection#handleResumeMatch(e1e8b00c42c42532).(msg, size);
4245 break;
4246 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0xc7):
4247 //this is related to either a failed match create or a bad
4248 //sent message or maybe something legit
4249 //00280000696e74727573696f6e00000000000009 396b 0000000000000
4250 // I think we get these after we send 06c6, so that might
4251 // be like the creation confirm when its added to the list?
4252 // anyway, seems legit, I mean just names and ranks here:
4253 //000c000070657465726975730000000000000008696e74727573696f6e0000000000000900000000
4254 #ifdef RE_DEBUG
4255 printf("***0x06c7: ");
4256 for(i = 0; i < (int)size; i++)
4257 printf("%02x", msg[i]);
4258 printf("\n");
4259 #endif //RE_DEBUG
4260 break;
4261 //Two bytestrange: 0692:
4262 //0692696e74727573696f6e00000000000009696e74727573696f6e0049020000000000000000000000000000000000000
4263 //0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
4264 //0000000000000000000000000000002710006f756e742c2073746f74616c5f636f756e742c20737769000000000000000
4265 //10000000300000004000000056368696e61005f636f756e742c206c746f74616c5f636f0000000000004218b34d6f7573
4266 //652e676966006f73735f636f756e742c206c7400000000000000000000000000000000000000000000000000000000004
4267 //8f80619000000000000000000000000000000000000000000000000
4268
4269 //when we're trying to offer
4270 //706574657269757300000000000000087065746572697573002f490200000000000000000000000000
4271 //000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
4272 //0000000000000000000000000000000000000000000000002328006f756e742c2073746f74616c5f636f756e74
4273 //2c2073776900000000000000010000000300000004000000056368696e61005f636f756e742c206c746f74616c
4274 //5f636f000000000000406c8b4d6f7573652e676966006f73735f636f756e742c206c7400000000000000000000
4275 //0000000000000000000000000000000000000048fa788200000000000000000000000000000000000000000000
4276 //0000
4277
4278 //70657465726975730000000000000008
4279 //706574657269757300c7920200000015
4280 //00000011000000040000000000000009
4281 //0000000800000001000000000000000c
4282 //00000009000000030000000000000000
4283 //0000000000000000000000000000000c
4284 //00000009000000030000000000002457584f4f58584f4f4f4f4f4f4f005f636f756e742c2073776900000000000000010000000300000004000000056368696e61005f636f756e742c206c746f74616c5f636f00031b000000406c8b4d6f7573652e676966006f73735f636f756e742c206c74000000000000004e200000000000004e2000000000000000000000000049f2e7010000000000000000000000000000000000000000000061ea
4285
4286
4287 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x92):
4288 //possibly related to match opening or negotiation
4289 //actually, unlikely, we send an 0691 at open
4290 #ifdef RE_DEBUG
4291 printf("0x0692: ");
4292 for(i = 0; i < (int)size; i++)
4293 printf("%02x", msg[i]);
4294 printf("\n");
4295 #endif //RE_DEBUG
4296 break;
4297 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_FRIENDSBLOCKSLISTcxx . . $ `src/network/tygemprotocol.h:58:9`!):
4298 handleFriendsBlocksListcxx . . $ TygemConnection#handleFriendsBlocksList(e1e8b00c42c42532).(msg, size);
4299 break;
4300 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0x98):
4301 //maybe number of games/players?
4302 //definitely not, this is part of the login or something
4303 #ifdef RE_DEBUG
4304 printf("0x0698: ");
4305 for(i = 0; i < (int)size; i++)
4306 printf("%02x", msg[i]);
4307 printf("\n");
4308 #endif //RE_DEBUG
4309 break;
4310 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0xca):
4311 #ifdef RE_DEBUG
4312 printf("unknown new on login 13ca: ");
4313 for(i = 0; i < (int)size; i++)
4314 printf("%02x", msg[i]);
4315 printf("\n");
4316 #endif //RE_DEBUG
4317 break;
4318 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(TYGEM_PERSONALCHATcxx . . $ `src/network/tygemprotocol.h:59:9`!):
4319 handlePersonalChatcxx . . $ TygemConnection#handlePersonalChat(e1e8b00c42c42532).(msg, size);
4320 break;
4321 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0xb1): //a name during game? //maybe bets? probably bets FIXME
4322 //0001 0700 b0fc
4323 //c3b6 b5bf bdc3 b4eb 0000 0000 0000 0000 01
4324 //0000 0000 0000 0003
4325 //e86f 6c64 6572 6100 0000 0000 00
4326 #ifdef RE_DEBUG
4327 printf("0x06b1: ");
4328 for(i = 0; i < (int)size; i++)
4329 printf("%02x", msg[i]);
4330 printf("\n");
4331 #endif //RE_DEBUG
4332 break;
4333 case TPCcxx . . $ `src/network/tygemprotocol.h:61:9`!(0xaf): //login request response?
4334 #ifdef RE_DEBUG
4335 printf("0x06af: ");
4336 for(i = 0; i < (int)size; i++)
4337 printf("%02x", msg[i]);
4338 printf("\n");
4339 #endif //RE_DEBUG
4340 //is this right here?!?!? commenting out for now
4341 //sendInvitationSettings(false);
4342 break;
4343 default:
4344 #ifdef RE_DEBUG
4345 msg -= 4; //FIXME
4346 printf("Two bytestrange: %02x%02x: \n", msg[2], msg[3]);
4347 //#ifdef RE_DEBUG
4348 for(i = 2; i < (int)size + 4; i++)
4349 printf("%02x", msg[i]);
4350 printf("\n");
4351 #endif //RE_DEBUG
4352 break;
4353 }
4354 }
4355
4356 /* FIXME shouldn't this do something ?? */
4357 void TygemConnectioncxx . . $ TygemConnection#::handleConnectedcxx . . $ TygemConnection#handleConnected(e1e8b00c42c42532).(unsigned char * , unsigned int )
4358 {
4359 }
4360
4361 #ifdef RE_DEBUG
4362 //#define PLAYERLIST_DEBUG
4363 #endif //RE_DEBUG
4364 //0613
4365 void TygemConnectioncxx . . $ TygemConnection#::handlePlayerListcxx . . $ TygemConnection#handlePlayerList(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
4366 {
4367 unsigned char * p = msg;
4368 unsigned char name[14];
4369 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d)., rankcxx . . $ QString#QString(ced63f7c635d850d).;
4370 int players;
4371 bool no_rank = false;
4372 bool special_account;
4373 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
4374 PlayerListingcxx . . $ PlayerListing# * aPlayer;
4375
4376 players = (p[0] << 8) + p[1];
4377 p += 4;
4378 //printf("Players %d\n", players);
4379 if(!received_playerscxx . . $ TygemConnection#received_players. && players < 512)
4380 {
4381 setStatecxx . . $ NetworkConnection#setState(41e728cff2b23034).(Connectedcxx . . $ Connected.);
4382 received_playerscxx . . $ TygemConnection#received_players. = true;
4383 }
4384 //make sure these aren't one off, FIXME,
4385 //i.e., cutting off last record, also check on ORO
4386 while(p < (msg + size - 0x37) || (p < (msg + size - 19) && p[0] == 0x01))
4387 {
4388 #ifdef PLAYERLIST_DEBUG
4389 for(int j = 0; j < 0x38; j++)
4390 printf("%c", p[j]);
4391 printf("\n");
4392 for(int j = 0; j < 0x38; j++)
4393 printf("%02x", p[j]);
4394 printf("\n");
4395 #endif //PLAYERLIST_DEBUG
4396 if(p[0] == 0x01)
4397 {
4398 p += 4;
4399 strncpy((char *)name, (char *)p, 14);
4400 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4401 aPlayer = room->getPlayerListingByNotNicknamecxx . . $ Room#getPlayerListingByNotNickname(d3f53ac2de9f0b45).(encoded_name);
4402 /* This "isOngoingMatch" is called too often. FIXME */
4403 if((match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOngoingMatchcxx . . $ MatchNegotiationState#isOngoingMatch(c9857a73d68e59ba).() || match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentDisconnectedcxx . . $ MatchNegotiationState#opponentDisconnected(c9857a73d68e59ba).()) &&
4404 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyPlayercxx . . $ MatchNegotiationState#verifyPlayer(20057ff4c3da74fc).(aPlayer))
4405 {
4406 /* basically, we can't disconnect this player because we need their info to
4407 * send stuff */
4408
4409 //FIXME nick or username? probably nick but is that ascii or normal?
4410 //don't delete the playerlisting if we're still in a game with them
4411 p += 16;
4412 continue;
4413 }
4414 aPlayer->onlinecxx . . $ PlayerListing#online. = false;
4415 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! playerListingReceivedcxx . . $ NetworkConnection#playerListingReceived(122195e397f39e1b).(aPlayer);
4416
4417 p += 14;
4418 #ifdef PLAYERLIST_DEBUG
4419 printf("Player %s disconnected, last bytes: %02x%02x\n", encoded_name.toLatin1().constData(), p[0], p[1]);
4420 #endif //PLAYERLIST_DEBUG
4421 p += 2;
4422 continue;
4423 }
4424 p += 2;
4425 p++;
4426 #ifdef FIXME
4427 /* We get disconnects for at least some of these so this isn't ignorable like this. */
4428 if(!p[0])
4429 {
4430 //often [Gxxxx] player, I assume guest?
4431 //0002 0000 5b47 3236 3734 5d32 3000 0000
4432 //0000 0000 5b47 3236 3734 5d32 3000 0000
4433 //0000 0100 0000 0000 0000 0000 0000 0000
4434 //0000 45ab 0001 004b
4435 #ifdef PLAYERLIST_DEBUG
4436 printf("Guest\n");
4437 #endif //PLAYERLIST_DEBUG
4438 p += 0x35;
4439 continue;
4440 }
4441 /* I think p[0] is the flag icon, but it can be different
4442 * pictures too so... */
4443 #endif //FIXME
4444 p++;
4445 if(p[0] == '[' && p[1] == 'G' && (p[2] == 'S' || p[2] == 'M'))
4446 special_account = true;
4447 else
4448 special_account = false;
4449 strncpy((char *)name, (char *)p, 14);
4450 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4451 if(p[14])
4452 printf("FIXME player 14 char:\n\n");
4453 p += 15;
4454 //rank byte
4455 if(p[0] < 0x12)
4456 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
4457 else if(p[0] > 0x1a)
4458 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
4459 else
4460 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
4461 p++;
4462 strncpy((char *)name, (char *)p, 11);
4463 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4464 //another name
4465 aPlayer = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
4466 aPlayer->notnicknamecxx . . $ PlayerListing#notnickname. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_name;
4467 aPlayer->namecxx . . $ PlayerListing#name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_name2;
4468 aPlayer->rankcxx . . $ PlayerListing#rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rank;
4469 aPlayer->hiddencxx . . $ PlayerListing#hidden. = special_account;
4470
4471 p += 11;
4472 aPlayer->country_idcxx . . $ PlayerListing#country_id. = p[0];
4473 p++;
4474 p += 4;
4475 // are these unsigned longs or shorts ?!?!?
4476 p += 2;
4477 aPlayer->winscxx . . $ PlayerListing#wins. = (p[0] << 8) + p[1];
4478 p += 2;
4479 p += 2;
4480 aPlayer->lossescxx . . $ PlayerListing#losses. = (p[0] << 8) + p[1];
4481 p += 2; //w/l
4482 p++;
4483 if(p[0])
4484 {
4485 //FIXME
4486 printf("player uses username, not nickname?!?\n");
4487 /* If this occurs often, ... well its one thing to store
4488 * the player on the username, but if it affects the game
4489 * listing displays, we have to check the byte on the player...
4490 * meaning a separate variable. I'll see if it happens
4491 * a lot or if its an issue */
4492 }
4493 p++;
4494 p += 2;
4495 if(p[0] == 0xff && p[1] == 0xff) //normally 0000 ----, then ffff ff40
4496 no_rank = true;
4497 p += 2;
4498
4499 if(no_rank)
4500 {
4501 aPlayer->rank_scorecxx . . $ PlayerListing#rank_score. = 0;
4502 no_rank = false;
4503 }
4504 else
4505 aPlayer->rank_scorecxx . . $ PlayerListing#rank_score. = (p[0] << 8) + p[1];
4506 /* player rank scores MUST Be normalized to be filtered in view properly !! */
4507 //aPlayer->rank_score = rankToScore(aPlayer->rank);
4508 p += 2;
4509 //p[0] probably means keyi, can contact with game
4510 if(p[0])
4511 aPlayer->infocxx . . $ PlayerListing#info. =cxx . . $ QString#`operator=`(d02845eef0c33901). "X";
4512 else
4513 aPlayer->infocxx . . $ PlayerListing#info. =cxx . . $ QString#`operator=`(d02845eef0c33901). "O";
4514 //p[1]
4515 //00
4516 //01 might mean observing
4517 //02 probably means in a game
4518 /* I've seen 10, then 11 when we enter room for game and then 12 when we've accepted and game is in progress */
4519 //aPlayer->country = QString::number(p[0], 16) + QString::number(p[1], 16);
4520 p += 2;
4521 p += 2;
4522 #ifdef PLAYERLIST_DEBUG
4523 /* FIXME there's some object code playerlist structure dependency
4524 * such that if we alter the playerlisting structure, it can
4525 * screw up the lists or something until we make clean and make again */
4526 printf("%s %s %d/%d\n", name, rank.toLatin1().constData(), aPlayer->wins, aPlayer->losses);
4527 #endif //PLAYERLIST_DEBUG
4528 emitcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:97:10`! playerListingReceivedcxx . . $ NetworkConnection#playerListingReceived(122195e397f39e1b).(aPlayer);
4529 }
4530
4531 if(p != (msg + size))
4532 {
4533 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("handlePlayerListing packet strange size %d", (msg + size) - p);
4534 }
4535
4536 if(received_gamescxx . . $ TygemConnection#received_games. && match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->canEnterRematchAdjournedcxx . . $ MatchNegotiationState#canEnterRematchAdjourned(c9857a73d68e59ba).())
4537 promptResumeMatchcxx . . $ TygemConnection#promptResumeMatch(49f6e7a06ebc5aa8).();
4538 }
4539
4540 QStringcxx . . $ QString# TygemConnectioncxx . . $ TygemConnection#::rating_pointsToRankcxx . . $ TygemConnection#rating_pointsToRank(538777a873a4ab5d).(unsigned int rp)
4541 {
4542 int rem = rp % 1000;
4543 rp -= rem;
4544 rp /= 1000;
4545 if(rp < 26)
4546 {
4547 rp = 26 - rp;
4548 return QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(rp) +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#QString(85c52e162fed56f9).("k");
4549 }
4550 else
4551 {
4552 rp -= 25;
4553 return QStringcxx . . $ QString#::numbercxx . . $ QString#number(da83c6b4fd8c0e98).(rp) +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#QString(85c52e162fed56f9).("d");
4554 }
4555 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("?");
4556 }
4557
4558 /* FIXME, I really hate using regular expressions in code that's
4559 * called this often, but okay for now. Also, its basically the
4560 * same everywhere, don't know why I thought it would be different
4561 * per protocol.
4562
4563 * No, there is a problem, the rating points are maybe different and also
4564 * listed in view on tygem, so they have to be sorted differently. i.e.
4565 * this should actually return the real tygem rank scores instead of
4566 * changing the rating_points or rank score, above to this normalized
4567 * thing. FIXME*/
4568 unsigned int TygemConnectioncxx . . $ TygemConnection#::rankToScorecxx . . $ TygemConnection#rankToScore(9d92bb507a34628c).(QStringcxx . . $ QString# rank)
4569 {
4570 QStringcxx . . $ QString# buffer = rankcxx . . $ QString#QString(132dd6869045752b).;
4571 //buffer.replace(QRegExp("[pdk+?\\*\\s]"), "");
4572 buffer.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("[pdk]"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).);
4573 int ordinal = buffer.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
4574 unsigned int rp;
4575
4576 /* This is for ranking purposes, these are all kind of off and
4577 * tygem doesn't equate rank to points directly I don't think.
4578 * might be weighted by win/loss ratio or something.
4579 * at the very least, its logarithmic */
4580 /* right now, the score filter goes up to 5d, no more FIXME */
4581 if(rank.containscxx . . $ QString#contains(8cce4688c16f48f3).("k"cxx . . $ QString#QString(85c52e162fed56f9).))
4582 rp = (19 - ordinal) * 1000;
4583 else if(rank.containscxx . . $ QString#contains(8cce4688c16f48f3).("d"cxx . . $ QString#QString(85c52e162fed56f9).))
4584 rp = 18000 + (ordinal * 1000);
4585 else if(rank.containscxx . . $ QString#contains(8cce4688c16f48f3).("p"cxx . . $ QString#QString(85c52e162fed56f9).))
4586 rp = 28000 + (ordinal * 1000);
4587 else
4588 return 0;
4589
4590 return rp;
4591 }
4592
4593 //FIXME this was oro code, but tygem has numbers for like 3 countries at least
4594 QStringcxx . . $ QString# TygemConnectioncxx . . $ TygemConnection#::getCountryFromCodecxx . . $ TygemConnection#getCountryFromCode(e76153c3c184c917).(unsigned char code)
4595 {
4596 code &= 0x0f;
4597 switch(code)
4598 {
4599 case 1:
4600 return "KOREA"cxx . . $ QString#QString(85c52e162fed56f9).;
4601 break;
4602 case 2:
4603 return "CHINA"cxx . . $ QString#QString(85c52e162fed56f9).;
4604 break;
4605 case 3:
4606 return "JAPAN"cxx . . $ QString#QString(85c52e162fed56f9).;
4607 break;
4608 case 4:
4609 return "INTL"cxx . . $ QString#QString(85c52e162fed56f9).;
4610 break;
4611 case 5:
4612 return "THAILAND"cxx . . $ QString#QString(85c52e162fed56f9).;
4613 break;
4614 case 6:
4615 //that blue flag...
4616 return "UN?"cxx . . $ QString#QString(85c52e162fed56f9).;
4617 break;
4618 case 7:
4619 return "USA"cxx . . $ QString#QString(85c52e162fed56f9).;
4620 break;
4621 case 8:
4622 return "HONGKONG"cxx . . $ QString#QString(85c52e162fed56f9).;
4623 break;
4624 case 9:
4625 return "SINGAPORE"cxx . . $ QString#QString(85c52e162fed56f9).;
4626 break;
4627 case 0xa:
4628 return "CANADA"cxx . . $ QString#QString(85c52e162fed56f9).;
4629 break;
4630 case 0xb:
4631 return "GERMANY"cxx . . $ QString#QString(85c52e162fed56f9).;
4632 break;
4633 case 0xc:
4634 return "FRANCE"cxx . . $ QString#QString(85c52e162fed56f9).;
4635 break;
4636 case 0xd:
4637 return "AUSTRAILIA"cxx . . $ QString#QString(85c52e162fed56f9).;
4638 break;
4639 case 0xe:
4640 return "RUSSIA"cxx . . $ QString#QString(85c52e162fed56f9).;
4641 break;
4642 case 0xf:
4643 return "UKRAINE"cxx . . $ QString#QString(85c52e162fed56f9).;
4644 break;
4645 }
4646 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("-");
4647 }
4648
4649 /* FIXME I think this p++, p += n, stuff is a really
4650 * bad idea now. I need to get that other protocol
4651 * idea working or just use the numbers somehow. It would
4652 * be better to have msg[n + offset + offset] then what we're
4653 * doing now */
4654 /* FIXME, we may be getting this twice, meaning we may not have to request it
4655 * or possibly we may not have to request it for eweiqi or something. */
4656 void TygemConnectioncxx . . $ TygemConnection#::handleFriendsBlocksListcxx . . $ TygemConnection#handleFriendsBlocksList(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
4657 {
4658 //0018 0696
4659 //0001 2066 696e 7472 7573 696f 6e00 6672 6965 6e00
4660 unsigned char name[15];
4661 unsigned int i;
4662
4663 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d).;
4664 name[14] = 0x00;
4665 int records = (msg[0] << 8) + msg[1];
4666 if((records * 16) + 4 != (int)size)
4667 {
4668 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("FriendsBlock message of strange size: %d", size);
4669 //return;
4670 }
4671 #ifdef RE_DEBUG
4672 printf("FriendsBlocksList: %d\n", records);
4673 for(i = 0; i < size; i++)
4674 printf("%02x", msg[i]);
4675 printf("\n");
4676 #endif //RE_DEBUG
4677 //i = 2; //2066
4678 i = 4;
4679 while(records--)
4680 {
4681 strncpy((char *)name, (char *)&(msg[i]), 14);
4682 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4683 i += 15;
4684 /* FIXME somehow, its possible for the same name to be on the official
4685 * server list more than once */
4686 if(msg[i] == 0x00)
4687 friendedListcxx . . $ NetworkConnection#friendedList..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(new FriendWatchListingcxx . . $ FriendWatchListing#FriendWatchListing(4e51b35ce1bea96b).(encoded_namecxx . . $ QString#QString(132dd6869045752b)., friendwatch_notify_defaultcxx . . $ NetworkConnection#friendwatch_notify_default.));
4688 else if(msg[i] == 0xff)
4689 blockedListcxx . . $ NetworkConnection#blockedList..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(new FriendWatchListingcxx . . $ FriendWatchListing#FriendWatchListing(4e51b35ce1bea96b).(encoded_namecxx . . $ QString#QString(132dd6869045752b)., friendwatch_notify_defaultcxx . . $ NetworkConnection#friendwatch_notify_default.));
4690 else
4691 printf("unknown indicator: %02x\n", msg[i]);
4692 #ifdef RE_DEBUG
4693 printf("%02x %s %s\n", msg[i], encoded_name.toLatin1().constData(), name);
4694 #endif //RE_DEBUG
4695 i++;
4696 }
4697 }
4698
4699 /* These are the number of players on the other servers
4700 * FIXME
4701 * seem they're sent out maybe every 20 seconds*/
4702 //0x0654:
4703 void TygemConnectioncxx . . $ TygemConnection#::handleServerPlayerCountscxx . . $ TygemConnection#handleServerPlayerCounts(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
4704 {
4705 unsigned char * p = msg;
4706 p += 2;
4707 //int records = (p[0] << 8) + p[1];
4708 p += 2;
4709 #ifdef RE_DEBUG
4710 //printf("0654 %d unknown records: \n", records);
4711 #endif //RE_DEBUG
4712 while(p < (msg + size - 3))
4713 {
4714 #ifdef RE_DEBUG
4715 // printf("%02x%02x for %d(%02x%02x) %d\n",
4716 // p[0], p[1], (p[2] << 8) + p[3], p[2], p[3],
4717 // (p[6] << 8) + p[7]);
4718 #endif //RE_DEBUG
4719 p += 8;
4720 }
4721 //0100 000d
4722 //79bd 0913 0000 0b3f
4723 //79bd 092d 0000 0092
4724 //79bd 0914 0000 0909
4725 //79bd 0912 0000 001a
4726 //79bd 094b 0000 04b5
4727 //79bd 092c 0000 01ee
4728 //79bd 097d 0000 00c9
4729 //79bd 092f 0000 031a
4730 //79bd 094c 0000 0302
4731 //79bd 0915 0000 0000
4732 //79bd 0911 0000 0729
4733 //79bd 092e 0000 005c
4734 //79bd 0915 0000 0004
4735 }
4736
4737 /* We might FIXME replace the return on this with a QString
4738 * when we alter the list view to handle different columns.
4739 * But for now, moves is pretty accurate for the field */
4740 int TygemConnectioncxx . . $ TygemConnection#::getPhasecxx . . $ TygemConnection#getPhase(b27dbea426b7b93).(unsigned char byte)
4741 {
4742 /* Note that this is unused right now */
4743 switch(byte)
4744 {
4745 case 0:
4746 return 0;
4747 //open
4748 break;
4749 case 1:
4750 return 30;
4751 //early
4752 break;
4753 case 2:
4754 return 50;
4755 //middle
4756 break;
4757 case 3:
4758 return 130;
4759 //end
4760 break;
4761 case 6: //adjourned due to drop, I think
4762 case 11:
4763 //looks like wished opponent
4764 default:
4765 return -1;
4766 break;
4767 }
4768 }
4769
4770 //this was oro but certainly there's tygem flags we don't get
4771 QStringcxx . . $ QString# TygemConnectioncxx . . $ TygemConnection#::getRoomTagcxx . . $ TygemConnection#getRoomTag(e76153c3c184c917).(unsigned char byte)
4772 {
4773 switch(byte)
4774 {
4775 case 0x1f:
4776 case 0x3d:
4777 //normal and broadcast in progress
4778 return QStringcxx . . $ QString#QString(ced63f7c635d850d).();
4779 break;
4780 case 0x04:
4781 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** chat 04");
4782 break;
4783 case 0x1a:
4784 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** chat 1a");
4785 break;
4786 case 0x70:
4787 //likely chat 0 locked?
4788 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** chat 70");
4789 break;
4790 case 0x3c:
4791 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** review 3c");
4792 break;
4793 case 0x19:
4794 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** chat 19");
4795 break;
4796 case 0x1c:
4797 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** quit? 19");
4798 break;
4799 case 0x0b:
4800 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** wished 0b");
4801 break;
4802 case 0x0f:
4803 return QStringcxx . . $ QString#QString(85c52e162fed56f9).("** one color 0f");
4804 break;
4805 default:
4806 return (QStringcxx . . $ QString#QString(85c52e162fed56f9).("** ") +cxx . . $ operator+(fab9b4f80031f353). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(byte, 16));
4807 break;
4808 }
4809 }
4810
4811 #ifdef RE_DEBUG
4812 //#define GAMESLIST_DEBUG
4813 #endif //RE_DEBUG
4814 //0612
4815 void TygemConnectioncxx . . $ TygemConnection#::handleGamesListcxx . . $ TygemConnection#handleGamesList(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
4816 {
4817 unsigned char * p = msg;
4818 unsigned char * game_record;
4819 unsigned int id;
4820 unsigned int name_length;
4821 unsigned char name[15];
4822 unsigned char flags;
4823 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
4824 QStringcxx . . $ QString# encoded_nameAcxx . . $ QString#QString(ced63f7c635d850d)., encoded_nameBcxx . . $ QString#QString(ced63f7c635d850d)., rankAcxx . . $ QString#QString(ced63f7c635d850d)., rankBcxx . . $ QString#QString(ced63f7c635d850d).;
4825 QStringcxx . . $ QString# encoded_nameA2cxx . . $ QString#QString(ced63f7c635d850d)., encoded_nameB2cxx . . $ QString#QString(ced63f7c635d850d).;
4826 GameListingcxx . . $ GameListing# * aGameListing;
4827
4828 name[14] = 0x00;
4829 /*printf("Gamelist message:\n");
4830 for(i = 0; i < size; i++)
4831 printf("%02x", msg[i]);
4832 printf("\n");*/
4833 //unsigned int number_of_games = (p[0] << 8) + p[1];
4834 p += 4;
4835 while(p < (msg + size - 0x48) || (p < (msg + size - 3) && p[2] == 0x01))
4836 {
4837 game_record = p;
4838 id = (game_record[0] << 8) + game_record[1];
4839 #ifdef GAMESLIST_DEBUG
4840 printf("Id: %d:\n", id);
4841 #endif //GAMESLIST_DEBUG
4842 aGameListing = room->getGameListingcxx . . $ Room#getGameListing(d402167d8f57cf00).(id);
4843 aGameListing->runningcxx . . $ GameListing#running. = true;
4844 aGameListing->FRcxx . . $ GameListing#FR. =cxx . . $ QString#`operator=`(d02845eef0c33901). "";
4845 if(game_record[2] == 0x01)
4846 {
4847
4848 #ifdef GAMESLIST_DEBUG
4849 printf("Id: %d:\n", id);
4850 printf("is ended!!!\n");
4851 for(unsigned int i = 0; i < 4; i++)
4852 printf("%c", p[i]);
4853 printf("\n");
4854 #endif //GAMESLIST_DEBUG
4855
4856 p += 4;
4857 aGameListing->runningcxx . . $ GameListing#running. = false;
4858 room->recvGameListingcxx . . $ Room#recvGameListing(9a447f3b9a8a5041).(aGameListing);
4859 continue;
4860 }
4861 if(game_record[3] & 0x01)
4862 {
4863 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "L";
4864 aGameListing->isLockedcxx . . $ GameListing#isLocked. = true;
4865 }
4866 //p[4] == 0x02 is some other kind of record
4867 #ifdef GAMESLIST_DEBUG
4868 for(unsigned int i = 0; i < 0x4c; i++)
4869 {
4870 printf("%c", p[i]);
4871 }
4872 printf("\n");
4873 for(unsigned int i = 0; i < 0x4c; i++)
4874 {
4875 printf("%02x", p[i]);
4876 }
4877 printf("\n");
4878 #endif //GAMESLIST_DEBUG
4879 p += 2; //past id
4880 //0000 0001 0002 0000 ff00 7978 7973 7a00
4881 p++;
4882 //if(p[0] == 0x00)
4883 //p += 2;
4884 p++;
4885
4886 p++;
4887 //impacts time
4888 //there's also 0x30, I think 0x50, etc.. issues here
4889 aGameListing->white_first_flagcxx . . $ GameListing#white_first_flag. = p[0] & 0x01; //game_record[5]
4890 //aGameListing->FR += QString::number(p[0], 16) + " ";
4891 /* 40 looks like a lit 2 computer screens, 50 like 2 dark computers */
4892 /* 30 is just betting and over*/
4893 /* Thinking 40 bit is broadcast and 20 bit is betting */
4894 p++;
4895 aGameListing->observerscxx . . $ GameListing#observers. = (game_record[6] << 8) + game_record[7];
4896 //We have an issue here I think FIXME with observer numbers
4897 p += 2;
4898 //int some_number = (p[0] << 8) + p[1]; // This number seems to be either 0 or -1
4899 p += 2;
4900 p++;
4901 //aGameListing->FR = "";
4902 //p += 2;
4903 flags = p[0];
4904
4905 //FIXME we need a flag parse function
4906 //but note that we might want a variable return value in the sense
4907 //that maybe we want to get the flags, maybe we want to set the name of the black
4908 //player to ** review ** or something...
4909 if(flags & 0x80)
4910 {
4911 // Betting
4912 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "B";
4913 }
4914 if(flags & 0x20)
4915 {
4916 //probably broadcast, maybe as well as betting
4917 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "R";
4918 }
4919 //ff00
4920 p++;
4921
4922 //name 1
4923 strncpy((char *)name, (char *)p, 14);
4924 encoded_nameA =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4925 p += 15;
4926 //rank byte
4927 if(p[0] < 0x12)
4928 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
4929 else if(p[0] > 0x1a)
4930 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
4931 else
4932 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
4933 p++;
4934 strncpy((char *)name, (char *)p, 11);
4935 #ifdef GAMESLIST_DEBUG
4936 printf("%s vs.", name);
4937 #endif //GAMESLIST_DEBUG
4938 encoded_nameA2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4939 p += 12;
4940 if(p[0] == 0x00)
4941 {
4942 p += 16;
4943 encoded_nameB =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(ced63f7c635d850d).();
4944 encoded_nameB2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(ced63f7c635d850d).();
4945 rankB =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(ced63f7c635d850d).();
4946 }
4947 else
4948 {
4949 strncpy((char *)name, (char *)p, 14);
4950 encoded_nameB =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4951 p += 15;
4952 if(p[0] < 0x12)
4953 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
4954 else if(p[0] > 0x1a)
4955 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
4956 else
4957 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
4958 p++;
4959 strncpy((char *)name, (char *)p, 11); //chinese
4960 #ifdef GAMESLIST_DEBUG
4961 printf(" %s\n", name);
4962 #endif //GAMESLIST_DEBUG
4963 encoded_nameB2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
4964 }
4965 p += 12;
4966
4967 p++;
4968 //this p[0] should be game status
4969 //aGameListing->FR += QString::number(p[0], 16);
4970 switch(game_record[73])
4971 {
4972 case 0:
4973 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "?"; //looking
4974 break;
4975 case 1:
4976 aGameListing->movescxx . . $ GameListing#moves. = 0;
4977 break;
4978 case 2:
4979 aGameListing->movescxx . . $ GameListing#moves. = 50;
4980 break;
4981 case 3:
4982 aGameListing->movescxx . . $ GameListing#moves. = 120;
4983 break;
4984 case 4:
4985 aGameListing->movescxx . . $ GameListing#moves. = (unsigned)-1; //over
4986 break;
4987 case 5:
4988 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "V"; //review
4989 break;
4990 case 6:
4991 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "A"; //adjourned due to drop?
4992 break;
4993 case 11:
4994 aGameListing->FRcxx . . $ GameListing#FR. +=cxx . . $ QString#`operator+=`(d02845eef0c33901). "W"; //wished opponent?
4995 break;
4996 }
4997 p++;
4998 p++;
4999 //name_length = p[0];
5000 p++;
5001 //p += name_length;
5002 //2 bytes here, 0001 or 0004 or 0006 or 0003, etc..
5003 p += 2;
5004 name_length = (p[0] << 8) + p[1];
5005 //if(different_game_record)
5006 //apparently has nothing to do with earlier,
5007 //might be another flag FIXME
5008 p += 2;
5009 if(1)
5010 {
5011 if(name_length)
5012 {
5013 char * comment = new char[name_length + 1];
5014 comment[name_length] = '\0';
5015 strncpy(comment, (char *)p, name_length); //FIXME next line strlen
5016 aGameListing->commentcxx . . $ GameListing#comment. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).(comment, strlen(comment));
5017 delete comment;
5018 }
5019 p += name_length;
5020 }
5021
5022 /* Don't remember why this can't get the info from the players? FIXME*/
5023 if(aGameListing->white_first_flagcxx . . $ GameListing#white_first_flag.)
5024 {
5025 aGameListing->_white_namecxx . . $ GameListing#_white_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameA2;
5026 aGameListing->_white_rankcxx . . $ GameListing#_white_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankA;
5027 aGameListing->_white_rank_scorecxx . . $ GameListing#_white_rank_score. = rankToScorecxx . . $ TygemConnection#rankToScore(9d92bb507a34628c).(rankAcxx . . $ QString#QString(132dd6869045752b).);
5028 aGameListing->_black_namecxx . . $ GameListing#_black_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameB2;
5029 aGameListing->_black_rankcxx . . $ GameListing#_black_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
5030 aGameListing->_black_rank_scorecxx . . $ GameListing#_black_rank_score. = rankToScorecxx . . $ TygemConnection#rankToScore(9d92bb507a34628c).(rankBcxx . . $ QString#QString(132dd6869045752b).);
5031 }
5032 else
5033 {
5034 aGameListing->_white_namecxx . . $ GameListing#_white_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameB2;
5035 aGameListing->_white_rankcxx . . $ GameListing#_white_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
5036 aGameListing->_white_rank_scorecxx . . $ GameListing#_white_rank_score. = rankToScorecxx . . $ TygemConnection#rankToScore(9d92bb507a34628c).(rankBcxx . . $ QString#QString(132dd6869045752b).);
5037 aGameListing->_black_namecxx . . $ GameListing#_black_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameA2;
5038 aGameListing->_black_rankcxx . . $ GameListing#_black_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankA;
5039 aGameListing->_black_rank_scorecxx . . $ GameListing#_black_rank_score. = rankToScorecxx . . $ TygemConnection#rankToScore(9d92bb507a34628c).(rankAcxx . . $ QString#QString(132dd6869045752b).);
5040 }
5041 room->recvGameListingcxx . . $ Room#recvGameListing(9a447f3b9a8a5041).(aGameListing);
5042 if(initial_connectcxx . . $ TygemConnection#initial_connect. && match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->newMatchAllowedcxx . . $ MatchNegotiationState#newMatchAllowed(c9857a73d68e59ba).())
5043 {
5044 if(encoded_nameA2 ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
5045 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->setupRematchAdjournedcxx . . $ MatchNegotiationState#setupRematchAdjourned(6f89333d9b9322ae).(id, encoded_nameB2cxx . . $ QString#QString(132dd6869045752b).);
5046 else if(encoded_nameB2 ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
5047 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->setupRematchAdjournedcxx . . $ MatchNegotiationState#setupRematchAdjourned(6f89333d9b9322ae).(id, encoded_nameA2cxx . . $ QString#QString(132dd6869045752b).);
5048 }
5049 }
5050 initial_connectcxx . . $ TygemConnection#initial_connect. = false;
5051 received_gamescxx . . $ TygemConnection#received_games. = true;
5052 if(received_playerscxx . . $ TygemConnection#received_players. && match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->canEnterRematchAdjournedcxx . . $ MatchNegotiationState#canEnterRematchAdjourned(c9857a73d68e59ba).())
5053 promptResumeMatchcxx . . $ TygemConnection#promptResumeMatch(49f6e7a06ebc5aa8).();
5054 }
5055
5056 //shouldn't this be somewhere more standard? FIXME
5057 void TygemConnectioncxx . . $ TygemConnection#::promptResumeMatchcxx . . $ TygemConnection#promptResumeMatch(49f6e7a06ebc5aa8).(void)
5058 {
5059 unsigned short game_number = match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getGameIdcxx . . $ MatchNegotiationState#getGameId(32a7769d58713265).();
5060 GameListingcxx . . $ GameListing# * gameListing = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getGameListingcxx . . $ Room#getGameListing(d402167d8f57cf00).(game_number);
5061
5062 QStringcxx . . $ QString# opp_name = (cxx . . $ QString#QString(132dd6869045752b).gameListing->white_namecxx . . $ GameListing#white_name(a2fb7a6ce195d51).() ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? gameListing->black_namecxx . . $ GameListing#black_name(a2fb7a6ce195d51).() : gameListing->white_namecxx . . $ GameListing#white_name(a2fb7a6ce195d51).());
5063 if (QMessageBoxcxx . . $ QMessageBox#::questioncxx . . $ QMessageBox#question(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Resume match?"),
5064 QStringcxx . . $ QString#(trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Resume match in progress with %1?\n").argcxx . . $ QString#arg(bc823072288cbbb5).(opp_name)))
5065 == QMessageBoxcxx . . $ QMessageBox#::Yescxx . . $ QMessageBox#Yes.)
5066 {
5067 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Trying to rejoin %d", game_number);
5068 sendJoincxx . . $ TygemConnection#sendJoin(ed53e3bbd3fa2f69).(game_number);
5069 sendObserversRequestcxx . . $ TygemConnection#sendObserversRequest(ed53e3bbd3fa2f69).(game_number);
5070 sendResumecxx . . $ TygemConnection#sendResume(ed53e3bbd3fa2f69).(game_number);
5071 }
5072 else
5073 {
5074 //we have to do something else here, FIXME either, nothing, no choice,
5075 //or we need to change the match negotiation state or send a resign or... nothing is
5076 //probably best.... i.e., no "Yes" but informational
5077 //check official client, might be able to resign
5078 /* Actually, hitting "No" is a-okay in the official client and it does nothing,
5079 * opponent still has to wait out the five minutes. */
5080 }
5081 }
5082
5083 void TygemConnectioncxx . . $ TygemConnection#::handleRequestKeepAlivecxx . . $ TygemConnection#handleRequestKeepAlive(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5084 {
5085 if(size != 4)
5086 {
5087 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("setup keep alive of size %d", size);
5088 }
5089 #ifdef RE_DEBUG
5090 //printf("Keepalive IV %8x\n", *(uint32_t *)msg);
5091 #endif //RE_DEBUG
5092 uint32_tcxx . . $ uint32_t# keepaliveIV = encodeKeepAliveIVcxx . . $ TygemConnection#encodeKeepAliveIV(2141b656ce2cc063).(*(uint32_tcxx . . $ uint32_t# *)msg);
5093 #ifdef RE_DEBUG
5094 //printf("Keepalive IV encoded %8x\n", keepaliveIV);
5095 #endif //RE_DEBUG
5096 sendServerKeepAlivecxx . . $ TygemConnection#sendServerKeepAlive(cb2f890c2fdad230).(keepaliveIV);
5097 }
5098
5099 void TygemConnectioncxx . . $ TygemConnection#::handleServerAnnouncementcxx . . $ TygemConnection#handleServerAnnouncement(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5100 {
5101 unsigned char * p = msg;
5102
5103 #ifdef RE_DEBUG
5104 printf("0xf659: ");
5105 for(unsigned int i = 0; i < size; i++)
5106 printf("%02x", msg[i]);
5107 printf("\n");
5108 #endif //RE_DEBUG
5109 p += 2;
5110
5111 /* FIXME, likely first two bytes are something else */
5112 QStringcxx . . $ QString# ucxx . . $ QString#QString(ced63f7c635d850d).;
5113
5114 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)p, size - 2);
5115 //u = codec->toUnicode(b, size - 4);
5116 if(console_dispatchcxx . . $ NetworkConnection#console_dispatch.)
5117 console_dispatchcxx . . $ NetworkConnection#console_dispatch.->recvTextcxx . . $ ConsoleDispatch#recvText(7df51288a9ebd664).("*** " +cxx . . $ operator+(c75c3ae4eb9af1a8). u);
5118 }
5119
5120 void TygemConnectioncxx . . $ TygemConnection#::handleServerRoomChatcxx . . $ TygemConnection#handleServerRoomChat(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5121 {
5122 unsigned char * p = msg;
5123 unsigned char * text = new unsigned char[size - 0x23];
5124 unsigned char name[15];
5125 name[14] = 0x00;
5126 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d)., rankcxx . . $ QString#QString(ced63f7c635d850d).;
5127 #ifdef RE_DEBUG
5128 printf("serverchat: \n");
5129 for(unsigned int i = 0; i < size; i++)
5130 printf("%02x", msg[i]);
5131 printf("\n");
5132 #endif //RE_DEBUG
5133 p += 4;
5134 strncpy((char *)name, (char *)&(msg[4]), 14);
5135 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5136 p += 15;
5137 if(msg[15] < 0x12)
5138 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[15]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5139 else if(msg[15] > 0x1a)
5140 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5141 else
5142 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5143 p++;
5144 strncpy((char *)name, (char *)&(msg[16]), 11);
5145 //we lost first three letters here last I checked
5146 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5147 p += 0x10;
5148 //don't know what that one byte is, but its not part of text
5149 p++;
5150 strncpy((char *)text, (char *)&(msg[37]), size - 0x24);
5151
5152 //Room * room = getDefaultRoom(); //3
5153 //PlayerListing * player = room->getPlayerListing(player_id);
5154 //if(player)
5155 //{
5156 #ifdef RE_DEBUG
5157 printf("%s says: \n", name);
5158 for(int i = 0; i < (int)size - 0x24; i++)
5159 printf("%02x", text[i]);
5160 printf("\n");
5161 #endif //RE_DEBUG
5162 QStringcxx . . $ QString# ucxx . . $ QString#QString(ced63f7c635d850d).;
5163
5164 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)text, strlen((char *)text));
5165 //u = codec->toUnicode(b, size - 4);
5166 if(console_dispatchcxx . . $ NetworkConnection#console_dispatch.)
5167 console_dispatchcxx . . $ NetworkConnection#console_dispatch.->recvTextcxx . . $ ConsoleDispatch#recvText(7df51288a9ebd664).(encoded_name2 +cxx . . $ operator+(501d4570f8fec4c9). '[' +cxx . . $ operator+(fab9b4f80031f353). rank +cxx . . $ operator+(3d22f08efddf8107). "]: " +cxx . . $ operator+(fab9b4f80031f353). u);
5168 /*}
5169 else
5170 printf("unknown player says something");*/
5171 delete[] text;
5172 }
5173
5174 //has garbled stuff on the end, maybe due to unicode, still FIXME
5175 //0661
5176 void TygemConnectioncxx . . $ TygemConnection#::handleGameChatcxx . . $ TygemConnection#handleGameChat(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5177 {
5178 unsigned char * p = msg;
5179 unsigned char * text;
5180 unsigned char name[15];
5181 name[14] = 0x00;
5182 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
5183 int room_number;
5184 unsigned int size_of_message;
5185 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
5186 QStringcxx . . $ QString# rankcxx . . $ QString#QString(ced63f7c635d850d).;
5187 #ifdef RE_DEBUG
5188 int i;
5189
5190 printf("** game chat size: %d: ", size);
5191 for(i = 0; i < (int)size; i++)
5192 printf("%02x", p[i]);
5193 printf("\n");
5194 #endif //RE_DEBUG
5195 //Room * room = getDefaultRoom();
5196 room_number = (p[0] << 8) + p[1];
5197 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(room_number);
5198 if(!boarddispatch)
5199 {
5200 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for %d for chat msg", room_number);
5201 return;
5202 }
5203 p += 0x14;
5204 strncpy((char *)name, (char *)p, 14);
5205 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5206 p += 15;
5207 if(p[0] < 0x12)
5208 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5209 else if(p[0] > 0x1a)
5210 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5211 else
5212 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5213 p++;
5214 strncpy((char *)name, (char *)p, 11);
5215 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5216 if(encoded_name2 ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
5217 {
5218 //block as echo
5219 //but then our rank doesn't appear ... FIXME check with oro, igs
5220 return;
5221 }
5222 p += 0x1c;
5223 size_of_message = p[0];
5224 if(size_of_message > size - 66)
5225 {
5226 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad in game chat message size");
5227 return;
5228 }
5229
5230 p += 4;
5231 //again, init number not part of text
5232 p++;
5233 text = new unsigned char[size_of_message + 1];
5234 strncpy((char *)text, (char *)p, size_of_message);
5235 text[size_of_message] = 0x00;
5236 //PlayerListing * player = room->getPlayerListing(player_id);
5237 //if(player)
5238 //{
5239
5240 QStringcxx . . $ QString# ucxx . . $ QString#QString(ced63f7c635d850d).;
5241
5242 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)text, strlen((char *)text));
5243 //u = codec->toUnicode(b, size - 4);
5244 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(encoded_name2 +cxx . . $ operator+(3d22f08efddf8107). "[" +cxx . . $ operator+(fab9b4f80031f353). rank +cxx . . $ operator+(3d22f08efddf8107). "]", ucxx . . $ QString#QString(132dd6869045752b).);
5245 /*}
5246 else
5247 printf("unknown player says something");*/
5248 delete[] text;
5249 }
5250
5251 void TygemConnectioncxx . . $ TygemConnection#::handleOpenConversationcxx . . $ TygemConnection#handleOpenConversation(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5252 {
5253 /* We're not going to bother negotiating this, get the player
5254 * and send a reply */
5255 PlayerListingcxx . . $ PlayerListing# * player;
5256 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
5257 QStringcxx . . $ QString# rankcxx . . $ QString#QString(ced63f7c635d850d).;
5258 unsigned char name[15];
5259 name[14] = 0x00;
5260
5261 if(size < 30)
5262 {
5263 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad conversation open size: %d", size);
5264 return;
5265 }
5266
5267 strncpy((char *)name, (char *)msg, 14);
5268 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5269 if(msg[15] < 0x12)
5270 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[15]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5271 else if(msg[15] > 0x1a)
5272 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5273 else
5274 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5275 strncpy((char *)name, (char *)&(msg[16]), 11);
5276 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5277
5278 player = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
5279 sendConversationReplycxx . . $ TygemConnection#sendConversationReply(ca5adf404307529).(player, acceptcxx . . $ TygemConnection#accept.);
5280 Talkcxx . . $ Talk# * t = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getTalkcxx . . $ Room#getTalk(e709c6e389e35213).(player);
5281 t->setConversationOpenedcxx . . $ Talk#setConversationOpened(b45ddcbc8423892c).(true);
5282 t->updatePlayerListingcxx . . $ Talk#updatePlayerListing(49f6e7a06ebc5aa8).();
5283 }
5284
5285 void TygemConnectioncxx . . $ TygemConnection#::handleConversationReplycxx . . $ TygemConnection#handleConversationReply(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5286 {
5287 PlayerListingcxx . . $ PlayerListing# * player;
5288 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
5289 QStringcxx . . $ QString# rankcxx . . $ QString#QString(ced63f7c635d850d).;
5290 unsigned char name[15];
5291 name[14] = 0x00;
5292 if(size < 63)
5293 {
5294 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad conversation reply size: %d", size);
5295 return;
5296 }
5297
5298 strncpy((char *)name, (char *)msg, 14);
5299 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5300 if(msg[15] < 0x12)
5301 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[15]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5302 else if(msg[15] > 0x1a)
5303 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5304 else
5305 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5306 strncpy((char *)name, (char *)&(msg[16]), 11);
5307 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5308
5309 player = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
5310 Talkcxx . . $ Talk# * t = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getIfTalkcxx . . $ Room#getIfTalk(b72f705c6951e6b6).(player);
5311 if(!t)
5312 {
5313 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No talk for: %s", encoded_name2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
5314 return;
5315 }
5316
5317 if(msg[62] == 0x01)
5318 {
5319 t->setConversationOpenedcxx . . $ Talk#setConversationOpened(b45ddcbc8423892c).(true);
5320 }
5321 else if(msg[62] == 0x00)
5322 {
5323 t->recvTalkcxx . . $ Talk#recvTalk(7df51288a9ebd664).(QStringcxx . . $ QString#QString(85c52e162fed56f9).("** Declines conversation **"));
5324 }
5325 else
5326 {
5327 #ifdef RE_DEBUG
5328 printf("Conversation reply msg 62 = %02x\n", msg[62]);
5329 #endif //RE_DEBUG
5330 }
5331
5332 if(pendingConversationMsgcxx . . $ TygemConnection#pendingConversationMsg..findcxx . . $ std/map#find(36f8d56706583706).(player) !=cxx . . $ std/`operator!=`(be6a71a859368080). pendingConversationMsgcxx . . $ TygemConnection#pendingConversationMsg..endcxx . . $ std/map#end(7e4de33083b6e738).())
5333 {
5334 sendConversationMsgcxx . . $ TygemConnection#sendConversationMsg(1598b02156041f24).(player, pendingConversationMsgcxx . . $ TygemConnection#pendingConversationMsg.[cxx . . $ std/map#`operator[]`(bbd415b616967878).player].toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
5335 pendingConversationMsgcxx . . $ TygemConnection#pendingConversationMsg..erasecxx . . $ std/map#erase(a7de169f3ef4bfb3).(player);
5336 }
5337 }
5338
5339 void TygemConnectioncxx . . $ TygemConnection#::handleConversationMsgcxx . . $ TygemConnection#handleConversationMsg(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5340 {
5341 PlayerListingcxx . . $ PlayerListing# * player;
5342 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
5343 QStringcxx . . $ QString# rankcxx . . $ QString#QString(ced63f7c635d850d).;
5344 unsigned char name[15];
5345 int size_of_message;
5346 int nickname_len;
5347 bool closing = false;
5348 char * text;
5349 name[14] = 0x00;
5350 if(size < 61)
5351 {
5352 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Received bad conversation msg");
5353 return;
5354 }
5355 #ifdef RE_DEBUG
5356 printf("Conversation msg:\n");
5357 for(unsigned int i = 0; i < size; i++)
5358 printf("%02x ", msg[i]);
5359 printf("\n");
5360 #endif //RE_DEBUG
5361
5362 strncpy((char *)name, (char *)msg, 14);
5363 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5364 if(msg[15] < 0x12)
5365 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[15]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5366 else if(msg[15] > 0x1a)
5367 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5368 else
5369 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[15] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5370 strncpy((char *)name, (char *)&(msg[16]), 11);
5371 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5372 nickname_len = strlen((char *)name);
5373 //FIXME 255 chat size limit ?!?!
5374 size_of_message = msg[60];
5375 unsigned int adjusted_size = size_of_message;
5376 if(size_of_message % 4 == 0)
5377 adjusted_size += 4;
5378 else
5379 {
5380 while(adjusted_size % 4 != 0)
5381 adjusted_size++;
5382 }
5383 if(size != adjusted_size + 60 + 4)
5384 {
5385 //76 72
5386 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad conversation message size %d %d", size, adjusted_size + 64);
5387 return;
5388 }
5389
5390 player = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
5391 Talkcxx . . $ Talk# * t = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getIfTalkcxx . . $ Room#getIfTalk(b72f705c6951e6b6).(player);
5392 if(!t)
5393 {
5394 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unknown player replies to conversation: %s", encoded_name2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
5395 return;
5396 }
5397
5398 if(msg[62] == 0x04)
5399 {
5400 //FIXME do we need to do anything else?
5401 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Conversation closing by other person");
5402 closing = true;
5403 }
5404 else if(msg[62] != 0x05)
5405 {
5406 #ifdef RE_DEBUG
5407 printf("Conversation msg 62 = %02x\n", msg[62]);
5408 #endif //RE_DEBUG
5409 }
5410
5411 text = new char[size_of_message + 1];
5412 strncpy(text, (char *)&(msg[64]), size_of_message);
5413
5414 text[size_of_message] = 0x00; //doublecheck FIXME
5415
5416 QStringcxx . . $ QString# ucxx . . $ QString#QString(ced63f7c635d850d).;
5417
5418 if(closing)
5419 {
5420 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)&(text[nickname_len + 2]), strlen((char *)&(text[nickname_len + 2])));
5421 u =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). "** " +cxx . . $ operator+(c75c3ae4eb9af1a8). u +cxx . . $ operator+(3d22f08efddf8107). " **";
5422 }
5423 else
5424 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)text, strlen((char *)text));
5425 t->recvTalkcxx . . $ Talk#recvTalk(7df51288a9ebd664).(ucxx . . $ QString#QString(132dd6869045752b).);
5426 if(closing)
5427 t->setConversationOpenedcxx . . $ Talk#setConversationOpened(b45ddcbc8423892c).(false);
5428 delete[] text;
5429 }
5430
5431 /* I think these are actually supposed to be little email type msgs even though
5432 * they're small and conversations are supposed to be held over
5433 * something else that we have to respond to to open up */
5434 void TygemConnectioncxx . . $ TygemConnection#::handlePersonalChatcxx . . $ TygemConnection#handlePersonalChat(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5435 {
5436 unsigned char * p = msg;
5437 unsigned char * text = new unsigned char[size - 7];
5438 unsigned char name[15];
5439 name[14] = 0x00;
5440 unsigned int subject_size, msg_size;
5441 QStringcxx . . $ QString# our_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d)., rankcxx . . $ QString#QString(ced63f7c635d850d)., subjectcxx . . $ QString#QString(ced63f7c635d850d).;
5442 #ifdef RE_DEBUG
5443 printf("** msg size: %d: ", size);
5444 for(unsigned int i = 0; i < size; i++)
5445 printf("%02x", p[i]);
5446 printf("\n");
5447 #endif //RE_DEBUG
5448
5449 strncpy((char *)name, (char *)p, 14);
5450 our_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).((char *)name);
5451 p += 15;
5452 p++;
5453 strncpy((char *)name, (char *)p, 14);
5454 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5455 p += 15;
5456
5457 //rank byte
5458 if(p[0] < 0x12)
5459 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5460 else if(p[0] > 0x1a)
5461 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5462 else
5463 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5464 p++;
5465 strncpy((char *)name, (char *)p, 11);
5466 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5467 p += 12;
5468 p++;
5469 subject_size = p[0];
5470 p++;
5471 printf("Subjectsize: %d\n", subject_size);
5472 if(subject_size > (size - 47))
5473 {
5474 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad message subject size: %d", subject_size);
5475 delete[] text;
5476 return;
5477 }
5478 strncpy((char *)text, (char *)p, subject_size);
5479 subject =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).((char *)text);
5480 p += subject_size;
5481 msg_size = (p[0] << 8) + p[1]; //tygem caps at 1024
5482 p += 2;
5483 printf("msg_size: %d\n", msg_size);
5484 if(msg_size > (size - (47 + subject_size + 2)))
5485 {
5486 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad message msg size: %d", msg_size);
5487 delete[] text;
5488 return;
5489 }
5490 strncpy((char *)text, (char *)p, msg_size + 1);
5491
5492 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
5493 PlayerListingcxx . . $ PlayerListing# * player = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
5494
5495 #ifdef RE_DEBUG
5496 printf("%s says to you ", player->name.toLatin1().constData());
5497 for(unsigned int i = 0; i < size - 8; i++)
5498 printf("%02x", text[i]);
5499 printf("\n");
5500 #endif //RE_DEBUG
5501 QStringcxx . . $ QString# ucxx . . $ QString#QString(ced63f7c635d850d).;
5502 u =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((const char *)text, strlen((char *)text));
5503 Talkcxx . . $ Talk# * talk = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getTalkcxx . . $ Room#getTalk(e709c6e389e35213).(player);
5504 if(talk)
5505 {
5506 talk->recvTalkcxx . . $ Talk#recvTalk(7df51288a9ebd664).(ucxx . . $ QString#QString(132dd6869045752b).);
5507 talk->updatePlayerListingcxx . . $ Talk#updatePlayerListing(49f6e7a06ebc5aa8).();
5508 }
5509 //FIXME highlight or something
5510 //if(console_dispatch)
5511 // console_dispatch->recvText(player->name + "-> " + QString((char *)text));
5512
5513 delete[] text;
5514 }
5515
5516 //0666
5517 void TygemConnectioncxx . . $ TygemConnection#::handleObserverListcxx . . $ TygemConnection#handleObserverList(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5518 {
5519 unsigned char * p = msg;
5520 unsigned int game_number;
5521 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
5522 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
5523 PlayerListingcxx . . $ PlayerListing# * aPlayer;
5524 //PlayerListing * newPlayer = new PlayerListing();
5525 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d)., rankcxx . . $ QString#QString(ced63f7c635d850d).;
5526 int country_size;
5527 unsigned char name[20]; //country can be larger than 11
5528 game_number = (p[0] << 8) + p[1];
5529 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
5530 if(!boarddispatch)
5531 {
5532 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("no board dispatch for observer list");
5533 return;
5534 }
5535
5536 p += 2;
5537 // unsigned short number_of_observers = (p[0] << 8) + p[1];
5538 p += 2;
5539 #ifdef RE_DEBUG
5540 printf("observers %d:\n", number_of_observers);
5541 for(unsigned int i = 0; i < size - 4; i++)
5542 printf("%02x", p[i]);
5543 printf("\n");
5544 #endif //RE_DEBUG
5545 /* FIXME possible issue with country name which is not included in
5546 * 0x34 */
5547
5548 while(p < (msg + size - 0x33) || (p[0] == 0x01 && p < (msg + size - 19)))
5549 {
5550 if(p[0] == 0x01)
5551 {
5552 //0131 1140 b9d9 b6f7 b3ad c1f8 c0cc 0000 0000 0013 c900 0000
5553
5554
5555 //0100 0000 696e 7472 7573 696f 6e00 0000 0000 0009
5556 p += 4;
5557 strncpy((char *)name, (char *)p, 14);
5558 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5559 aPlayer = room->getPlayerListingByNotNicknamecxx . . $ Room#getPlayerListingByNotNickname(d3f53ac2de9f0b45).(encoded_name);
5560 boarddispatch->recvObservercxx . . $ BoardDispatch#recvObserver(fcd883ebbd0934ee).(aPlayer, false);
5561 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOngoingMatchcxx . . $ MatchNegotiationState#isOngoingMatch(3c978dac0e5ee2ad).(game_number))
5562 {
5563 GameDatacxx . . $ GameData# * gameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
5564 //FIXME nick or username? probably nick but is that ascii or normal?
5565 if(aPlayer->namecxx . . $ PlayerListing#name. ==cxx . . $ `operator==`(5bc2975d2d751687). (gameData->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? gameData->white_namecxx . . $ GameData#white_name. : gameData->black_namecxx . . $ GameData#black_name.))
5566 {
5567 if(gameData->fullresultcxx . . $ GameData#fullresult. == 0)
5568 {
5569 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("opponent left game!!");
5570 sendOpponentDisconnectcxx . . $ TygemConnection#sendOpponentDisconnect(89ee62dcaa58bdba).(game_number, opponent_disconnectcxx . . $ TygemConnection#opponent_disconnect.);
5571 sendLongOpponentDisconnectcxx . . $ TygemConnection#sendLongOpponentDisconnect(cb2f890c2fdad230).(game_number);
5572
5573 opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID. = startTimercxx . . $ QObject#startTimer(cf5d4a693bb15cf1).(1000);
5574 /* FIXME may or may not be the right place
5575 * for this, we could get another message or
5576 * perhaps when we haven't received time
5577 * from opponent for 4 or 5 seconds.
5578 * Right now, I'll assume that's time it takes
5579 * server to pass "observer left" msg */
5580 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentDisconnectcxx . . $ MatchNegotiationState#opponentDisconnect(49f6e7a06ebc5aa8).();
5581 /* FIXME, if its our turn, we need to block playing, and also stop the clocks !!
5582 * or can we play?FIXME */
5583 boarddispatch->stopTimecxx . . $ BoardDispatch#stopTime(49f6e7a06ebc5aa8).(); //also no play, if our turn
5584 QStringcxx . . $ QString# q = QStringcxx . . $ QString#(trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Opponent Disconnected"));
5585 boarddispatch->moveControlcxx . . $ BoardDispatch#moveControl(4c89b026053e4d32).(q);
5586 }
5587 }
5588 }
5589 p += 15;
5590 #ifdef RE_DEBUG
5591 printf("Player %s leaving room, last byte: %02x\n", encoded_name.toLatin1().constData(), p[0]);
5592 #endif //RE_DEBUG
5593 p++;
5594 #ifdef RE_DEBUG
5595 printf("Found leaving observer\n");
5596 #endif //RE_DEBUG
5597 continue;
5598 }
5599 if(p[1] == 0x39)
5600 {
5601 p += 4;
5602 printf("observer, what the hell is this\n");
5603 continue;
5604 }
5605 else if(p[1] != 0x02)
5606 {
5607 printf("%02x%02x\n", p[0], p[1]);
5608 }
5609 #ifdef RE_DEBUG
5610 for(int i = 0; i < 0x34; i++)
5611 printf("%c", p[i]);
5612 printf("\n");
5613 #endif //RE_DEBUG
5614 p += 2;
5615 p++;
5616 if(!p[0])
5617 {
5618 printf("Observer Guest\n");
5619 //0002 0000 5b47 3337 3039 5d32 3000 0000
5620 //0000 0000 5b47 3337 3039 5d32 3000 0000
5621 //0000 0100 0000 0000 0000 0000 0000 0000
5622 //0000 0000
5623 /* FIXME this looks a little funny. A room with
5624 * multiple observers that's empty because we don't
5625 * add guests to the list... at the same time,
5626 * they'd have to be special player listings..
5627 * maybe just duplicates but still... */
5628 p += 48;
5629 p += p[0] + 1;
5630 continue;
5631 }
5632
5633 /* I think p[0] is the flag icon, but it can be different
5634 * pictures too so... */
5635 p++;
5636 strncpy((char *)name, (char *)p, 14);
5637 //encoded_name = QString((char *)name);
5638 /* WARNING There's a chance that encoded names are not one
5639 * to one and since the names are used to look players up,
5640 * doing toUnicode could write to the wrong player.
5641 * possible FIXME*/
5642 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5643 p += 14;
5644 p++;
5645 //rank byte
5646 if(p[0] < 0x12)
5647 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - p[0]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
5648 else if(p[0] > 0x1a)
5649 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
5650 else
5651 rank =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(p[0] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
5652 p++;
5653 strncpy((char *)name, (char *)p, 11);
5654 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
5655 //another name
5656 aPlayer = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
5657 //unnecessary to set the name since we can't get
5658 //record without it... probably nickname as well
5659 //FIXME, but if we didn't need player lists...
5660 //technically we should be able to display anyway...
5661 //aPlayer->name = encoded_name;
5662 //aPlayer->nickname = nickname;
5663 //aPlayer->rank = rank;
5664 p += 8;
5665 p += 4;
5666 p += 16;
5667 p += 2;
5668 p++;
5669
5670 /* Below is player listing packet */
5671 //0002 009e 3737 3435 3532 0000 0000 0000
5672 //0000 0000 3737 3435 3532 006f 6f6e 0002
5673 //0000 0000 0000 0064 0000 012b 0000 0000
5674 //ffff ff40 0001 004b
5675 /****/
5676 /* And observer listing */
5677 //0002 009e 7065 7465 7269 7573 0000 0000
5678 //0000 0008 7065 7465 7269 7573 0000 0002
5679 //0000 0000 0000 0000 0000 0000 0000 0000
5680 //0000 0005 6368 696e 61
5681
5682 country_size = p[0];
5683 p++;
5684 if(p > (msg + size - country_size))
5685 {
5686 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Observer list packet overrun, discarding last record!");
5687 return;
5688 }
5689 if(country_size > 19)
5690 {
5691 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Strange country name size greater than hard coded array!!!");
5692 p += country_size;
5693 continue;
5694 }
5695 strncpy((char *)name, (char *)p, country_size);
5696 name[country_size] = '\0';
5697 p += country_size;
5698 aPlayer->countrycxx . . $ PlayerListing#country. =cxx . . $ QString#`operator=`(4f35bf974e7f8568). QStringcxx . . $ QString#QString(85c52e162fed56f9).((char *)name);
5699 /*recvObserver does not make a copy at any point.
5700 *its supposed that the player listing comes from
5701 *the full listing and will be handled with that.*/
5702
5703 /* Also notice that below is a problem if someone leaves
5704 * and rejoins a game */
5705 //aPlayer->room_list.push_back(game_number); //moved to boarddispatch doublecheck FIXME
5706 boarddispatch->recvObservercxx . . $ BoardDispatch#recvObserver(fcd883ebbd0934ee).(aPlayer, true);
5707 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
5708 {
5709 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->justCreatedRoomcxx . . $ MatchNegotiationState#justCreatedRoom(c9857a73d68e59ba).() && match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getPlayerListingcxx . . $ MatchNegotiationState#getPlayerListing(8a20cf3761bafdec).() == aPlayer)
5710 {
5711 /* They've just joined our created room
5712 * so we send the rest of this. Presuming
5713 * its not a resume... FIXME */
5714 /* This might be a resume or something weird
5715 * I'm not seeing MatchMsg1 anymore !!!
5716 * just they join, we pop up the offer dialog
5717 * and then we send it !!! FIXME*/
5718 //#ifdef FIXME //necessary when?
5719 //tom may require this
5720 if(connectionTypecxx . . $ NetworkConnection#connectionType. == TypeTOMcxx . . $ TypeTOM.)
5721 sendMatchMsg1cxx . . $ TygemConnection#sendMatchMsg1(35cead64ffbd9888).(aPlayer, game_number);
5722 //#endif //FIXME
5723 MatchRequestcxx . . $ MatchRequest# * mr = new MatchRequestcxx . . $ MatchRequest#();
5724 mr->numbercxx . . $ MatchRequest#number. = game_number;
5725 mr->opponentcxx . . $ MatchRequest#opponent. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). aPlayer->namecxx . . $ PlayerListing#name.;
5726 mr->opponent_is_challengercxx . . $ MatchRequest#opponent_is_challenger. = false;
5727 /* FIXME this is same as "our_invitation" I think
5728 * in game data, they should be the same name
5729 * FIXME FIXME FIXME */
5730 mr->first_offercxx . . $ MatchRequest#first_offer. = true;
5731 mr->timeSystemcxx . . $ MatchRequest#timeSystem. = byoyomicxx . . $ byoyomi.;
5732
5733 GameDialogcxx . . $ GameDialog# * gd = getGameDialogcxx . . $ NetworkConnection#getGameDialog(3dcc94127826259).(aPlayer);
5734 gd->recvRequestcxx . . $ GameDialog#recvRequest(461bc273ee812ab9).(mr, getGameDialogFlagscxx . . $ TygemConnection#getGameDialogFlags(f708dce9a8856c70).());
5735 delete mr;
5736 }
5737 else
5738 {
5739 GameDatacxx . . $ GameData# * gameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
5740 //FIXME nick or username? probably nick but is that ascii or normal?
5741 if(aPlayer->namecxx . . $ PlayerListing#name. ==cxx . . $ `operator==`(5bc2975d2d751687). (gameData->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() ? gameData->white_namecxx . . $ GameData#white_name. : gameData->black_namecxx . . $ GameData#black_name.))
5742 {
5743 if(opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID.)
5744 {
5745 /* FIXME, quite likely we'll need to
5746 * send other things here or perhaps
5747 * we even get another message to
5748 * trigger this, not this one */
5749 killTimercxx . . $ QObject#killTimer(d4f767463ce0a6b3).(opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID.);
5750 opponentDisconnectTimerIDcxx . . $ TygemConnection#opponentDisconnectTimerID. = 0;
5751 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opponent rejoined after leaving");
5752 /* I think these are probably sent in response to something maybe...
5753 * we shouldn't just send them like this. We need to do it
5754 * one at a time like match negotiation FIXME */
5755 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(gameData, opponent_reconnectscxx . . $ TygemConnection#opponent_reconnects.);
5756 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentRejoinscxx . . $ MatchNegotiationState#opponentRejoins(49f6e7a06ebc5aa8).();
5757 }
5758 }
5759 }
5760 }
5761 }
5762 if(p != (msg + size))
5763 {
5764 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("handleObserverList strange size: %d(%d)", (msg + size) - p, size);
5765 }
5766 }
5767
5768 /* I think we get these when we try to observe broadcasted, or betting games
5769 * as well.
5770 * oro FIXME, but tygem may have betting in general*/
5771 void TygemConnectioncxx . . $ TygemConnection#::handleBettingMatchStartcxx . . $ TygemConnection#handleBettingMatchStart(e1e8b00c42c42532).(unsigned char * , unsigned int )
5772 {
5773 }
5774
5775 /* These are simple, sent by the loser I think
5776 * note that sendMatchResult sends them which is awkward
5777 * because of "match" versus "game" FIXME */
5778 //0670
5779 void TygemConnectioncxx . . $ TygemConnection#::handleGameResult2cxx . . $ TygemConnection#handleGameResult2(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5780 {
5781 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
5782 GameDatacxx . . $ GameData# * gameData;
5783 //0670
5784 //0003 0001 6269 7473 0000 0000 0000 0000
5785 //0000 0014 6269 7473 0000 0000 0000 0002
5786 //0000 0000 0000 0000
5787 if(size != 0x28)
5788 {
5789 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Game result 2 msg of strange size: %d", size);
5790 }
5791 char name[15];
5792 strncpy((char *)name, (char *)&(msg[4]), 14);
5793
5794 strncpy((char *)name, (char *)&(msg[20]), 11);
5795 if(getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() !=cxx . . $ `operator!=`(5bc2975d2d751687). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name)))
5796 {
5797 #ifdef RE_DEBUG
5798 //FIXME note that if this happens a lot
5799 //we might need to handle it in observed games
5800 //actually, we get our own message back so...
5801 printf("0670 not addressed to us\n");
5802 #endif //RE_DEBUG
5803 /* FIXME, it seems if we resign, maybe only if its early in game, but we'll get our own 0670 back
5804 * but no 0672, which leads to thinking the opponent dropped because nothing sets RESIGN flag.
5805 * if nothing is broken, then that means we should check here or when we send the resign in case
5806 * moves is less than 5 or 10 or something and then set result there FIXME */
5807 /* Okay, I think now that that first name is not the addressee necessary, that its the wff thing
5808 * so we need to handle these FIXME */
5809 return;
5810 }
5811 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).((msg[0] << 8) + msg[1]);
5812 if(!boarddispatch)
5813 {
5814 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("no board dispatch for %d", (msg[0] << 8) + msg[1]);
5815 return;
5816 }
5817 gameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
5818 //msg[2] is likely color
5819 #ifdef RE_DEBUG
5820 if(msg[2])
5821 boarddispatch->recvKibitz(0, "0x670 (resign msg? 01)");
5822 else
5823 boarddispatch->recvKibitz(0, "0x670 (resign msg? 00)");
5824 printf("0x0670: ");
5825 for(unsigned int i = 0; i < size; i++)
5826 printf("%02x", msg[i]);
5827 printf("\n");
5828 #endif //RE_DEBUG
5829 //I think we need to respond to this with 0672
5830 //otherwise no result posted
5831 //sendLongMatchResult FIXME but only if this is
5832 //from opp
5833 //note also that this is very likely the resign
5834 //message and we should set result as such REGARDLESS
5835 //of being in score mode or not, we should switch out if it
5836 //if we are
5837 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
5838 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
5839 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).();
5840 //FIXME, we should be able to use
5841 //color byte above, msg[2] or whatever
5842 if(gameData->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
5843 {
5844 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneWhitecxx . . $ stoneWhite.;
5845 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gameData->black_namecxx . . $ GameData#black_name.;
5846 }
5847 else
5848 {
5849 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneBlackcxx . . $ stoneBlack.;
5850 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gameData->white_namecxx . . $ GameData#white_name.;
5851 }
5852 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
5853 sendResultcxx . . $ TygemConnection#sendResult(f9859626c725809).(gameData, &aGameResult);
5854
5855 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(gameData->numbercxx . . $ GameData#number.)) //redundant with 0672?
5856 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->resetcxx . . $ MatchNegotiationState#reset(49f6e7a06ebc5aa8).();
5857 }
5858
5859 //0672
5860 void TygemConnectioncxx . . $ TygemConnection#::handleGameResultcxx . . $ TygemConnection#handleGameResult(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
5861 {
5862 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
5863 unsigned char * p = msg;
5864 unsigned short game_number = (msg[0] << 8) + msg[1];
5865 //bool white_loses_on_time = false, black_loses_on_time = false;
5866 //unsigned int moves;
5867 unsigned int margin;
5868 unsigned char victory_condition_code;
5869 if(size != 0x24)
5870 {
5871 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Game result of strange size: %d", size);
5872 }
5873 //this is sent if we join an ended game as well
5874 //must be result where 0671 is match opened
5875 //0670 is sent if, for instance, resign
5876 //while we're watching it, but not after over
5877
5878 //but 0670 can be sent without 0672 apparently
5879 //during game, but again, we would get 0672 alone
5880 //if it was after game
5881 //lastly, looks like 0672 might happen without SUR?
5882 //maybe only when adjourned or something?
5883 //but we definitely need to handle it and we might
5884 //want to have it send result (i.e., W+T, etc. ) FIXME
5885
5886 //white has 4 seconds wins by R
5887 //0002 0001 d6ee b8f0 d0a1 bba8 0000 0000
5888 //0000 001a 0400 0000 0076 0000 0204 00a0
5889 //021c 0060
5890
5891 //gets this after sends a timeloss prematurely due to some 0 period count error...
5892 //FIXME
5893 //038d0001696e74727573696f6e000000000000090900000000010000000000a0011d0060
5894
5895 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
5896 if(!boarddispatch)
5897 {
5898 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for game number %d", game_number);
5899 return;
5900 }
5901 GameDatacxx . . $ GameData# * gd = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
5902 p += 2;
5903 // bool white_wins2 = msg[2] ^ gd->white_first_flag; //NOT VALID as is
5904 #ifdef RE_DEBUG
5905 printf("0672 %02x vs %02x!!", msg[2], gd->our_invitation);
5906 #endif //RE_DEBUG
5907 /* FIXME double check this, but as is, it seems in our games, this is addressed
5908 * to us and this is not the winner name, winner rank, but just the usual msg
5909 * header, doublecheck against other games */
5910
5911 //00 00 their invitation, they win
5912 //01 00 their invitation, we win
5913 p += 2;
5914 //winner name //probably not, dest
5915 p += 14;
5916 //winner rank //probably not, dest
5917 p += 2;
5918 //0300 0000 0115 0000
5919 victory_condition_code = msg[20]; //p[0]
5920 //03 B + R
5921 //04 W + R
5922 //00 W + X
5923 //07 B + T
5924 //0000 0956 002e 0000
5925 p += 2;
5926 margin = (msg[22] << 8) + msg[23];
5927 p += 2;
5928 // moves = (msg[24] << 8) + msg[25];
5929 p += 2;
5930 printf("%02x%02x is in 0672 after margin and moves\n", p[0], p[1]); //p[0] may need to be xored with wff
5931 p += 2;
5932 //times
5933
5934 // enum TimeFlags f = handleTimeChunk(boarddispatch, &(msg[28]), gd->white_first_flag); //this can still get time flipped FIXME
5935 /* FIXME unreliable !! not necessary */
5936 /* if(f == BLACK_LOSES)
5937 black_loses_on_time = true;
5938 else if(f == WHITE_LOSES)
5939 white_loses_on_time = true; */
5940
5941 #ifdef RE_DEBUG
5942 //B + R: white_wins2 = 1 here, FIXME
5943 if(boarddispatch)
5944 boarddispatch->recvKibitz(0, "0x672 " + QString::number(white_wins2));
5945
5946 printf("***** 0x0672: ");
5947 for(unsigned int i = 0; i < size; i++)
5948 printf("%02x", msg[i]);
5949 printf("\n");
5950 if(black_loses_on_time)
5951 qDebug("black loses on time?\n");
5952 if(white_loses_on_time)
5953 qDebug("white loses on time?\n");
5954 #endif //RE_DEBUG
5955
5956 //FIXME not necessary:
5957
5958 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
5959 #ifdef FIXME //also broken I think
5960 if(white_loses_on_time || black_loses_on_time)
5961 {
5962 aGameResult.result = GameResult::TIME;
5963 aGameResult.game_number = game_number;
5964 if(white_loses_on_time)
5965 {
5966 aGameResult.loser_name = gd->white_name;
5967 aGameResult.winner_name = gd->black_name;
5968 aGameResult.winner_color = stoneBlack;
5969 }
5970 else
5971 {
5972 aGameResult.loser_name = gd->black_name;
5973 aGameResult.winner_name = gd->white_name;
5974 aGameResult.winner_color = stoneWhite;
5975 }
5976 boarddispatch->recvResult(&aGameResult);
5977 return;
5978 }
5979 #endif //FIXME
5980
5981 //awkward, redundant with white_loses_on_time, black_loses_on_time above
5982 bool white_wins = false, black_wins = false;
5983 switch(victory_condition_code)
5984 {
5985 case 0x00:
5986 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::SCOREcxx . . $ GameResult#SCORE.;
5987 black_wins = true;
5988 aGameResult.winner_scorecxx . . $ GameResult#winner_score. = (float)margin/10.0;
5989 aGameResult.loser_scorecxx . . $ GameResult#loser_score. = 0;
5990 break;
5991 case 0x01:
5992 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::SCOREcxx . . $ GameResult#SCORE.;
5993 white_wins = true;
5994 aGameResult.winner_scorecxx . . $ GameResult#winner_score. = (float)margin/10.0;
5995 aGameResult.loser_scorecxx . . $ GameResult#loser_score. = 0;
5996 break;
5997 case 0x02:
5998 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::DRAWcxx . . $ GameResult#DRAW.;
5999 /* Don't know whether we get this or what */
6000 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneNonecxx . . $ stoneNone.;
6001 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
6002 return; //awkward
6003 break;
6004 case 0x03:
6005 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
6006 black_wins = true;
6007 break;
6008 case 0x04:
6009 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
6010 white_wins = true;
6011 break;
6012 case 0x05:
6013 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::FORFEITcxx . . $ GameResult#FORFEIT.;
6014 black_wins = true;
6015 break;
6016 case 0x06:
6017 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::FORFEITcxx . . $ GameResult#FORFEIT.;
6018 white_wins = true;
6019 break;
6020 case 0x07:
6021 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.;
6022 black_wins = true;
6023 break;
6024 case 0x08:
6025 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.;
6026 white_wins = true;
6027 break;
6028 /* FIXME doublecheck these, I think we get these
6029 * if its an overwhelming victory. It displays a
6030 * cute message, its not really a resign but
6031 * it may as well be. */
6032 case 0x09:
6033 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
6034 black_wins = true;
6035 break;
6036 case 0x0a:
6037 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::RESIGNcxx . . $ GameResult#RESIGN.;
6038 white_wins = true;
6039 break;
6040 default:
6041 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("%02x is unhandled victory condition code", victory_condition_code);
6042 break;
6043 }
6044
6045 //definitely where we pop up result
6046 //EXCEPT that if its our match and we sent the 0672, I don't think we get one
6047 //back, but we don't want the countdialog to be looking at our_invitation
6048 //which is certainly tygem specific even though, at this point, the
6049 //distinction is meaningless
6050 //so we'll let countdialog set the result no matter what and we'll
6051 //drop the 0672 here if its our match, unless its loss on time, not after
6052 //countdialog is active
6053 //no unless its a resign, really, according to tygem FIXME
6054 //this messaage is where result is set
6055 //this is hideously awkward but its fine for now FIXME
6056 /*if(game_number == playing_game_number)
6057 {
6058 if(aGameResult.result == GameResult::SCORE)
6059 {
6060 //apparently, game result doesn't come up
6061 //from accept count at all or properly
6062 //which might be better anyway
6063 //playing_game_number = 0; //good place?? FIXME
6064 //return;
6065 }
6066 }*/
6067
6068 aGameResult.game_numbercxx . . $ GameResult#game_number. = game_number;
6069 if(black_wins)
6070 {
6071 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gd->white_namecxx . . $ GameData#white_name.;
6072 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gd->black_namecxx . . $ GameData#black_name.;
6073 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneBlackcxx . . $ stoneBlack.;
6074 }
6075 else
6076 {
6077 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gd->black_namecxx . . $ GameData#black_name.;
6078 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gd->white_namecxx . . $ GameData#white_name.;
6079 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneWhitecxx . . $ stoneWhite.;
6080 }
6081 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
6082 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
6083 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->resetcxx . . $ MatchNegotiationState#reset(49f6e7a06ebc5aa8).();
6084 }
6085
6086 //0x0683: //clock stop? //enter score?
6087 /* As I recall, these are also used to set the time in professional games
6088 * being broadcast
6089 * But on second thought, this is a 0683:
6090 //018e 0b01 bfee bfb5 c0da 3832 0000 0000
6091 //0000 0016 0000 0000 0000 0000 0000 0000
6092 //0000 1a00 c1a6 3134 b1e2 2047 53c4 aec5
6093 //d8bd bab9 e820 babb bcb1 b8ae b1d7 0000
6094 * so not really sure what they are... that's got some names in there, could
6095 * even be a comment of some kind
6096 * likely a game update
6097 */
6098 #ifdef RE_DEBUG
6099 void TygemConnection::handleScoreMsg1(unsigned char * msg, unsigned int size)
6100 #else
6101 void TygemConnectioncxx . . $ TygemConnection#::handleScoreMsg1cxx . . $ TygemConnection#handleScoreMsg1(e1e8b00c42c42532).(unsigned char * msg, unsigned int /*size*/)
6102 #endif //RE_DEBUG
6103 {
6104 /* Change name FIXME, definitely not enter score, more likely
6105 * time stop. Except, they're variable size... Its even possible
6106 * that they're image sends... maybe... */
6107 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6108 //0087 aa01 0101 0000 031e 00a0 0334 0040
6109 #ifdef RE_DEBUG
6110 printf("0x0683: ");
6111 for(unsigned int i = 0; i < size; i++)
6112 printf("%02x", msg[i]);
6113 printf("\n");
6114 #endif //RE_DEBUG
6115 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).((msg[0] << 8) + msg[1]);
6116 if(!boarddispatch)
6117 return;
6118 #ifdef RE_DEBUG
6119 boarddispatch->recvKibitz(0, "0x683");
6120 #endif //RE_DEBUG
6121 //boarddispatch->stopTime();
6122
6123 //after this 7b
6124 //0087 0101 6261 696e 6974 6500 0000 0000
6125 //0000 0011 6261 696e 6974 6500 0000 0002
6126 //00c5 0000 0000 0000
6127 //0087 aa01 0300 0000 031e 00a0 0334 0040
6128 //FIXME
6129 //black_first = ??
6130 //handleTimeChunk(boarddispatch, &(msg[7]), black_first);
6131 //another 7b 83 pair:
6132 //0087 0001 baac d0a6 bba8 0000 0000 0000
6133 //0000 0011 6861 6e78 6961 6f68 7561 0002
6134 //00c5 0000 0000 0000
6135
6136 //0087 aa01 0201 0000 031e 00a0 0334 0040
6137
6138 // and two more pairs, same game
6139 //0x067b:
6140 //00870001baacd0a6bba80000000000000000001168616e7869616f687561000201c6000000000000
6141 //0087aa0104010100031e00a003340040
6142
6143 //008701016261696e6974650000000000000000116261696e697465000000000201c6000000000000
6144
6145 //0087aa0105000100031e00a003340040
6146 //followed by 0672
6147 //0087 0101 6261 696e 6974 6500 0000 0000
6148 //0000 0011 0000 0055 0116 0000 031e 00a0
6149 //0334 0040 0024 0668
6150
6151 //0x0683: 0183aa01050000000318008003260040
6152 }
6153
6154 //an REM -1 -1 likely proceeds these as meaning done?
6155 void TygemConnectioncxx . . $ TygemConnection#::handleEndgameMsgcxx . . $ TygemConnection#handleEndgameMsg(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6156 {
6157 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6158 GameDatacxx . . $ GameData# * game;
6159 unsigned short game_number;
6160 unsigned char name[15];
6161 name[14] = 0x00;
6162 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
6163 if(size < 34)
6164 {
6165 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad endgame msg, size: %d", size);
6166 return;
6167 }
6168 //I"m thinking actually draw request
6169 //no I think this is a request, count maybe? or is that 6a?
6170 //maybe winner message?, unlikely, several sent and 0201c5 as well below
6171 //00020101616438380000000000000000000000
6172 //16616438380000000000000002 00 c5000000000000
6173 //we saw alternating 067b and 0683, with the 83 starting the sequence
6174 //had something to do with hitting done or agree, in the end black
6175 //(I think black) just resigned
6176 //01c50101c4f4d2bbb5b6000000000000000000124e6965596944616f0000000200c7000000000000
6177 //01c5 aa01 0600 0000 030b 00a0 031e 0060
6178 //01c50001caa4c1fa3200000000000000000000127368656e676c6f6e6732000201c9000000000000
6179 //and then right before DSC move message:
6180
6181 //0x067b: 01c50101c4f4d2bbb5b6000000000000000000124e6965596944616f0000000201c6000000000000
6182 //0x0683: 01c5 aa01 0401 0100 030b 00a0 031e 0060
6183 //0x067b: 01c50001caa4c1fa3200000000000000000000127368656e676c6f6e6732000200c6000000000000
6184 //0x0683: 01c5 aa01 0500 0000 030b 00a0 031e 0060
6185 //0x066b: 00da0001c6f7bcbcc0ccb5b700000000000000166d696e676d696e67303100000100000000000000
6186
6187 //008701016261696e6974650000000000000000116261696e697465000000000200c5000000000000
6188 game_number = (msg[0] << 8) + msg[1];
6189 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6190 if(!boarddispatch)
6191 {
6192 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unexpected: got 067b for board %d", game_number);
6193 return;
6194 }
6195 game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
6196 #ifdef RE_DEBUG
6197 printf("***** 0x067b: ");
6198 for(unsigned int i = 0; i < size; i++)
6199 printf("%02x", msg[i]);
6200 printf("\n");
6201 #endif //RE_DEBUG
6202
6203 //this is addressee
6204 strncpy((char *)name, (char *)&(msg[4]), 14);
6205 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
6206 strncpy((char *)name, (char *)&(msg[20]), 11);
6207 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
6208 /* encoded_name2 is NOT reliable, for instance in resuming adjourned. */
6209 if(encoded_name2 !=cxx . . $ `operator!=`(5bc2975d2d751687). QStringcxx . . $ QString#QString(ced63f7c635d850d).())
6210 encoded_name =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_name2;
6211
6212 /*player = getDefaultroom->getPlayerListing(encoded_name);
6213 if(!player)
6214 {
6215 qDebug("Can't get player listing for %s in 067b", encoded_name.toLatin1().constData());
6216 return;
6217 }*/
6218 //035d 0001 696e 7472 7573 696f 6e00 0000 0000 0009
6219 //696e 7472 7573 696f 6e00 0002 00c3 0000 0000 0000
6220
6221 //030a 0001 696e 7472 7573 696f 6e00 0000 0000 0009
6222 //696e 7472 7573 696f 6e00 0002 0000 0000 0000 0000
6223 if(msg[33] == 0xc1)
6224 {
6225 if(encoded_name !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) //probably FIXME
6226 return;
6227 MoveRecordcxx . . $ MoveRecord# * move = new MoveRecordcxx . . $ MoveRecord#();
6228 move->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::REQUESTUNDOcxx . . $ MoveRecord#REQUESTUNDO.;
6229 move->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
6230 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(move);
6231 delete move;
6232 //sendEndgameMsg(game, refuse_undo_request);
6233 return;
6234 }
6235 else if(msg[33] == 0xc2)
6236 {
6237 if(encoded_name !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6238 return;
6239 if(msg[32] == 0x00)
6240 {
6241 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 refused undo.").argcxx . . $ QString#arg(bc823072288cbbb5).(
6242 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6243 return;
6244 }
6245 else
6246 {
6247 /*MoveRecord * move = new MoveRecord();
6248 move->flags = MoveRecord::UNDO;
6249 move->number = NOMOVENUMBER;
6250 boarddispatch->recvMove(move);
6251 delete move;*/
6252 /* There's a WIT move message that triggers the UNDO */
6253 return;
6254 }
6255 }
6256 else if(msg[33] == 0xc3) //this is a pre-pass request count
6257 {
6258 if(encoded_name !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6259 return; //awkward, should be consistent but we check it below
6260 //actually 066a is the request
6261 //boarddispatch->recvKibitz(QString(), QString("%1 requests count...").arg(
6262 // (encoded_name == game->black_name ? game->white_name : game->black_name)));
6263 /*if(encoded_name == getUsername())
6264 boarddispatch->recvRequestCount();*/
6265 /* FIXME, I've come to believe this is a draw request or
6266 * less likely, an adjournment request */
6267 boarddispatch->recvRequestDrawcxx . . $ BoardDispatch#recvRequestDraw(49f6e7a06ebc5aa8).();
6268 }
6269 else if(msg[33] == 0xc4)
6270 {
6271 /* Shouldn't this be the opposite? Since the message is meant
6272 * for us?!? i.e., encoded_name != FIXME*/
6273 if(encoded_name !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6274 return; //awkward, should be consistent but we check it below
6275 if(msg[32] == 0x01)
6276 {
6277 /* FIXME maybe all these sorts of messages should be on the boarddispatch.
6278 * only issue is making sure we get the player name right but maybe we should rewrite
6279 * in a more generic way */
6280 /*boarddispatch->recvKibitz(QString(), QString("%1 has accepted count request...").arg(
6281 (encoded_name == game->black_name ? game->white_name : game->black_name)));
6282 if(encoded_name == getUsername())
6283 boarddispatch->recvAcceptCountRequest();*/
6284 //we also get this ?!?
6285 //we need to do a real count I think
6286 //because we're not getting the count request from opponent for
6287 //whatever reason, possibly button isn't working on eweiqi client
6288 //but anyway, I've wasted enough time on this tonight FIXME
6289 //0x067b: 009100010000000000000000000000000000000000000000000000000000000000cc000000000000
6290 //0x0674: 00910101
6291 boarddispatch->recvAcceptDrawRequestcxx . . $ BoardDispatch#recvAcceptDrawRequest(49f6e7a06ebc5aa8).();
6292 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
6293 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::DRAWcxx . . $ GameResult#DRAW.;
6294 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
6295 sendLongMatchResultcxx . . $ TygemConnection#sendLongMatchResult(ed53e3bbd3fa2f69).(game_number);
6296 }
6297 else
6298 {
6299 /*boarddispatch->recvKibitz(QString(), QString("%1 has rejected count request...").arg(
6300 (encoded_name == game->black_name ? game->white_name : game->black_name)));
6301 if(encoded_name == getUsername())
6302 boarddispatch->recvRejectCountRequest();*/
6303 boarddispatch->recvRefuseDrawRequestcxx . . $ BoardDispatch#recvRefuseDrawRequest(49f6e7a06ebc5aa8).();
6304 }
6305 }
6306 else if(msg[33] == 0xc5)
6307 {
6308 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 has hit done...").argcxx . . $ QString#arg(bc823072288cbbb5).(
6309 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6310 // if we've already hit done, we need to popup a countdialog
6311 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
6312 {
6313 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6314 {
6315 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sentDoneCountingcxx . . $ MatchNegotiationState#sentDoneCounting(c9857a73d68e59ba).())
6316 boarddispatch->createCountDialogcxx . . $ BoardDispatch#createCountDialog(49f6e7a06ebc5aa8).();
6317 else
6318 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->receiveDoneCountingcxx . . $ MatchNegotiationState#receiveDoneCounting(49f6e7a06ebc5aa8).();
6319 }
6320 else //can we get this more than once for some reason? duplicate count dialogs? FIXME
6321 {
6322 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->receivedDoneCountingcxx . . $ MatchNegotiationState#receivedDoneCounting(c9857a73d68e59ba).())
6323 boarddispatch->createCountDialogcxx . . $ BoardDispatch#createCountDialog(49f6e7a06ebc5aa8).();
6324 else
6325 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendDoneCountingcxx . . $ MatchNegotiationState#sendDoneCounting(49f6e7a06ebc5aa8).();
6326 }
6327 }
6328 }
6329 else if(msg[33] == 0xc6)
6330 {
6331 /* Its not entirely standard to have our reject/accept sends
6332 * set those flags without response from server. But alternative
6333 * is to complicate recvRejectCount with who is sending it.
6334 * Note that presumably we don't bring up a CountDialog for games
6335 * we're observing, but if we need to leave score mode during
6336 * observed game, ... well we probably need to handle that from
6337 * DSCs and REMs or some other 7b or time message or the like.
6338 * We really haven't dealt with score rejection protocol yet
6339 * FIXME */
6340 if(msg[32] == 0x00)
6341 {
6342 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 rejects result").argcxx . . $ QString#arg(bc823072288cbbb5).(
6343 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6344 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) //i.e., meant for us
6345 {
6346 /* FIXME: We don't need to send this if sendRejectCount already sent it or vice
6347 * versa. FIXME */
6348 boarddispatch->recvRejectCountcxx . . $ BoardDispatch#recvRejectCount(49f6e7a06ebc5aa8).();
6349 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#(); //here? FIXME
6350 //aMove->color = stoneErase;
6351 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE.;
6352 sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(game_number, aMove);
6353 delete aMove;
6354 /* I think tygem is updated so you can no longer mark dead stones, maybe
6355 * so it just does the score and tells you and you can reject it if you want
6356 * but I'm not sure what that does. So I'm altering this and the accept
6357 * below for now since its a pain to get the score thing totally right
6358 * right now ... but obviously I should. */
6359 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->startMatchcxx . . $ MatchNegotiationState#startMatch(49f6e7a06ebc5aa8).(); //reset passes
6360 }
6361 }
6362 else //if(msg[36] == 0x01)
6363 {
6364 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 accepts result").argcxx . . $ QString#arg(bc823072288cbbb5).(
6365 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6366 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) //i.e., meant for us
6367 {
6368 boarddispatch->recvAcceptCountcxx . . $ BoardDispatch#recvAcceptCount(49f6e7a06ebc5aa8).();
6369 }
6370 }
6371 }
6372 else if(msg[33] == 0xf0)
6373 {
6374 /* Both players get this, presumably on a restarted game, note that there aren't necessarily
6375 * any names in it:
6376 * 002c 067b 000b 0101
6377 * 0000 0000 0000 0000 0000 0000 0000 0000
6378 * 0000 0000 0000 0000 0000 0000 01f0 0000
6379 * 0000 0000 */
6380 #ifdef RE_DEBUG
6381 //FIXME do we need to handle these?
6382 printf("Received endgame resume f0\n");
6383 #endif //RE_DEBUG
6384 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentRejoiningcxx . . $ MatchNegotiationState#opponentRejoining(c9857a73d68e59ba).())
6385 {
6386 /* FIXME FIXME Also, we should pop up a window with timer so that if its our turn
6387 * player doesn't suddenly lose on time because opponent dropped. That should postpone
6388 * sending sendOpponentDisconnect with the opponent_reconnect type here (or maybe its after, before UNREMOVE:*/
6389 sendOpponentDisconnectcxx . . $ TygemConnection#sendOpponentDisconnect(89ee62dcaa58bdba).(game_number, opponent_reconnectcxx . . $ TygemConnection#opponent_reconnect.); //pretty sure it gets this, time is updated... maybe
6390 }
6391 }
6392 else if(msg[33] == 0xf1)
6393 {
6394 //opponent_resumes
6395 //0063 0001 7065 7465 7269 7573 0000 0000 0000 0000
6396 //0000 0000 0000 0000 0000 0000 01f1 0c00 031b 0060
6397 //0305 00a0 0201 0000
6398 /* These means, I think, our opponent has seen us
6399 * rejoin... but what's weird is the above is sent
6400 * from peterius to intrusion */
6401 /* And then after we get this:
6402 //0063 0000 696e 7472 7573 696f 6e00 0000 0000 0000
6403 //0000 0000 0000 0000 0000 0000 00f1 0800 031b 0060
6404 //0305 00a0
6405 */
6406 /* Its possible that these are requesting our reply
6407 * they might be sent out to all involved players but
6408 * like they suggest color, that 4th byte, or the byte
6409 * before the 00... again, intrusion dropped and was
6410 * white I think. Its weird to think we just
6411 * echo one of these back though... and they clearly
6412 * have the time also */
6413 //000c 0000 696e 7472 7573 696f 6e00 0000
6414 //0000 0000 0000 0000 0000 0000 0000 0000
6415 //00f1 0800 031b 00a0 010d 0060
6416 /* Looks like 32 is always off for the [34]08 and on for the [34]0c
6417 * the 08 seeming to be the one to respond too... */
6418 /*if(msg[32] == 0x00)
6419 {*/
6420 if(msg[34] == 0x08)
6421 {
6422 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6423 {
6424 sendEndgameMsgcxx . . $ TygemConnection#sendEndgameMsg(2ecea8996989f997).(game, we_resumecxx . . $ TygemConnection#we_resume.);
6425 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
6426 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE.;
6427 sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(game_number, aMove);
6428 delete aMove;
6429 sendResumeFromDisconnectcxx . . $ TygemConnection#sendResumeFromDisconnect(cb2f890c2fdad230).(game_number);
6430 /* FIXME need to set time here, especially for opp but which color is which */
6431 //??
6432 /*enum TimeFlags f = */handleTimeChunkcxx . . $ TygemConnection#handleTimeChunk(6a8d10de6566324a).(boarddispatch, &(msg[36]), !game->white_first_flagcxx . . $ GameData#white_first_flag.);
6433 }
6434 else
6435 {
6436 }
6437 }
6438 /*}
6439 else //if(msg[32] == 0x01)
6440 {
6441
6442 }*/
6443 }
6444 }
6445
6446 void TygemConnectioncxx . . $ TygemConnection#::handleGameStateChangecxx . . $ TygemConnection#handleGameStateChange(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6447 {
6448 //0681 01f7 0201 0305 0340 033b 0280 0100 0000
6449 if(size != 20)
6450 {
6451 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("game state change msg of strange size %d", size);
6452 }
6453 #ifdef RE_DEBUG
6454 printf("0x0681: ");
6455 for(unsigned int i = 0; i < size; i++)
6456 printf("%02x", msg[i]);
6457 printf("\n");
6458 #endif //RE_DEBUG
6459 unsigned short game_number = (msg[0] << 8) + msg[1];
6460 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6461 if(!boarddispatch)
6462 {
6463 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unexpected: got 0681 for board %d", game_number);
6464 return;
6465 }
6466
6467 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentRejoiningcxx . . $ MatchNegotiationState#opponentRejoining(c9857a73d68e59ba).())
6468 {
6469 //pretty sure this is where we popup the dialog
6470
6471 /* -- allows our time to start again, but they can't play
6472 * nothing and -=2 don't have our time start */
6473 //move_message_number_ack--; //who knows?!?! only when they drop during our turn?
6474 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
6475 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNREMOVEcxx . . $ MoveRecord#UNREMOVE.;
6476 aMove->colorcxx . . $ MoveRecord#color. = stoneErasecxx . . $ stoneErase.; //flip the colors, FIXME check for other UNREMOVE sends
6477 sendMovecxx . . $ TygemConnection#sendMove(74f2a753311a2adf).(game_number, aMove);
6478 delete aMove;
6479 //move_message_number_ack++;
6480
6481 //match_negotiation_state->opponentRejoins();
6482 sendResumeFromDisconnectcxx . . $ TygemConnection#sendResumeFromDisconnect(cb2f890c2fdad230).(game_number);
6483
6484 /* We have to wait here for them to hit okay. FIXME */
6485 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentReconnectcxx . . $ MatchNegotiationState#opponentReconnect(49f6e7a06ebc5aa8).(); //just startMatch
6486 boarddispatch->startTimecxx . . $ BoardDispatch#startTime(49f6e7a06ebc5aa8).();
6487 //if((boarddispatch->getBlackTurn() && gameData->black_name == getUsername()) ||
6488 // (!boarddispatch->getBlackTurn() && gameData->white_name == getUsername()))
6489 QStringcxx . . $ QString# qcxx . . $ QString#QString(ced63f7c635d850d).;
6490 boarddispatch->moveControlcxx . . $ BoardDispatch#moveControl(4c89b026053e4d32).(q); //whos turn is it FIXME
6491 /* When we accept invite, and they drop and rejoin, this doesn't work FIXME
6492 * also, as white, our time got reset to full for some reason, but that might have been
6493 * from when we dropped to test it. */
6494 }
6495 }
6496
6497 /* This has been removed I think. If its still possible, it has to be flagged in the match settings
6498 * somewhere */
6499 void TygemConnectioncxx . . $ TygemConnection#::handleCountRequestcxx . . $ TygemConnection#handleCountRequest(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6500 {
6501 unsigned char * p = msg;
6502 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6503 GameDatacxx . . $ GameData# * game;
6504 unsigned short game_number;
6505 unsigned char name[15];
6506 name[14] = 0x00;
6507 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d).;
6508 if(size != 40)
6509 {
6510 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Count request of strange size: %d", size);
6511 }
6512 //0x066a
6513 //030a 0001 696e 7472 7573 696f 6e00 0000 0000 0009
6514 //696e 7472 7573 696f 6e00 0002 0000 0000 0000 0000
6515 //0x066b: 00da0001c6f7bcbcc0ccb5b700000000000000166d696e676d696e67303100000100000000000000
6516
6517 game_number = (msg[0] << 8) + msg[1];
6518 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6519 if(!boarddispatch)
6520 {
6521 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unexpected: got 066a for board %d", game_number);
6522 return;
6523 }
6524 game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
6525 #ifdef RE_DEBUG
6526 printf("***** 0x066a: ");
6527 for(unsigned int i = 0; i < size; i++)
6528 printf("%02x", msg[i]);
6529 printf("\n");
6530 #endif //RE_DEBUG
6531
6532 p += 2;
6533 p += 2;
6534 //this is name for not the player who hit done
6535 strncpy((char *)name, (char *)p, 14);
6536 p += 16;
6537 strncpy((char *)name, (char *)p, 11);
6538 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
6539 /*player = getDefaultroom->getPlayerListing(encoded_name);
6540 if(!player)
6541 {
6542 qDebug("Can't get player listing for %s in 067b", encoded_name.toLatin1().constData());
6543 return;
6544 }*/
6545 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 requests count...").argcxx . . $ QString#arg(bc823072288cbbb5).(
6546 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6547 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6548 boarddispatch->recvRequestCountcxx . . $ BoardDispatch#recvRequestCount(49f6e7a06ebc5aa8).();
6549 }
6550
6551 void TygemConnectioncxx . . $ TygemConnection#::handleCountRequestResponsecxx . . $ TygemConnection#handleCountRequestResponse(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6552 {
6553 unsigned char * p = msg;
6554 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6555 GameDatacxx . . $ GameData# * game;
6556 unsigned short game_number;
6557 unsigned char name[15];
6558 name[14] = 0x00;
6559 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d).;
6560 if(size != 0x24) //eweiqi 40 FIXME, 40 on tygem as well
6561 {
6562 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Count request response of strange size: %d", size);
6563 }
6564 //0x066a
6565 //030a 0001 696e 7472 7573 696f 6e00 0000 0000 0009
6566 //696e 7472 7573 696f 6e00 0002 0000 0000 0000 0000
6567 //0x066b: 00da 0001 c6f7 bcbc c0cc b5b7 0000 0000
6568 //0000 0016 6d69 6e67 6d69 6e67 3031 0000
6569 //0100 0000 0000 0000
6570
6571 game_number = (msg[0] << 8) + msg[1];
6572 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6573 if(!boarddispatch)
6574 {
6575 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unexpected: got 066b for board %d", game_number);
6576 return;
6577 }
6578 game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
6579 #ifdef RE_DEBUG
6580 printf("***** 0x066b: ");
6581 for(unsigned int i = 0; i < size; i++)
6582 printf("%02x", msg[i]);
6583 printf("\n");
6584 #endif //RE_DEBUG
6585
6586 p += 2;
6587 p += 2;
6588 //this is name for not the player who hit done
6589 strncpy((char *)name, (char *)p, 14);
6590 p += 16;
6591 strncpy((char *)name, (char *)p, 11);
6592 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
6593 /*player = getDefaultroom->getPlayerListing(encoded_name);
6594 if(!player)
6595 {
6596 qDebug("Can't get player listing for %s in 067b", encoded_name.toLatin1().constData());
6597 return;
6598 }*/
6599 if(msg[32] == 0x01)
6600 {
6601 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 has accepted count request...").argcxx . . $ QString#arg(bc823072288cbbb5).(
6602 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6603 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6604 boarddispatch->recvAcceptCountRequestcxx . . $ BoardDispatch#recvAcceptCountRequest(49f6e7a06ebc5aa8).();
6605 else
6606 {
6607 boarddispatch->recvEnterScoreModecxx . . $ BoardDispatch#recvEnterScoreMode(49f6e7a06ebc5aa8).();
6608 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->enterScoreModecxx . . $ MatchNegotiationState#enterScoreMode(49f6e7a06ebc5aa8).();
6609 }
6610 }
6611 else
6612 {
6613 boarddispatch->recvKibitzcxx . . $ BoardDispatch#recvKibitz(3458fe3960d5051).(QStringcxx . . $ QString#QString(ced63f7c635d850d).(), QStringcxx . . $ QString#QString(85c52e162fed56f9).("%1 has rejected count request...").argcxx . . $ QString#arg(bc823072288cbbb5).(
6614 (encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). game->black_namecxx . . $ GameData#black_name. ? game->white_namecxx . . $ GameData#white_name. : game->black_namecxx . . $ GameData#black_name.)));
6615 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6616 {
6617 boarddispatch->recvRejectCountRequestcxx . . $ BoardDispatch#recvRejectCountRequest(49f6e7a06ebc5aa8).();
6618 }
6619 }
6620 }
6621
6622 void TygemConnectioncxx . . $ TygemConnection#::handleTimecxx . . $ TygemConnection#handleTime(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6623 {
6624 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6625 unsigned char * p = msg;
6626 GameDatacxx . . $ GameData# * gr;
6627 unsigned short game_number = (p[0] << 8) + p[1];
6628 bool player_is_black;
6629 if(size != 12)
6630 {
6631 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("time message of size: %d\n", size);
6632 //FIXME
6633 }
6634 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6635 if(!boarddispatch)
6636 {
6637 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for %02x%02x", p[0], p[1]);
6638 return;
6639 }
6640 gr = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
6641 if(!gr)
6642 {
6643 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get game record for board: %d", game_number);
6644 return;
6645 }
6646 #ifdef RE_DEBUG
6647 //#ifdef NOISY_DEBUG
6648 printf("TIME: ");
6649 for(unsigned int i = 0; i < size; i++)
6650 printf("%02x", p[i]);
6651 printf("\n");
6652 //#endif //NOISY_DEBUG
6653 #endif //RE_DEBUG
6654
6655 p += 2;
6656 // this gets reversed
6657 player_is_black = p[0] ^ gr->white_first_flagcxx . . $ GameData#white_first_flag.;
6658 p += 2;
6659 enum TimeFlagscxx . . $ TygemConnection#TimeFlags# f = handleTimeChunkcxx . . $ TygemConnection#handleTimeChunk(6a8d10de6566324a).(boarddispatch, p, player_is_black);
6660 /* double check the below */
6661 if(f == BLACK_LOSEScxx . . $ TygemConnection#BLACK_LOSES. && gr->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6662 {
6663 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
6664 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.;
6665 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneWhitecxx . . $ stoneWhite.;
6666 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gr->white_namecxx . . $ GameData#white_name.;
6667 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gr->black_namecxx . . $ GameData#black_name.;
6668 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
6669 sendResultcxx . . $ TygemConnection#sendResult(f9859626c725809).(gr, &aGameResult);
6670 }
6671 else if(f == WHITE_LOSEScxx . . $ TygemConnection#WHITE_LOSES. && gr->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6672 {
6673 GameResultcxx . . $ GameResult# aGameResultcxx . . $ GameResult#GameResult(49f6e7a06ebc5aa8).;
6674 aGameResult.resultcxx . . $ GameResult#result. = GameResultcxx . . $ GameResult#::TIMEcxx . . $ GameResult#TIME.;
6675 aGameResult.winner_colorcxx . . $ GameResult#winner_color. = stoneBlackcxx . . $ stoneBlack.;
6676 aGameResult.winner_namecxx . . $ GameResult#winner_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gr->black_namecxx . . $ GameData#black_name.;
6677 aGameResult.loser_namecxx . . $ GameResult#loser_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). gr->white_namecxx . . $ GameData#white_name.;
6678 boarddispatch->recvResultcxx . . $ BoardDispatch#recvResult(c72a8b5aed169521).(&aGameResult);
6679 sendResultcxx . . $ TygemConnection#sendResult(f9859626c725809).(gr, &aGameResult);
6680 }
6681 }
6682
6683 enum TygemConnectioncxx . . $ TygemConnection#::TimeFlagscxx . . $ TygemConnection#TimeFlags# TygemConnectioncxx . . $ TygemConnection#::handleTimeChunkcxx . . $ TygemConnection#handleTimeChunk(6a8d10de6566324a).(BoardDispatchcxx . . $ BoardDispatch# * boarddispatch, unsigned char chunk[8], bool black_first)
6684 {
6685 unsigned char c_periods, o_periods;
6686 unsigned char c_flags, o_flags;
6687 unsigned int c_seconds, o_seconds;
6688 int white_seconds, white_periods;
6689 int black_seconds, black_periods;
6690 bool black_loses_on_time = false, white_loses_on_time = false;
6691
6692 /* Since we send time, we block it if its from us */
6693 if(black_first && boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).()->black_namecxx . . $ GameData#black_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6694 return GAME_ONcxx . . $ TygemConnection#GAME_ON.;
6695 if(!black_first && boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).()->white_namecxx . . $ GameData#white_name. ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
6696 return GAME_ONcxx . . $ TygemConnection#GAME_ON.;
6697 /* shouldn't we really be recving this time
6698 * to sync with server lag? maybe FIXME*/
6699
6700 //first four are this current players turn
6701 c_periods = chunk[0];
6702 c_seconds = chunk[1] + (chunk[2] * 60);
6703 c_flags = chunk[3];
6704 //second four are other player
6705 o_periods = chunk[4];
6706 o_seconds = chunk[5] + (chunk[6] * 60);
6707 o_flags = chunk[7];
6708 if(black_first)
6709 {
6710 black_seconds = c_seconds;
6711 white_seconds = o_seconds;
6712 if(c_flags & 0x20)
6713 black_periods = c_periods;
6714 else
6715 black_periods = -1;
6716 //if(c_flags & 0x80 && black_periods == 0)
6717 if(black_periods == 0 && black_seconds == 0)
6718 black_loses_on_time = true;
6719 if(o_flags & 0x20)
6720 white_periods = o_periods;
6721 else
6722 white_periods = -1;
6723 //if(o_flags & 0x80 && white_periods == 0)
6724 if(white_periods == 0 && white_seconds == 0)
6725 white_loses_on_time = true;
6726 }
6727 else
6728 {
6729 black_seconds = o_seconds;
6730 white_seconds = c_seconds;
6731 if(c_flags & 0x20)
6732 white_periods = c_periods;
6733 else
6734 white_periods = -1;
6735 //if(c_flags & 0x80 && white_periods == 0)
6736 if(white_periods == 0 && white_seconds == 0)
6737 white_loses_on_time = true;
6738 if(o_flags & 0x20)
6739 black_periods = o_periods;
6740 else
6741 black_periods = -1;
6742 //if(o_flags & 0x80 && black_periods == 0)
6743 if(black_periods == 0 && black_seconds == 0)
6744 black_loses_on_time = true;
6745 }
6746
6747 /*
6748 if(boarddispatch->getGameData()->black_name == getUsername())
6749 black_seconds = 0;
6750 if(boarddispatch->getGameData()->white_name == getUsername())
6751 white_seconds = 0;*/
6752
6753 /* We should most likely kill the timer then... */
6754 boarddispatch->recvTimecxx . . $ BoardDispatch#recvTime(63f8d2dcefae8817).(TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(white_seconds, white_periods), TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(black_seconds, black_periods));
6755 if(black_loses_on_time)
6756 return BLACK_LOSEScxx . . $ TygemConnection#BLACK_LOSES.;
6757 else if(white_loses_on_time)
6758 return WHITE_LOSEScxx . . $ TygemConnection#WHITE_LOSES.;
6759 return GAME_ONcxx . . $ TygemConnection#GAME_ON.;
6760 }
6761
6762 /* FIXME disturbing implication. When we were sending the moves one off,
6763 * it would draw them on the place we clicked, but then draw the last move
6764 * on the place we got back. This indicates inconsistencies in move
6765 * placement code, serious issue */
6766 /* FIXME Consider adding code to actually filter out by the move message
6767 * number per game in case that's a kind of prevention against replays
6768 * or something. */
6769 /* FIXME When resuming a game "Opp sends bad move message number" comes up
6770 * repeatedly because we're passed all the moves at once and sends none of
6771 * them. bad move message number stuff needs to be fixed up somehow anyway. */
6772 //0668
6773 void TygemConnectioncxx . . $ TygemConnection#::handleMovecxx . . $ TygemConnection#handleMove(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
6774 {
6775 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
6776 unsigned char * p = msg;
6777 GameDatacxx . . $ GameData# * gr;
6778 int x, y;
6779 unsigned short game_number = (p[0] << 8) + p[1];
6780 int player_number, player_number2, number0;
6781 bool opponents_move = false;
6782 if(size < 24) //FIXME
6783 {
6784 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad move msg, size: %d", size);
6785 return;
6786 }
6787 #ifdef RE_DEBUG
6788 printf("Move msg:\n");
6789 for(unsigned int i = 0; i < size; i++)
6790 printf("%02x ", p[i]);
6791 printf("\n");
6792 #endif //RE_DEBUG
6793 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
6794 if(!boarddispatch)
6795 {
6796 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for %02x%02x", p[0], p[1]);
6797 return;
6798 }
6799 gr = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
6800 if(!gr)
6801 {
6802 //FIXME
6803 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Shouldn't be a board dispatch here\n");
6804 return;
6805 }
6806 p += 2;
6807
6808 if(p[0] == 0x00) //from inviter
6809 player_number2 = 0;
6810 else if(p[0] == 0x01) //from invitee
6811 player_number2 = 1;
6812 else
6813 {
6814 player_number2 = -1;
6815 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Strange invitation byte in move");
6816 }
6817 #ifdef RE_DEBUG
6818 printf("%02x vs %02x!!\n", p[0], gr->our_invitation);
6819 #endif //RE_DEBUG
6820 //00 00 their invitation, their move
6821 //01 00 their invitation our move
6822 //00 01 02 after a possible screw up, their invitation, they rejoin
6823 p += 2;
6824 p += 4; //ffff ffff
6825 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOngoingMatchcxx . . $ MatchNegotiationState#isOngoingMatch(3c978dac0e5ee2ad).(game_number) || match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentRejoiningcxx . . $ MatchNegotiationState#opponentRejoining(c9857a73d68e59ba).())
6826 {
6827 if(player_number2 == gr->our_invitationcxx . . $ GameData#our_invitation.)
6828 opponents_move = true;
6829 else
6830 {
6831 //FIXME trying this assuming that its a rejoin and these are our moves we're getting:
6832 //likely still off depending on who goes first
6833 /* Doesn't work because we need to weed out DSC (UNREMOVE), etc. */
6834 //move_message_number = (p[0] << 8) + p[1];
6835 }
6836 }
6837 p += 4;
6838 //move msg number is also around here too
6839 //STO 0 move_number player_number x y 0a
6840 //SUR 0 move_number player_number 0a
6841 //REM 0 312 -1 -1 0 1
6842 //REM 0 307 5 6 1 0
6843 //REM 0 306 10 14 2 0 un remove?
6844 //REM 0 number x y player_number 0
6845 //DSC 1 0 1 //dead stone clear
6846 //DSC 1 0 2
6847 //SKI 0 player_number //skip? pass?
6848
6849 //BAC 0 246 1 //part of review
6850 //CSP 0 233 0 //possibly something to do with sscoring (This might start the review) actually i think it resets it
6851 //CST 0 234 //this might start placing the new stones (CSP and CST are opposites)
6852 //FOR 0 186 1
6853 //CRE 0 119 //maybe resets the board to the game, or just the tree.
6854 // END 0 119 //end review?
6855
6856 // don't know, something on pro broadcast
6857 //WIT 0 8 2
6858 //WIT 0 9 1
6859 //WIT 0 10 2
6860 //WIT 0 11 1
6861 //WIT 0 12 2
6862 #ifdef RE_DEBUG
6863 printf("%d %s\n", player_number2, (char *)p);
6864 #endif //RE_DEBUG
6865 if(strncmp((char *)p, "STO ", 4) == 0)
6866 {
6867 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
6868 p += 4;
6869 if(sscanf((char *)p, "%d %d %d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &player_number, &aMove->xcxx . . $ MoveRecord#x., &aMove->ycxx . . $ MoveRecord#y.) != 5)
6870 {
6871 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad Move");
6872 delete aMove;
6873 return;
6874 }
6875 /* The move message number is just that, it doesn't have to
6876 * have anything to do with the move number. Also, we FIXME
6877 * can't use a global in case we're watching multiple games? */
6878 if(opponents_move)
6879 {
6880 if(aMove->numbercxx . . $ MoveRecord#number. != (unsigned)move_message_numbercxx . . $ TygemConnection#move_message_number. + 1)
6881 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opp sends bad move message number: %d", aMove->numbercxx . . $ MoveRecord#number.);
6882 move_message_numbercxx . . $ TygemConnection#move_message_number. = aMove->numbercxx . . $ MoveRecord#number.;
6883 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = aMove->numbercxx . . $ MoveRecord#number.;
6884 }
6885 //aMove->number = move_message_number;
6886 //aMove->number--; //first move is... handicap?
6887 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
6888 aMove->xcxx . . $ MoveRecord#x.++;
6889 aMove->ycxx . . $ MoveRecord#y.++;
6890 if(player_number == 1)
6891 aMove->colorcxx . . $ MoveRecord#color. = stoneBlackcxx . . $ stoneBlack.;
6892 else if(player_number == 2)
6893 aMove->colorcxx . . $ MoveRecord#color. = stoneWhitecxx . . $ stoneWhite.;
6894 else
6895 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Strange player number: %d", player_number);
6896 if(number0 != 0)
6897 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Number0 = %d\n", number0);
6898 //if(aMove->x == 0 || aMove->y == 0) //doubt it FIXME
6899 // aMove->flags = MoveRecord::PASS;
6900 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
6901 delete aMove;
6902 }
6903 else if(strncmp((char *)p, "SKI ", 4) == 0)
6904 {
6905 p += 4;
6906 int move_number;
6907 if(sscanf((char *)p, "%d %d %d", &number0, &move_number, &player_number) != 2)
6908 {
6909 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad skip message");
6910 return;
6911 }
6912 if(opponents_move)
6913 {
6914 if(move_number != (int)(move_message_numbercxx . . $ TygemConnection#move_message_number. + 1))
6915 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opp sends bad move message number: %d", move_number);
6916 move_message_numbercxx . . $ TygemConnection#move_message_number. = move_number;
6917 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = move_number;
6918 }
6919 #ifdef RE_DEBUG
6920 boarddispatch->recvKibitz(QString(), "SKI");
6921 #endif //RE_DEBUG
6922 }
6923 else if(strncmp((char *)p, "SUR ", 4) == 0)
6924 {
6925 p += 4;
6926 int move_number;
6927 if(sscanf((char *)p, "%d %d %d", &number0, &move_number, &player_number) != 3)
6928 {
6929 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad resign message");
6930 return;
6931 }
6932 if(opponents_move)
6933 {
6934 if(move_number != move_message_numbercxx . . $ TygemConnection#move_message_number. + 1)
6935 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opp sends bad move message number: %d", move_number);
6936 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = move_number; //necessary? FIXME
6937 }
6938 /* If opponent resigns, we act on the 0670 we receive */
6939 }
6940 else if(strncmp((char *)p, "REM ", 4) == 0)
6941 {
6942 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
6943 /* FIXME, fix potential bug with unremoving as on cyberoro ?!?? */
6944 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::REMOVE_AREAcxx . . $ MoveRecord#REMOVE_AREA.;
6945 int remove_flag;
6946 p += 4;
6947 if(sscanf((char *)p, "%d %d %d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &x, &y, &remove_flag) != 5)
6948 {
6949 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad Move");
6950 delete aMove;
6951 return;
6952 }
6953 if(opponents_move)
6954 {
6955 if(aMove->numbercxx . . $ MoveRecord#number. != (unsigned)move_message_numbercxx . . $ TygemConnection#move_message_number. + 1)
6956 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opp sends bad move message number: %d", aMove->numbercxx . . $ MoveRecord#number.);
6957 move_message_numbercxx . . $ TygemConnection#move_message_number. = aMove->numbercxx . . $ MoveRecord#number.;
6958 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = aMove->numbercxx . . $ MoveRecord#number.;
6959 }
6960 if(x == -1 && y == -1)
6961 {
6962 #ifdef RE_DEBUG
6963 boarddispatch->recvKibitz(QString(), "REM -1 -1");
6964 #endif //RE_DEBUG
6965 /* We also get this on a resume and send it as well */
6966 //done scoring! recvKibitz, etc.
6967 //seems to be only one of these
6968 //no, I see two
6969 delete aMove;
6970 return;
6971 }
6972 aMove->xcxx . . $ MoveRecord#x. = x + 1;
6973 aMove->ycxx . . $ MoveRecord#y. = y + 1;
6974 aMove->numbercxx . . $ MoveRecord#number.--;
6975 /*if(player_number == 1)
6976 aMove->color = stoneBlack;
6977 else if(player_number == 2)
6978 aMove->color = stoneWhite;
6979 else
6980 qDebug("Strange player number: %d", player_number);*/
6981 if(number0 != 0)
6982 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Number0 = %d\n", number0);
6983 //if(aMove->x == 0 || aMove->y == 0) //doubt it FIXME
6984 // aMove->flags = MoveRecord::PASS;
6985 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
6986 delete aMove;
6987 }
6988 else if(strncmp((char *)p, "DSC ", 4) == 0)
6989 {
6990 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
6991 /* FIXME, fix potential bug with unremoving as on cyberoro ?!?? */
6992 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNREMOVE_AREAcxx . . $ MoveRecord#UNREMOVE_AREA.;
6993 int number2;
6994 p += 4;
6995 if(sscanf((char *)p, "%d %d %d", &number0, &number2, &player_number) != 3)
6996 {
6997 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad Move");
6998 delete aMove;
6999 return;
7000 }
7001 if(player_number == 2)
7002 aMove->colorcxx . . $ MoveRecord#color. = stoneWhitecxx . . $ stoneWhite.;
7003 else
7004 aMove->colorcxx . . $ MoveRecord#color. = stoneBlackcxx . . $ stoneBlack.;
7005 /* This is disgusting FIXME we need to figure out what the move_message_number s are
7006 * supposed to be. The thing here is that the DSC one seems to expect the next one
7007 * but not be the next one, meaning we can't just set it here on our previous move
7008 * but then I guess it shifts the opponents off too... I just need to think about it */
7009 /* FIXME FIXME */
7010 //if(match_negotiation_state->isOngoingMatch(game_number) && !opponents_move)
7011 // move_message_number--;
7012 /*if(player_number == 1)
7013 aMove->color = stoneBlack;
7014 else if(player_number == 2)
7015 aMove->color = stoneWhite;
7016 else
7017 qDebug("Strange player number: %d", player_number);*/
7018 //1 DSC 1 0 1
7019 if(number0 != 1)
7020 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Number1 = %d\n", number0); //???
7021 //if(aMove->x == 0 || aMove->y == 0) //doubt it FIXME
7022 // aMove->flags = MoveRecord::PASS;
7023 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7024 delete aMove;
7025 if(opponents_move && match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->opponentRejoiningcxx . . $ MatchNegotiationState#opponentRejoining(c9857a73d68e59ba).())
7026 {
7027 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("so we were getting here after all");
7028 //have to get this if we're rejoining, BEFORE we start playing again FIXME
7029 //or we could start playing on 0x68e
7030 }
7031 }
7032 else if(strncmp((char *)p, "WIT ", 4) == 0)
7033 {
7034 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7035 /* WIT looks like a kind of review undo (withdraw?), player_number here is
7036 * who's turn it now is.*/
7037 p += 4;
7038 if(sscanf((char *)p, "%d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &player_number) != 3)
7039 {
7040 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad WIT move");
7041 delete aMove;
7042 return;
7043 }
7044 if(opponents_move)
7045 {
7046 //can this even happen?
7047 if(aMove->numbercxx . . $ MoveRecord#number. != (unsigned)move_message_numbercxx . . $ TygemConnection#move_message_number. + 1)
7048 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Opp sends bad move message number: %d", aMove->numbercxx . . $ MoveRecord#number.);
7049 move_message_numbercxx . . $ TygemConnection#move_message_number. = aMove->numbercxx . . $ MoveRecord#number.;
7050 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = aMove->numbercxx . . $ MoveRecord#number.;
7051 }
7052
7053 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7054 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::UNDOcxx . . $ MoveRecord#UNDO.;
7055 if(player_number == 2)
7056 aMove->colorcxx . . $ MoveRecord#color. = stoneBlackcxx . . $ stoneBlack.;
7057 else
7058 aMove->colorcxx . . $ MoveRecord#color. = stoneWhitecxx . . $ stoneWhite.;
7059 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7060 delete aMove;
7061 }
7062 else if(strncmp((char *)p, "BAC ", 4) == 0)
7063 {
7064 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7065 int moves_to_move;
7066 /* I assume this is backup, or go back to a particular point. I'm not quite sure
7067 * what to do with it right now, since currently observer can look at any move.
7068 * but quite likely it just sets the move to something. */
7069 /* Can go back and forward 1 to 5 */
7070 p += 4;
7071 if(sscanf((char *)p, "%d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &moves_to_move) != 3)
7072 {
7073 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad BAC move");
7074 delete aMove;
7075 return;
7076 }
7077 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::BACKWARDcxx . . $ MoveRecord#BACKWARD.;
7078 aMove->numbercxx . . $ MoveRecord#number. = moves_to_move;
7079 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("BAC msg %d %d", aMove->numbercxx . . $ MoveRecord#number., moves_to_move);
7080 /*if(opponents_move)
7081 {
7082 //can this even happen?
7083 if(aMove->number != (unsigned)move_message_number + 1)
7084 qDebug("Opp sends bad move message number: %d", aMove->number);
7085 move_message_number = aMove->number;
7086 move_message_number_ack = aMove->number;
7087 }*/
7088 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7089 delete aMove;
7090 }
7091 else if(strncmp((char *)p, "FOR ", 4) == 0)
7092 {
7093 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7094 int moves_to_move;
7095 p += 4;
7096 if(sscanf((char *)p, "%d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &moves_to_move) != 3)
7097 {
7098 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad FOR move");
7099 delete aMove;
7100 return;
7101 }
7102 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::FORWARDcxx . . $ MoveRecord#FORWARD.;
7103 aMove->numbercxx . . $ MoveRecord#number. = moves_to_move;
7104 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("FOR msg %d %d", aMove->numbercxx . . $ MoveRecord#number., moves_to_move);
7105 /*if(opponents_move)
7106 {
7107 //can this even happen?
7108 if(aMove->number != (unsigned)move_message_number + 1)
7109 qDebug("Opp sends bad move message number: %d", aMove->number);
7110 move_message_number = aMove->number;
7111 move_message_number_ack = aMove->number;
7112 }*/
7113 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7114 delete aMove;
7115 }
7116 else if(strncmp((char *)p, "CRE ", 4) == 0)
7117 {
7118 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7119 p += 4;
7120 if(sscanf((char *)p, "%d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number.) != 2)
7121 {
7122 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad CRE move");
7123 delete aMove;
7124 return;
7125 }
7126 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::DELETEBRANCHcxx . . $ MoveRecord#DELETEBRANCH.;
7127 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7128 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("CRE msg %d", aMove->numbercxx . . $ MoveRecord#number.);
7129 /*if(opponents_move)
7130 {
7131 //can this even happen?
7132 if(aMove->number != (unsigned)move_message_number + 1)
7133 qDebug("Opp sends bad move message number: %d", aMove->number);
7134 move_message_number = aMove->number;
7135 move_message_number_ack = aMove->number;
7136 }*/
7137 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7138 delete aMove;
7139 }
7140 else if(strncmp((char *)p, "CSP ", 4) == 0)
7141 {
7142 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7143 p += 4;
7144 if(sscanf((char *)p, "%d %d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number., &player_number) != 3)
7145 {
7146 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad CSP move");
7147 delete aMove;
7148 return;
7149 }
7150 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::RESETBRANCHcxx . . $ MoveRecord#RESETBRANCH.;
7151 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7152 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("CSP msg %d %d", aMove->numbercxx . . $ MoveRecord#number., player_number);
7153 /*if(opponents_move)
7154 {
7155 //can this even happen?
7156 if(aMove->number != (unsigned)move_message_number + 1)
7157 qDebug("Opp sends bad move message number: %d", aMove->number);
7158 move_message_number = aMove->number;
7159 move_message_number_ack = aMove->number;
7160 }*/
7161 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7162 boarddispatch->setReviewInVariationcxx . . $ BoardDispatch#setReviewInVariation(b45ddcbc8423892c).(false);
7163 delete aMove;
7164 }
7165 else if(strncmp((char *)p, "CST ", 4) == 0)
7166 {
7167 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7168 p += 4;
7169 if(sscanf((char *)p, "%d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number.) != 2)
7170 {
7171 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad CST move");
7172 delete aMove;
7173 return;
7174 }
7175 //aMove->flags = MoveRecord::FORWARD;
7176 //aMove->number = NOMOVENUMBER;
7177 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("CST msg %d", aMove->numbercxx . . $ MoveRecord#number.);
7178 /*if(opponents_move)
7179 {
7180 //can this even happen?
7181 if(aMove->number != (unsigned)move_message_number + 1)
7182 qDebug("Opp sends bad move message number: %d", aMove->number);
7183 move_message_number = aMove->number;
7184 move_message_number_ack = aMove->number;
7185 }*/
7186 //boarddispatch->recvMove(aMove);
7187 boarddispatch->setReviewInVariationcxx . . $ BoardDispatch#setReviewInVariation(b45ddcbc8423892c).(true);
7188 delete aMove;
7189 }
7190 else if(strncmp((char *)p, "BEG ", 4) == 0)
7191 {
7192 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7193 p += 4;
7194 if(sscanf((char *)p, "%d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number.) != 2)
7195 {
7196 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad BEG move");
7197 delete aMove;
7198 return;
7199 }
7200 if(boarddispatch->getReviewInVariationcxx . . $ BoardDispatch#getReviewInVariation(c9857a73d68e59ba).())
7201 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::RESETBRANCHcxx . . $ MoveRecord#RESETBRANCH.;
7202 else
7203 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::RESETGAMEcxx . . $ MoveRecord#RESETGAME.;
7204 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7205 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("BEG msg %d", aMove->numbercxx . . $ MoveRecord#number.);
7206 /*if(opponents_move)
7207 {
7208 //can this even happen?
7209 if(aMove->number != (unsigned)move_message_number + 1)
7210 qDebug("Opp sends bad move message number: %d", aMove->number);
7211 move_message_number = aMove->number;
7212 move_message_number_ack = aMove->number;
7213 }*/
7214 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7215 delete aMove;
7216 }
7217 else if(strncmp((char *)p, "END ", 4) == 0)
7218 {
7219 MoveRecordcxx . . $ MoveRecord# * aMove = new MoveRecordcxx . . $ MoveRecord#();
7220 p += 4;
7221 if(sscanf((char *)p, "%d %d", &number0, &aMove->numbercxx . . $ MoveRecord#number.) != 2)
7222 {
7223 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad END move");
7224 delete aMove;
7225 return;
7226 }
7227 aMove->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::TOENDcxx . . $ MoveRecord#TOEND.;
7228 aMove->numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7229 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("END msg %d", aMove->numbercxx . . $ MoveRecord#number.);
7230 /*if(opponents_move)
7231 {
7232 //can this even happen?
7233 if(aMove->number != (unsigned)move_message_number + 1)
7234 qDebug("Opp sends bad move message number: %d", aMove->number);
7235 move_message_number = aMove->number;
7236 move_message_number_ack = aMove->number;
7237 }*/
7238 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(aMove);
7239 delete aMove;
7240 }
7241 else
7242 printf("Unknown: %s\n", (char *)p);
7243 }
7244
7245 void TygemConnectioncxx . . $ TygemConnection#::handlePasscxx . . $ TygemConnection#handlePass(24a4435ba77f1dc6).(unsigned char * msg, unsigned int size, int /* FIXME */)
7246 {
7247 if(size != 40) //or 0x24??
7248 {
7249 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Pass msg of strange size: %d", size);
7250 }
7251 unsigned char * p = msg;
7252 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
7253 int game_number = (p[0] << 8) + p[1];
7254 p += 2;
7255 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
7256 if(!boarddispatch)
7257 {
7258 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get board for %d for pass\n", game_number);
7259 return;
7260 }
7261 GameDatacxx . . $ GameData# * game = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
7262 bool white;
7263 /* Don't think so
7264 if(game->our_invitation)
7265 white = !p[0]; //doublecheck
7266 else
7267 white = p[0];*/
7268 p += 2;
7269 unsigned char name[15];
7270 name[14] = 0x00;
7271 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
7272
7273 strncpy((char *)name, (char *)p, 14);
7274 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7275
7276 p += 15;
7277
7278 //rank byte
7279 p++;
7280 strncpy((char *)name, (char *)p, 11);
7281 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7282 p += 10;
7283 p++;
7284 if(encoded_name2 ==cxx . . $ `operator==`(5bc2975d2d751687). game->white_namecxx . . $ GameData#white_name.)
7285 white = false;
7286 else
7287 white = true;
7288 //white = (p[0] != 0x02);
7289 //there's an 02 much later here and that must be... black color?
7290 /* No, this is likely the 02 country code that floats around, 02 meaning
7291 * china. Its just part of the header */
7292 /* Do we do this here or on the handleMove SKI? FIXME
7293 * I think this message is more reliable, but not sure for observed games
7294 * probably here */
7295 MoveRecordcxx . . $ MoveRecord# * move = new MoveRecordcxx . . $ MoveRecord#();
7296 move->flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::PASScxx . . $ MoveRecord#PASS.;
7297 move->colorcxx . . $ MoveRecord#color. = white ? stoneWhitecxx . . $ stoneWhite. : stoneBlackcxx . . $ stoneBlack.;
7298
7299 //boarddispatch->recvKibitz(0, QString(encoded_name) + " passes " + QString::number(move->color));
7300 //not right
7301 //still not right, for instance if we offer the game and play black
7302 //it gets reversed
7303 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(move);
7304 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->incrementPassescxx . . $ MatchNegotiationState#incrementPasses(49f6e7a06ebc5aa8).();
7305 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->twoPassescxx . . $ MatchNegotiationState#twoPasses(c9857a73d68e59ba).())
7306 {
7307 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->enterScoreModecxx . . $ MatchNegotiationState#enterScoreMode(49f6e7a06ebc5aa8).();
7308 /* Change to Tygem has some special score thing, I'd have to look into getting it exactly
7309 * but you can't mark stones dead anymore */
7310 boarddispatch->createCountDialogcxx . . $ BoardDispatch#createCountDialog(49f6e7a06ebc5aa8).();
7311 }
7312 //black
7313 //00870101 6261 696e 6974 6500 0000 0000 0000 00116261696e69746500000000020000000000000000
7314 #ifdef RE_DEBUG
7315 printf("**** 0x0669: ");
7316 for(unsigned int i = 0; i < size; i++)
7317 printf("%02x", msg[i]);
7318 printf("\n");
7319 #endif //RE_DEBUG
7320 }
7321
7322 QStringcxx . . $ QString# TygemConnectioncxx . . $ TygemConnection#::getStatusFromCodecxx . . $ TygemConnection#getStatusFromCode(31cb2f216a834e82).(unsigned char /* FIXME */, QStringcxx . . $ QString# /* FIXME */)
7323 {
7324 return ""cxx . . $ QString#QString(85c52e162fed56f9).;
7325 }
7326
7327 int TygemConnectioncxx . . $ TygemConnection#::compareRankscxx . . $ TygemConnection#compareRanks(cf8c7f074bbf9512).(QStringcxx . . $ QString# rankA, QStringcxx . . $ QString# rankB)
7328 {
7329 if(rankA.containscxx . . $ QString#contains(8cce4688c16f48f3).("p"cxx . . $ QString#QString(85c52e162fed56f9).) && !rankB.containscxx . . $ QString#contains(8cce4688c16f48f3).("p"cxx . . $ QString#QString(85c52e162fed56f9).))
7330 return 1;
7331 if(rankB.containscxx . . $ QString#contains(8cce4688c16f48f3).("p"cxx . . $ QString#QString(85c52e162fed56f9).) && !rankA.containscxx . . $ QString#contains(8cce4688c16f48f3).("p"cxx . . $ QString#QString(85c52e162fed56f9).))
7332 return -1;
7333 if(rankA.containscxx . . $ QString#contains(8cce4688c16f48f3).("d"cxx . . $ QString#QString(85c52e162fed56f9).) && !rankB.containscxx . . $ QString#contains(8cce4688c16f48f3).("d"cxx . . $ QString#QString(85c52e162fed56f9).))
7334 return 1;
7335 if(rankB.containscxx . . $ QString#contains(8cce4688c16f48f3).("d"cxx . . $ QString#QString(85c52e162fed56f9).) && !rankA.containscxx . . $ QString#contains(8cce4688c16f48f3).("d"cxx . . $ QString#QString(85c52e162fed56f9).))
7336 return -1;
7337 if(rankA.containscxx . . $ QString#contains(8cce4688c16f48f3).("k"cxx . . $ QString#QString(85c52e162fed56f9).))
7338 {
7339 QStringcxx . . $ QString# buffer = rankAcxx . . $ QString#QString(132dd6869045752b).;
7340 buffer.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("[pdk]"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).);
7341 int ordinalA = buffer.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
7342 buffer =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
7343 buffer.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("[pdk]"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).);
7344 int ordinalB = buffer.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
7345 if(ordinalA > ordinalB)
7346 return -1;
7347 else if(ordinalA == ordinalB)
7348 return 0;
7349 else
7350 return 1;
7351 }
7352 else
7353 {
7354 QStringcxx . . $ QString# buffer = rankAcxx . . $ QString#QString(132dd6869045752b).;
7355 buffer.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("[pdk]"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).);
7356 int ordinalA = buffer.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
7357 buffer =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
7358 buffer.replacecxx . . $ QString#replace(612862c8abff0ba5).(QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("[pdk]"cxx . . $ QString#QString(85c52e162fed56f9).), ""cxx . . $ QString#QString(85c52e162fed56f9).);
7359 int ordinalB = buffer.toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
7360 if(ordinalA > ordinalB)
7361 return 1;
7362 else if(ordinalA == ordinalB)
7363 return 0;
7364 else
7365 return -1;
7366 }
7367 }
7368
7369 //0639
7370 void TygemConnectioncxx . . $ TygemConnection#::handleBoardOpenedcxx . . $ TygemConnection#handleBoardOpened(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
7371 {
7372 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
7373 unsigned char * p = msg;
7374 GameDatacxx . . $ GameData# * aGameData;
7375 unsigned short game_number;
7376 if(size != 0x30)
7377 {
7378 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("board opened msg of strange size: %d\n", size);
7379 }
7380
7381 game_number = (p[0] << 8) + p[1];
7382 p += 2;
7383
7384 #ifdef RE_DEBUG
7385 printf("0639 match: \n");
7386 for(unsigned int i = 0; i < size; i++)
7387 printf("%02x", msg[i]);
7388 printf("\n");
7389 #endif //RE_DEBUG
7390
7391 //I suspect the below is a passworded private game, though I'm not sure:
7392 //0258 0000 0000 0000 0000 0000 0000 0000
7393 //0000 0015 7368 656e 7368 6938 0065 0002
7394 //0000 0001 0000 0000 00ff 0000 0003 00ff
7395 //that 3 maybe? not sure... not even sure its passworded
7396
7397 //normal game
7398 //0308 0100 b5b6 c7ef d2b9 0000 0000 0000
7399 //0000 001a 6461 6f71 7900 0000 0079 0002
7400 //0000 024f 00df 0000 00ff 0000 0000 0000
7401
7402 //a game we're joining
7403 //0006 0100 696e 7472 7573 696f 6e00 0000
7404 //0000 000a 696e 7472 7573 696f 6e00 0002
7405 //0000 0001 0000 0000 00ff 0000 0000 0000
7406
7407
7408
7409 boarddispatch = getBoardDispatchcxx . . $ NetworkConnection#getBoardDispatch(f34f0704202202).(game_number);
7410 /* We have to pass the game data record on the 0639
7411 * because the boardwindow is created by the dispatch
7412 * upon recv a record. The board window is necessary
7413 * to receive the observers from 0666, 0667 illicited
7414 * by the 0665 message, the 0665 message also illicits
7415 * the 0671 info message. So this is the way it must
7416 * be done */
7417 aGameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
7418 aGameData->numbercxx . . $ GameData#number. = game_number;
7419
7420 /* Its possibly that we're getting this on response to 0638,
7421 * trying to join a game we got disconnected from. In which
7422 * case ... well actually, I think we should get a proper
7423 * debug, something else is screwed up, like player names
7424 * or something FIXME */
7425
7426 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
7427 aGameData->gameModecxx . . $ GameData#gameMode. = modeMatchcxx . . $ modeMatch.;
7428 /*GameListing * gl = room->getGameListing(game_number);
7429 //FIXME get first time records
7430 if(gl)
7431 {
7432 aGameData->black_name = gl->black_name();
7433 aGameData->black_rank = gl->black_rank();
7434 aGameData->white_name = gl->white_name();
7435 aGameData->white_rank = gl->white_rank();
7436 // Unfortunately relevant to time records
7437 aGameData->white_first_flag = gl->white_first_flag;
7438 }*/
7439 boarddispatch->openBoardcxx . . $ BoardDispatch#openBoard(49f6e7a06ebc5aa8).();
7440
7441 /* Moved here from 0639 because 0671 probably
7442 * clears list or something on recv first data
7443 * and then back to 0639 because apparently,
7444 * it is the observer request that illicits 0671?*/
7445 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
7446 sendObserversRequestcxx . . $ TygemConnection#sendObserversRequest(ed53e3bbd3fa2f69).(game_number);
7447
7448 return;
7449 }
7450
7451 //0671
7452 void TygemConnectioncxx . . $ TygemConnection#::handleMatchOpenedcxx . . $ TygemConnection#handleMatchOpened(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
7453 {
7454 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
7455 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
7456 unsigned char * p = msg;
7457 PlayerListingcxx . . $ PlayerListing# * opponent = 0;
7458 GameDatacxx . . $ GameData# * aGameData;
7459 unsigned short game_number;
7460 unsigned char name[15];
7461 name[14] = 0x00;
7462 bool first_name_is_client;
7463 QStringcxx . . $ QString# encoded_nameAcxx . . $ QString#QString(ced63f7c635d850d)., encoded_nameBcxx . . $ QString#QString(ced63f7c635d850d).;
7464 QStringcxx . . $ QString# encoded_nameA2cxx . . $ QString#QString(ced63f7c635d850d)., encoded_nameB2cxx . . $ QString#QString(ced63f7c635d850d).;
7465 QStringcxx . . $ QString# rankAcxx . . $ QString#QString(ced63f7c635d850d)., rankBcxx . . $ QString#QString(ced63f7c635d850d).;
7466 unsigned short maintime;
7467 unsigned char periodtime, stones_periods;
7468 if(size != 92) //eweiqi 88 FIXME
7469 {
7470 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Match open msg of strange size: %d", size);
7471 }
7472 /* Is there a board_size FIXME or not? */
7473 game_number = (msg[0] << 8) + msg[1];
7474 p += 2;
7475
7476 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
7477 if(!boarddispatch)
7478 {
7479 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No board dispatch for %d", game_number);
7480 return;
7481 }
7482 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number) &&
7483 !match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->startMatchAcceptablecxx . . $ MatchNegotiationState#startMatchAcceptable(c9857a73d68e59ba).())
7484 {
7485 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("received match start at strange time"); //we get here when we create room FIXME why, I set MSCREATEDROOM, how is it not that
7486 //return;
7487 }
7488 aGameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
7489
7490 aGameData->numbercxx . . $ GameData#number. = game_number;
7491
7492 /* Don't want to use gl for names, but maybe need it for
7493 * white first flag? Hope not */
7494 GameListingcxx . . $ GameListing# * gl = room->getGameListingcxx . . $ Room#getGameListing(d402167d8f57cf00).(game_number);
7495 //FIXME get first time records
7496 //aGameData->black_name = gl->black_name();
7497 //aGameData->black_rank = gl->black_rank();
7498 //aGameData->white_name = gl->white_name();
7499 //aGameData->white_rank = gl->white_rank();
7500 /* Unfortunately relevant to time records */
7501 aGameData->white_first_flagcxx . . $ GameData#white_first_flag. = gl->white_first_flagcxx . . $ GameListing#white_first_flag.;
7502
7503 #ifdef RE_DEBUG
7504 printf("0671 match: \n");
7505 for(unsigned int i = 0; i < size; i++)
7506 printf("%02x", msg[i]);
7507 printf("\n");
7508 for(unsigned int i = 0; i < size; i++)
7509 printf("%c", msg[i]);
7510 printf("\n");
7511 #endif //RE_DEBUG
7512 //after declining match offer:
7513 //0009 0001 7065 7465 7269 7573 0000 0000
7514 //0000 0009 696e 7472 7573 696f 6e00 0000
7515 //0000 000a 0000 0000 0000 0000 0100 0002
7516 //ffff ffff ffff ffff 0001 0001 7065 7465
7517 //7269 7573 0000 0002 696e 7472 7573 696f
7518 //6e00 0002 0000 61ea 4af4 8c0e
7519
7520 first_name_is_client = msg[2];
7521 // we should see if there's time info in here or the
7522 // one we're currently using. we need to initially set time
7523 // we also seem to get this one when rematch started
7524
7525 /* FIXME If this is our match, we should
7526 * most likely do bd->startGame(); here */
7527
7528 //0087 0001 baac d0a6 bba8 0000 0000 0000
7529 //0000 0011 6261 696e 6974 6500 0000 0000
7530 //0000 0011 012c 1e03 0000 0000 0100 0002
7531 //ffff ffff ffff ffff 0002 0002 6861 6e78
7532 //6961 6f68 7561 0002 6261 696e 6974 6500
7533 //0000 0002 48f6 56cd
7534 //definitely thinking game info
7535 //00050001c0cfcdb7000000000000000000000014ced2d0cdced2d0e30000000000000014
7536 //012c1e030000010001000002ffffffffffffffff000100044a61636b44616e6e7900000267647368
7537 //6a0000000000000248f6a64e
7538
7539 //second option high minutes
7540 //0003000170657465726975730000000000000008696e74727573696f6e00000000000009
7541 //012c28010100010001000002ffffff
7542 //ffffffffff00010001706574657269757300000002696e74727573696f6e00000248fcebe0
7543
7544 //probably players turn 0001
7545
7546 //below is a rematch packet
7547 //one issue though is that there doesn't seem to be a rematch flag
7548 //and 0639 opens the board dispatch. Which means this has to
7549 //check that the game has ended, I guess just check for a result
7550 //after getting the 0671, since presumably any result messages
7551 //from broadcast games would come later and then if there is a result
7552 //close and reopen the boarddispatch. But then we need to be careful
7553 //that we don't lose anything that the 0639 put up that the 0671
7554 //neglected to. I don't think there's anything but... FIXME
7555 //00490001c4c1d2b0b5b6bfcd0000000000000015797031323131373400000000000000
7556 //14012c1e030100000001000002ffffffffffffffff000b0000xc6d79646b003137340000
7557 //0002797031323131373400000002498b58e4
7558
7559 p += 2;
7560 //name and rank
7561 strncpy((char *)name, (char *)&(msg[4]), 14);
7562 encoded_nameA =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7563 p += 15;
7564 //rank byte
7565 if(msg[19] < 0x12)
7566 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[19]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
7567 else if(msg[19] > 0x1a)
7568 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[19] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
7569 else
7570 rankA =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[19] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
7571 p++;
7572 //name and rank
7573 strncpy((char *)name, (char *)&(msg[20]), 14);
7574 encoded_nameB =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7575 p += 15;
7576 //rank byte
7577 if(msg[35] < 0x12)
7578 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(0x12 - msg[35]) +cxx . . $ operator+(501d4570f8fec4c9). 'k';
7579 else if(msg[35] > 0x1a)
7580 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[35] - 0x1a) +cxx . . $ operator+(501d4570f8fec4c9). 'p';
7581 else
7582 rankB =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). QStringcxx . . $ QString#::numbercxx . . $ QString#number(f4fd9db251ca774b).(msg[35] - 0x11) +cxx . . $ operator+(501d4570f8fec4c9). 'd';
7583 p++;
7584 //time settings
7585 //type seconds minutes periods
7586 /*switch(p[0])
7587 {
7588 case 0x01:
7589 aGameData->timeSystem = byoyomi;
7590 break;
7591 default:
7592 printf("Time system: %02x!!!\n", p[0]);
7593 break;
7594 }*/
7595 // TIME is wrong FIXME
7596 //0178 0001 696e 7472 7573 696f 6e00 0000
7597 //0000 000a 7065 7465 7269 7573 0000 0000
7598 //0000 0009 0000 0000 0000 0000 0100 0002
7599 //ffff ffff ffff ffff 0000 0001 696e 7472
7600 //7573696f6e000002706574657269757300000002000061ea4b3170da
7601 maintime = (msg[36] << 8) + msg[37];
7602 periodtime = msg[38];
7603 stones_periods = msg[39];
7604 if(maintime == 0 && periodtime == 0 && stones_periods == 0)
7605 {
7606 //this can't be the only indicator
7607 //no time settings agreed upon, no game
7608 //FIXME double check we aren't accidentally sending this
7609 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("no match");
7610 return;
7611 }
7612
7613 if(aGameData->fullresultcxx . . $ GameData#fullresult.)
7614 {
7615 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("0671 received for game with result already set\nassuming rematch\n");
7616 class ObserverListModelcxx . . $ ObserverListModel# * olm = boarddispatch->getObserverListModelForRematchcxx . . $ BoardDispatch#getObserverListModelForRematch(ac139ea84b69b4da).();
7617 NetworkConnectioncxx . . $ NetworkConnection#::closeBoardDispatchcxx . . $ NetworkConnection#closeBoardDispatch(cb2f890c2fdad230).(game_number);
7618 boarddispatch = getBoardDispatchcxx . . $ NetworkConnection#getBoardDispatch(f34f0704202202).(game_number);
7619 if(!boarddispatch)
7620 {
7621 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't create board dispatch for %d", game_number);
7622 return;
7623 }
7624 boarddispatch->setObserverListModelcxx . . $ BoardDispatch#setObserverListModel(a089598c119048f6).(olm);
7625 //below is copied from 0639, awkward FIXME
7626 boarddispatch->openBoardcxx . . $ BoardDispatch#openBoard(49f6e7a06ebc5aa8).();
7627
7628 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
7629 {
7630 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->startMatchcxx . . $ MatchNegotiationState#startMatch(49f6e7a06ebc5aa8).();
7631 //verify name and settings, possibly with switched color FIXME
7632 }
7633 aGameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
7634
7635 aGameData->numbercxx . . $ GameData#number. = game_number;
7636 }
7637
7638 aGameData->timeSystemcxx . . $ GameData#timeSystem. = byoyomicxx . . $ byoyomi.; //anything else??
7639 aGameData->maintimecxx . . $ GameData#maintime. = maintime;
7640 aGameData->periodtimecxx . . $ GameData#periodtime. = periodtime;
7641 aGameData->stones_periodscxx . . $ GameData#stones_periods. = stones_periods;
7642 #ifdef RE_DEBUG
7643 printf("0671 TIME SETTINGS: %d %d %d %d %d %d\n", p[0], p[1], p[2], p[3], p[4], p[5]);
7644 #endif //RE_DEBUG
7645 aGameData->handicapcxx . . $ GameData#handicap. = msg[40];
7646 /* Either all komi is 6.5 or its not in the 0671 anymore */
7647 /*if(gl)
7648 aGameData->komi = gl->komi;
7649 else*/
7650 aGameData->komicxx . . $ GameData#komi. = (float)msg[41] + .5;
7651 p += 4;
7652 p += 2;
7653 /* This isn't white first flag I don't think, its first player
7654 * white I think... or maybe first player black, so I'll negate it...*/
7655
7656 aGameData->white_first_flagcxx . . $ GameData#white_first_flag. = !msg[42];
7657 /* FIXME okay, obviously this isn't right, at the same time, we use it below BIG FIXME */
7658 aGameData->undoAllowedcxx . . $ GameData#undoAllowed. = msg[43];
7659 if(msg[44])
7660 aGameData->free_ratedcxx . . $ GameData#free_rated. = FREEcxx . . $ FREE.;
7661 else if(!msg[44])
7662 aGameData->free_ratedcxx . . $ GameData#free_rated. = RATEDcxx . . $ RATED.;
7663 else
7664 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("strange rated byte on board open %02x", msg[43]);
7665 p += 2;
7666 //696e74727573696f6e0000000000000b
7667 //70657465726975730000000000000009
7668 //0032
7669 //04b01e03 02 00 00 01 01 0200000000000000000000000000000000000000000000000000000000706574657269757300000002000061ea
7670
7671 //00320001
7672 //696e74727573696f6e0000000000000b
7673 //70657465726975730000000000000009
7674 //04b01e03 00 00 00 01 01 010002ffffffffffffffff00000000696e74727573696f6e000002706574657269757300000002000061ea4d5fc88e
7675
7676 #ifdef RE_DEBUG
7677 //FIXME really hope I don't use this anymore
7678 if(gl && gl->white_first_flag != aGameData->white_first_flag)
7679 qDebug("gl and 0671 white first flag differ !!!!!");
7680 printf("Setting white first flag to: %d\n", aGameData->white_first_flag);
7681 #endif //RE_DEBUG
7682 //msg44
7683 p += 4;
7684 p += 4;
7685 p += 4;
7686 //this is white/black or our picture code: p[1]
7687 p += 2;
7688 //possibly this is black or their picture code: p[1]
7689 p += 2;
7690 strncpy((char *)name, (char *)&(msg[60]), 11);
7691 encoded_nameA2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7692 p += 10;
7693
7694
7695 //p[1] is color byte
7696 /* We assume ascii names are in same order */
7697 //if(p[1] == 0x02)
7698 #ifdef RE_DEBUG
7699 boarddispatch->recvKibitz(QString(), "0671 wff " + QString::number(aGameData->white_first_flag)
7700 + " gl " + (gl ? QString::number(gl->white_first_flag) : "NA") +
7701 + " " + QString::number(p[1], 16) + " " + QString::number(p[13], 16));
7702 #endif //RE_DEBUG
7703 if(aGameData->white_first_flagcxx . . $ GameData#white_first_flag.)
7704 {
7705 aGameData->white_namecxx . . $ GameData#white_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameA2;
7706 aGameData->white_rankcxx . . $ GameData#white_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankA;
7707 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("white is %s", encoded_nameA2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
7708 }
7709 //else if(p[1] == 0x01)
7710 else
7711 {
7712 aGameData->black_namecxx . . $ GameData#black_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameA2;
7713 aGameData->black_rankcxx . . $ GameData#black_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankA;
7714 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("black is %s", encoded_nameA2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
7715 }
7716 //else
7717 // qDebug("Strange color byte %d, line: %d", p[1], __LINE__);
7718 p += 2;
7719 strncpy((char *)name, (char *)&(msg[72]), 11);
7720 encoded_nameB2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7721 p += 10;
7722 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sentAdjournResumecxx . . $ MatchNegotiationState#sentAdjournResume(c9857a73d68e59ba).())
7723 {
7724 if(encoded_nameB2 !=cxx . . $ `operator!=`(5bc2975d2d751687). match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getOpponentcxx . . $ MatchNegotiationState#getOpponent(d436534e89c8f252).())
7725 {
7726 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("rematch start by unknown player"); //I highly doubt encoded_nameB2 works if we originally created the game
7727 if(encoded_nameA2 ==cxx . . $ `operator==`(5bc2975d2d751687). match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getOpponentcxx . . $ MatchNegotiationState#getOpponent(d436534e89c8f252).())
7728 {
7729 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Rematch is a2"); //FIXME, yes, we get here if we created the game originally (offered it, etc. )
7730 //probably okay below because we normally only get 0672 if we didn't create the game
7731 //rejoin on disconnect is exception
7732 opponent = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_nameA2);
7733 }
7734 //return;
7735
7736 }
7737 else
7738 opponent = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_nameB2);
7739 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->setPlayercxx . . $ MatchNegotiationState#setPlayer(122195e397f39e1b).(opponent);
7740 }
7741 else if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
7742 {
7743 opponent = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_nameB2);
7744 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyPlayercxx . . $ MatchNegotiationState#verifyPlayer(20057ff4c3da74fc).(opponent))
7745 {
7746 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("start match by unknown player");
7747 //return; //bugs out here on nigiri
7748 }
7749 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyGameDatacxx . . $ MatchNegotiationState#verifyGameData(14f5f86f6c435b5).(*aGameData))
7750 {
7751 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("opponent attempted starting game with different match settings then negotiated upon");
7752 //happens FIXME and its not like we can send an error
7753 //return;
7754 }
7755 }
7756 //p[1] is color byte
7757 //if(p[1] == 0x02)
7758 if(!aGameData->white_first_flagcxx . . $ GameData#white_first_flag.)
7759 {
7760 aGameData->white_namecxx . . $ GameData#white_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameB2;
7761 aGameData->white_rankcxx . . $ GameData#white_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
7762 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("white is %s", encoded_nameB2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
7763 }
7764 //else if(p[1] == 0x01)
7765 else
7766 {
7767 aGameData->black_namecxx . . $ GameData#black_name. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_nameB2;
7768 aGameData->black_rankcxx . . $ GameData#black_rank. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). rankB;
7769 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("black is %s", encoded_nameB2.toLatin1cxx . . $ QString#toLatin1(ef52b713090bc85a).().constDatacxx . . $ QByteArray#constData(a9f41ea0e82d88cf).());
7770 }
7771 //else
7772 // qDebug("Strange color byte %d, line: %d", p[1], __LINE__);
7773 p += 2;
7774 //msg84
7775 boarddispatch->gameDataChangedcxx . . $ BoardDispatch#gameDataChanged(49f6e7a06ebc5aa8).();
7776 if(aGameData->handicapcxx . . $ GameData#handicap.)
7777 {
7778 /* This should really be cleaned up, done in some
7779 * general place. Handicap games on tygem are
7780 * really rare and I don't know how to really
7781 * set them up yet in matches. For all the
7782 * protocols this should be setup better.
7783 * So this is just temporary. FIXME */
7784 MoveRecordcxx . . $ MoveRecord# aMovecxx . . $ MoveRecord#MoveRecord(49f6e7a06ebc5aa8).;
7785 aMove.numbercxx . . $ MoveRecord#number. = NOMOVENUMBERcxx . . $ `src/network/messages.h:51:9`!;
7786 aMove.xcxx . . $ MoveRecord#x. = aGameData->handicapcxx . . $ GameData#handicap.;
7787 aMove.flagscxx . . $ MoveRecord#flags. = MoveRecordcxx . . $ MoveRecord#::HANDICAPcxx . . $ MoveRecord#HANDICAP.;
7788 boarddispatch->recvMovecxx . . $ BoardDispatch#recvMove(d174a3d9cfb0dd75).(&aMove);
7789 }
7790 if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->isOurGamecxx . . $ MatchNegotiationState#isOurGame(3c978dac0e5ee2ad).(game_number))
7791 {
7792 //our_invitation is also set in handleCreateRoomResponse, so doublecheck, the former may be unnecessary FIXME
7793 if(encoded_nameA2 ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).())
7794 {
7795 aGameData->our_invitationcxx . . $ GameData#our_invitation. = first_name_is_client;
7796 //we do this only if we didn't send the 0671 out
7797 if(!opponent)
7798 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get opponent to close game dialog");
7799 else
7800 getAndCloseGameDialogcxx . . $ NetworkConnection#getAndCloseGameDialog(847f6df3a908f59b).(opponent);
7801 /* Note that getAndClose will fail if we're rejoining
7802 * a match in progress FIXME, networkconnection reports
7803 * error. */
7804 }
7805 else
7806 aGameData->our_invitationcxx . . $ GameData#our_invitation. = !first_name_is_client;
7807 //FIXME time
7808 //doublecheck this same issue with 0 maintime on IGS and ORO
7809 if(aGameData->maintimecxx . . $ GameData#maintime. == 0)
7810 boarddispatch->recvTimecxx . . $ BoardDispatch#recvTime(63f8d2dcefae8817).(TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(aGameData->periodtimecxx . . $ GameData#periodtime., aGameData->stones_periodscxx . . $ GameData#stones_periods.), TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(aGameData->periodtimecxx . . $ GameData#periodtime., aGameData->stones_periodscxx . . $ GameData#stones_periods.));
7811 else
7812 boarddispatch->recvTimecxx . . $ BoardDispatch#recvTime(63f8d2dcefae8817).(TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(aGameData->maintimecxx . . $ GameData#maintime., -1), TimeRecordcxx . . $ TimeRecord#TimeRecord(3e454b8ccf442868).(aGameData->maintimecxx . . $ GameData#maintime., -1));
7813 /* I don't think this is a good place to set this: */
7814 /*if(aGameData->free_rated == FREE)
7815 aGameData->undoAllowed = true;*/
7816
7817 boarddispatch->startGamecxx . . $ BoardDispatch#startGame(49f6e7a06ebc5aa8).(); //starts timers
7818 boarddispatch->swapColorscxx . . $ BoardDispatch#swapColors(b45ddcbc8423892c).(true);
7819 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->startMatchcxx . . $ MatchNegotiationState#startMatch(49f6e7a06ebc5aa8).();
7820 }
7821 /* Actually, first move message number appears to be 2, maybe 1 is for handicap?
7822 * this needs to be right for when we play black!! */
7823 move_message_numbercxx . . $ TygemConnection#move_message_number. = 1; //changed from 0... only relevant for our games!! FIXME
7824 move_message_number_ackcxx . . $ TygemConnection#move_message_number_ack. = 1;
7825 /* Note that we increment on most sends ... */
7826
7827 return;
7828 }
7829
7830 //join with 0646 as well
7831 //0645
7832 void TygemConnectioncxx . . $ TygemConnection#::handleMatchOffercxx . . $ TygemConnection#handleMatchOffer(892cc42ac5eea747).(unsigned char * msg, unsigned int size, MIVersioncxx . . $ TygemConnection#MIVersion# version)
7833 {
7834 unsigned char * p = msg;
7835 if(size != 88) //84
7836 {
7837 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Match offer msg of strange size: %d", size);
7838 }
7839
7840 unsigned short game_number;
7841 unsigned char name[15];
7842 name[14] = 0x00;
7843 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
7844 PlayerListingcxx . . $ PlayerListing# * opponent;
7845
7846 strncpy((char *)name, (char *)p, 14);
7847 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7848 if(encoded_name !=cxx . . $ `operator!=`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).()) //FIXME in case response doesn't readdress
7849 return;
7850 p += 15;
7851 //rank
7852 p++;
7853 strncpy((char *)name, (char *)p, 14);
7854 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7855 p += 15;
7856 //rank
7857 p++;
7858 game_number = (p[0] << 8) + p[1];
7859 p += 2;
7860 //time settings
7861 MatchRequestcxx . . $ MatchRequest# * tempmr = new MatchRequestcxx . . $ MatchRequest#();
7862 tempmr->numbercxx . . $ MatchRequest#number. = game_number;
7863 tempmr->timeSystemcxx . . $ MatchRequest#timeSystem. = byoyomicxx . . $ byoyomi.;
7864 tempmr->maintimecxx . . $ MatchRequest#maintime. = (p[0] << 8) + p[1];
7865 tempmr->periodtimecxx . . $ MatchRequest#periodtime. = p[2];
7866 tempmr->stones_periodscxx . . $ MatchRequest#stones_periods. = p[3];
7867 tempmr->handicapcxx . . $ MatchRequest#handicap. = p[4];
7868 tempmr->komicxx . . $ MatchRequest#komi. = (float)p[5] + .5;
7869 switch(p[6])
7870 {
7871 /* FIXME NO!! either here or at one of the sendMatch Offers, there's something wrong
7872 * might be that it depends on who offers the game!! */
7873 case 0x00:
7874 if(version == modifycxx . . $ TygemConnection#modify.)
7875 tempmr->color_requestcxx . . $ MatchRequest#color_request. = MatchRequestcxx . . $ MatchRequest#::BLACKcxx . . $ MatchRequest#BLACK.;
7876 else
7877 tempmr->color_requestcxx . . $ MatchRequest#color_request. = MatchRequestcxx . . $ MatchRequest#::WHITEcxx . . $ MatchRequest#WHITE.;
7878 break;
7879 case 0x01:
7880 if(version == modifycxx . . $ TygemConnection#modify.)
7881 tempmr->color_requestcxx . . $ MatchRequest#color_request. = MatchRequestcxx . . $ MatchRequest#::WHITEcxx . . $ MatchRequest#WHITE.;
7882 else
7883 tempmr->color_requestcxx . . $ MatchRequest#color_request. = MatchRequestcxx . . $ MatchRequest#::BLACKcxx . . $ MatchRequest#BLACK.;
7884 break;
7885 case 0x02:
7886 tempmr->color_requestcxx . . $ MatchRequest#color_request. = MatchRequestcxx . . $ MatchRequest#::NIGIRIcxx . . $ MatchRequest#NIGIRI.;
7887 break;
7888 default:
7889 printf("Strange byte in match offer: %02x", p[6]);
7890 break;
7891 }
7892 p += 7;
7893 //696e74727573696f6e0000000000000b
7894 //70657465726975730000000000000009
7895 //0032 04b0 1e03 0200 0001 0102 00000000000000000000000000000000000000000000000000000000706574657269757300000002000061ea
7896
7897 #ifdef RE_DEBUG
7898 if(p[0] != p[1])
7899 printf("match offer with friendly/rated %02x %02x", p[0], p[1]);
7900 #endif //RE_DEBUG
7901 tempmr->undoAllowedcxx . . $ MatchRequest#undoAllowed. = p[0];
7902 //01 00 looks like rated with undo checked
7903 if(p[1] == 0x01)
7904 tempmr->free_ratedcxx . . $ MatchRequest#free_rated. = FREEcxx . . $ FREE.;
7905 else if(p[1] == 0x00)
7906 tempmr->free_ratedcxx . . $ MatchRequest#free_rated. = RATEDcxx . . $ RATED.;
7907 else
7908 printf("match offer with friendly/rated %02x %02x", p[0], p[1]);
7909 p += 2;
7910 //message version byte
7911 p++;
7912 p += 4; //ffff ffff
7913 p += 12;
7914 strncpy((char *)name, (char *)p, 11); //our nickname
7915 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7916 p += 11;
7917 p++; //country_id
7918 strncpy((char *)name, (char *)p, 11);
7919 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
7920 p += 11;
7921 p++; //country_id
7922
7923 if(version == offercxx . . $ TygemConnection#offer.)
7924 {
7925 //0645 doesn't have opponent's nickname, apparently,
7926 //our nickname if we send it, but not opponents
7927 tempmr->opponentcxx . . $ MatchRequest#opponent. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_name;
7928 tempmr->opponent_is_challengercxx . . $ MatchRequest#opponent_is_challenger. = true;
7929 opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingByNotNicknamecxx . . $ Room#getPlayerListingByNotNickname(d3f53ac2de9f0b45).(encoded_name);
7930 }
7931 else
7932 {
7933 tempmr->opponentcxx . . $ MatchRequest#opponent. =cxx . . $ QString#`operator=`(b79fde0b0ce9b948). encoded_name2;
7934 opponent = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).()->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
7935 }
7936 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyPlayercxx . . $ MatchNegotiationState#verifyPlayer(20057ff4c3da74fc).(opponent))
7937 {
7938 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Match offer/accept from unknown opponent");
7939 return;
7940 }
7941
7942 //0004 0e10 1e03 0100
7943 if(version == offercxx . . $ TygemConnection#offer. || version == modifycxx . . $ TygemConnection#modify.)
7944 {
7945 //apparently acknowledge no longer necessary?
7946 //sendMatchOffer(*tempmr, acknowledge);
7947
7948 if(version == offercxx . . $ TygemConnection#offer. && !match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->waitingForMatchOffercxx . . $ MatchNegotiationState#waitingForMatchOffer(c9857a73d68e59ba).())
7949 {
7950 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("received match offer, not waiting for match offer"); //this is happening when they modify sometimes, or if
7951 //we modify I think and they modify ours or something
7952 //return;
7953 }
7954 else if(version == modifycxx . . $ TygemConnection#modify. && !match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sentMatchOffercxx . . $ MatchNegotiationState#sentMatchOffer(c9857a73d68e59ba).())
7955 {
7956 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("received modified match offer, didn't send offer");
7957 //return;
7958 }
7959 //Here, we actually want to pop up game dialog
7960 GameDialogcxx . . $ GameDialog# * gameDialogDispatch = getGameDialogcxx . . $ NetworkConnection#getGameDialog(3dcc94127826259).(opponent);
7961 //for game dialog time checks
7962 lastMainTimeCheckedcxx . . $ NetworkConnection#lastMainTimeChecked. = tempmr->maintimecxx . . $ MatchRequest#maintime.;
7963 lastPeriodTimeCheckedcxx . . $ NetworkConnection#lastPeriodTimeChecked. = tempmr->periodtimecxx . . $ MatchRequest#periodtime.;
7964 lastPeriodsCheckedcxx . . $ NetworkConnection#lastPeriodsChecked. = tempmr->stones_periodscxx . . $ MatchRequest#stones_periods.;
7965 gameDialogDispatch->recvRequestcxx . . $ GameDialog#recvRequest(461bc273ee812ab9).(tempmr, getGameDialogFlagscxx . . $ TygemConnection#getGameDialogFlags(f708dce9a8856c70).());
7966 }
7967 else if(version == acceptcxx . . $ TygemConnection#accept.)
7968 {
7969 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sentMatchOffercxx . . $ MatchNegotiationState#sentMatchOffer(c9857a73d68e59ba).())
7970 return;
7971 //match offer accept
7972 //00580646
7973 //0x0646: 70657465726975730000000000000008696e74727573696f6e000000000000090032012c2801010001
7974 //000001ffffffff000000000001000000000000706574657269757300000002696e74727573696f6e000002
7975 //00a00616
7976 MatchRequestcxx . . $ MatchRequest# * mr = getAndCloseGameDialogcxx . . $ NetworkConnection#getAndCloseGameDialog(847f6df3a908f59b).(opponent);
7977 if(!mr)
7978 {
7979 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Can't get match request for opponent");
7980 //return;
7981 }
7982 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyMatchRequestcxx . . $ MatchNegotiationState#verifyMatchRequest(4332f687ff4e837).(*tempmr))
7983 {
7984 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("opponent accepted with strange match sttings"); //we get here
7985 //return;
7986 }
7987 //FIXME, maybe should be mr here, but tempmr from filled out
7988 //above is probably better
7989 //FIXME there's an issue here
7990 //when we negotiate an offer... not clear yet
7991 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->acceptMatchTermscxx . . $ MatchNegotiationState#acceptMatchTerms(969a5d62d7a1bd6e).(tempmr); //FIXME awkward, even though they're accepting? but is necessary here, just lousy name
7992 sendStartGamecxx . . $ TygemConnection#sendStartGame(9f9e9a38fcfe00de).(*tempmr);
7993 }
7994 else if(version == declinecxx . . $ TygemConnection#decline.)
7995 {
7996 GameDialogcxx . . $ GameDialog# * gameDialogDispatch = getIfGameDialogcxx . . $ NetworkConnection#getIfGameDialog(3dcc94127826259).(opponent);
7997 if(!gameDialogDispatch)
7998 {
7999 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("No game dialog open to be declined");
8000 }
8001 else
8002 gameDialogDispatch->recvRefuseMatchcxx . . $ GameDialog#recvRefuseMatch(d4f767463ce0a6b3).(GD_REFUSE_DECLINEcxx . . $ `src/network/networkconnection.h:80:9`!);
8003 }
8004 delete tempmr;
8005 return;
8006 }
8007
8008 void TygemConnectioncxx . . $ TygemConnection#::handleResumeMatchcxx . . $ TygemConnection#handleResumeMatch(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
8009 {
8010 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch;
8011 int i;
8012 unsigned short game_number;
8013 unsigned char name[15];
8014 name[14] = 0x00;
8015 QStringcxx . . $ QString# encoded_namecxx . . $ QString#QString(ced63f7c635d850d)., encoded_name2cxx . . $ QString#QString(ced63f7c635d850d).;
8016
8017 game_number = (msg[0] << 8) + msg[1];
8018 boarddispatch = getIfBoardDispatchcxx . . $ NetworkConnection#getIfBoardDispatch(f34f0704202202).(game_number);
8019 if(!boarddispatch)
8020 {
8021 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Unexpected: got 068e for board %d", game_number);
8022 return;
8023 }
8024
8025 //first name is not addressee!!
8026 strncpy((char *)name, (char *)&(msg[4]), 14);
8027 encoded_name =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
8028
8029 strncpy((char *)name, (char *)&(msg[20]), 14);
8030 encoded_name2 =cxx . . $ QString#`operator=`(4f35bf974e7f8568). serverCodeccxx . . $ TygemConnection#serverCodec.->toUnicodecxx . . $ QTextCodec#toUnicode(22771b2711c76a3b).((char *)name, strlen((char *)name));
8031
8032 //I'm not certain that we're sending this in the right order,
8033 //but I know from something else we send or just because, official
8034 //client will get us sent one of these when opponent resumes
8035 //a game they disconnected from
8036 //the last byte msg[35] is 0x01
8037 //made a mistake, that was from us..
8038 printf("***0x068e: ");
8039 for(i = 0; i < (int)size; i++)
8040 printf("%02x", msg[i]);
8041 printf("\n");
8042
8043 if(encoded_name ==cxx . . $ `operator==`(5bc2975d2d751687). getUsernamecxx . . $ NetworkConnection#getUsername(a2fb7a6ce195d51).() && msg[35] == 0x01)
8044 {
8045 /* This might actually be from us ?? */
8046 //this is where we need to reenable playing!!! FIXME
8047 }
8048 //068e 0005 0000
8049 //7065 7465 7269 7573 0000 0000 0000 0000
8050 //696e 7472 7573 696f 6e00 0000 0000 0001
8051
8052 //here we get this and we are peterius black, its not our invitation
8053 //0000 0028 068e 000b 0000 P..h.....(......
8054 //696e 7472 7573 696f 6e00 0000 0000 0000 intrusion.......
8055 //7065 7465 7269 7573 0000 0000 0000 0001 peterius........
8056
8057 //0010 067d 000b 0001 0312 1d80 0314 1d40
8058 }
8059
8060 //0643
8061 void TygemConnectioncxx . . $ TygemConnection#::handleMatchInvitecxx . . $ TygemConnection#handleMatchInvite(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
8062 {
8063 unsigned char * p = msg;
8064 unsigned short room_number;
8065 if(size != 60)
8066 {
8067 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("MatchInvite of size %d\n", size);
8068 // probably should print it out and exit FIXME
8069 }
8070 #ifdef RE_DEBUG
8071 printf("0x0643: ");
8072 for(unsigned int i = 0; i < size; i++)
8073 printf("%02x", msg[i]);
8074 printf("\n");
8075
8076 //tom
8077 //7065 7465 7269 7573 0000 0000 0000 0008
8078 //7065 7465 7269 7573 0000 0000 696e 7472
8079 //7573 696f 6e00 0000 0000 0008 696e 7472
8080 //7573 696f 6e00 0002 0100 ffff
8081 #endif //RE_DEBUG
8082 p += 14;
8083 //invite_byte = p[1]; //probably not
8084 p += 2;
8085 p += 12;
8086
8087 p += 16;
8088
8089 PlayerListingcxx . . $ PlayerListing# * player = getOrCreatePlayerListingFromRecordcxx . . $ TygemConnection#getOrCreatePlayerListingFromRecord(c707c4736c9748ef).((char *)&(msg[28]));
8090 p += 10;
8091 p++;
8092 opponent_is_challengercxx . . $ TygemConnection#opponent_is_challenger. = (bool)(p[0] - 1);
8093 p++;
8094 p += 2; //possible first, second player settings
8095 room_number = p[0] + (p[1] << 8);
8096 if(room_number != 0xffff)
8097 {
8098 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyPlayercxx . . $ MatchNegotiationState#verifyPlayer(20057ff4c3da74fc).(player))
8099 {
8100 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Got room to join from bad player");
8101 return;
8102 }
8103 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->waitingForRoomNumbercxx . . $ MatchNegotiationState#waitingForRoomNumber(c9857a73d68e59ba).())
8104 {
8105 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Got room to join, haven't accepted");
8106 return;
8107 }
8108 // this is created room
8109 sendJoincxx . . $ TygemConnection#sendJoin(ed53e3bbd3fa2f69).(room_number);
8110 match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sendJoinRoomcxx . . $ MatchNegotiationState#sendJoinRoom(ed53e3bbd3fa2f69).(room_number);
8111 //this also asks for an observer list request which may
8112 //FIXME not be necessary if its our match, don't think
8113 //they send it, we're first ones in
8114 /* Do we need to wait for observe reply?? or no? */
8115 sendObserversRequestcxx . . $ TygemConnection#sendObserversRequest(ed53e3bbd3fa2f69).(room_number);
8116 }
8117 else if(stdcxx . . $ std/::findcxx . . $ std/find(a92da12e15934614).(decline_all_invitationscxx . . $ TygemConnection#decline_all_invitations..begincxx . . $ std/vector#begin(55a6de06420d4903).(), decline_all_invitationscxx . . $ TygemConnection#decline_all_invitations..endcxx . . $ std/vector#end(55a6de06420d4903).(), player) !=cxx . . $ __gnu_cxx/`operator!=`(30ee64f2df4eef8b). decline_all_invitationscxx . . $ TygemConnection#decline_all_invitations..endcxx . . $ std/vector#end(55a6de06420d4903).())
8118 {
8119 //client is responsible for this:
8120 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, decline_allcxx . . $ TygemConnection#decline_all.);
8121 }
8122 else if(getBoardDispatchescxx . . $ NetworkConnection#getBoardDispatches(b126dc7c1de90089).() == 3)
8123 {
8124 // if we already have 3 games open, there's no warning, just decline
8125 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, declinecxx . . $ TygemConnection#decline.); //decline handles getBoardDispatches()
8126 }
8127 else if(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->inGamecxx . . $ MatchNegotiationState#inGame(c9857a73d68e59ba).())
8128 {
8129 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, alreadyingamecxx . . $ TygemConnection#alreadyingame.); //doublecheck this isn't block
8130 }
8131 else
8132 {
8133 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->newMatchAllowedcxx . . $ MatchNegotiationState#newMatchAllowed(c9857a73d68e59ba).())
8134 {
8135 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, declinecxx . . $ TygemConnection#decline.);
8136 return;
8137 }
8138 /* FIXME
8139 * yet another point, it seems somehow that the dialog
8140 * can close prematurely, somehow and then the seconds
8141 * will start low for another invite or something, its weird */
8142 MatchInviteDialogcxx . . $ MatchInviteDialog# * mid = new MatchInviteDialogcxx . . $ MatchInviteDialog#(playercxx . . $ QString#QString(132dd6869045752b).->namecxx . . $ PlayerListing#name., playercxx . . $ QString#QString(132dd6869045752b).->rankcxx . . $ PlayerListing#rank., true);
8143 int mid_return = mid->execcxx . . $ QDialog#exec(b126dc7c1de90089).();
8144
8145 if(mid_return == 1)
8146 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, acceptcxx . . $ TygemConnection#accept.);
8147 else if(mid_return == -1)
8148 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, declinecxx . . $ TygemConnection#decline.);
8149 else if(mid_return == -2)
8150 {
8151 decline_all_invitationscxx . . $ TygemConnection#decline_all_invitations..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(player);
8152 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(player, decline_allcxx . . $ TygemConnection#decline_all.);
8153 }
8154 }
8155 }
8156
8157 //0644
8158 void TygemConnectioncxx . . $ TygemConnection#::handleMatchInviteResponsecxx . . $ TygemConnection#handleMatchInviteResponse(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
8159 {
8160 unsigned char * p = msg;
8161 unsigned char name[15];
8162 name[14] = 0x00;
8163 if(size != 60)
8164 {
8165 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("MatchInvite of size %d\n", size);
8166 // probably should print it out and exit FIXME
8167 }
8168 //actually maybe our offer is still screwed up FIXME
8169 #ifdef RE_DEBUG
8170 printf("*** 0x0644: ");
8171 for(unsigned int i = 0; i < size; i++)
8172 printf("%02x", msg[i]);
8173 printf("\n");
8174 #endif //RE_DEBUG
8175 Roomcxx . . $ Room# * room = getDefaultRoomcxx . . $ NetworkConnection#getDefaultRoom(93e93f117be81b18).();
8176 p += 28;
8177 /* Can't we make a special thing to do all these repetitive string copies? */
8178 strncpy((char *)name, (char *)p, 14);
8179 QStringcxx . . $ QString# encoded_name = QStringcxx . . $ QString#QString(85c52e162fed56f9).((char *)name);
8180 //QString encoded_name = serverCodec->toUnicode((char *)name, strlen((char *)name));
8181 p += 14;
8182 p += 2;
8183 strncpy((char *)name, (char *)p, 11);
8184 QStringcxx . . $ QString# encoded_name2 = QStringcxx . . $ QString#QString(85c52e162fed56f9).((char *)name);
8185 PlayerListingcxx . . $ PlayerListing# * player = room->getPlayerListingcxx . . $ Room#getPlayerListing(d3f53ac2de9f0b45).(encoded_name2);
8186 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->verifyPlayercxx . . $ MatchNegotiationState#verifyPlayer(20057ff4c3da74fc).(player))
8187 {
8188 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Match invite response failed to verify player");
8189 return;
8190 }
8191 p += 12;
8192 p++;
8193 //this byte seems to determine accept versus decline, etc.
8194 //0x0b is autodecline, 0x00 is offer or decline here, 0x01
8195 switch(p[0])
8196 {
8197 case 0x00:
8198 {
8199 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0,trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Invite declined"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 has declined invitation").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
8200 }
8201 break;
8202 case 0x01:
8203 sendCreateRoomcxx . . $ TygemConnection#sendCreateRoom(49f6e7a06ebc5aa8).();
8204 return;
8205 break;
8206 case 0x0b:
8207 {
8208 /* FIXME, I'm thinking 0b may mean that they're already in a game
8209 * in addition?*/
8210 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("In game?"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 is not accepting invitations").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
8211 }
8212 break;
8213 case 0x0c:
8214 {
8215 /* We shouldn't really get here, this means they have "decline"
8216 * set */
8217 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Not open"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 is not accepting invitations").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
8218 }
8219 break;
8220 case 0x0d:
8221 {
8222 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Not open"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 has the maximum boards (3) open").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
8223 }
8224 break;
8225 case 0x0e:
8226 {
8227 /* I think you get this if you check the box */
8228 QMessageBoxcxx . . $ QMessageBox#::informationcxx . . $ QMessageBox#information(a9e3742e6f7b4147).(0, trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("Invite declined"), trcxx . . $ NetworkConnection#tr(75d9f1c324b4579d).("%1 has declined all invitations").argcxx . . $ QString#arg(bc823072288cbbb5).(player->namecxx . . $ PlayerListing#name.));
8229 }
8230 break;
8231 default:
8232 #ifdef RE_DEBUG
8233 qDebug("Received strange byte %02x in match invite response", p[0]);
8234 #endif //RE_DEBUG
8235 break;
8236 }
8237 }
8238
8239 //0637
8240 void TygemConnectioncxx . . $ TygemConnection#::handleCreateRoomResponsecxx . . $ TygemConnection#handleCreateRoomResponse(e1e8b00c42c42532).(unsigned char * msg, unsigned int size)
8241 {
8242 unsigned short room_number = (msg[0] << 8) + msg[1];
8243
8244 if(size != 12) //4?
8245 {
8246 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("create room response of size: %d", size);
8247 //return;
8248 }
8249 /* FIXME We're going to assume for now that we're getting
8250 * this because we received a match response accept and
8251 * so we'll just send the join message and pray for rain */
8252 if(msg[2] != 0x01 || msg[3] != 0xff)
8253 {
8254 printf("roomcreate: %02x %02x\n", msg[2], msg[3]);
8255 }
8256 //0x0637 room create?: 0129 01ff 0000 0000 0000 0000
8257 #ifdef RE_DEBUG
8258 printf("0x0637 room create?: ");
8259 for(unsigned int i = 0; i < size; i++)
8260 printf("%02x", msg[i]);
8261 printf("\n");
8262 #endif //RE_DEBUG
8263 if(!match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->sentCreateRoomcxx . . $ MatchNegotiationState#sentCreateRoom(c9857a73d68e59ba).())
8264 return;
8265 sendObserversRequestcxx . . $ TygemConnection#sendObserversRequest(ed53e3bbd3fa2f69).(room_number);
8266 //join should also put us in room with board?
8267 sendMatchInvitecxx . . $ TygemConnection#sendMatchInvite(72df06a5942d44e9).(match_negotiation_statecxx . . $ NetworkConnection#match_negotiation_state.->getPlayerListingcxx . . $ MatchNegotiationState#getPlayerListing(8a20cf3761bafdec).(), createcxx . . $ TygemConnection#create., room_number);
8268 //not sure of timing of this
8269
8270 //when we offer and its accepted and we create, we don't
8271 //get a starting message, I think we're supposed to open the
8272 //board on receipt of 0637 maybe, 0665 send is strange, don't
8273 //know what that's for, no response anyway, that we know of
8274
8275 /* Try creating board here FIXME with MatchOpened 0639*/
8276 BoardDispatchcxx . . $ BoardDispatch# * boarddispatch = getBoardDispatchcxx . . $ NetworkConnection#getBoardDispatch(f34f0704202202).(room_number);
8277 GameDatacxx . . $ GameData# * aGameData = boarddispatch->getGameDatacxx . . $ BoardDispatch#getGameData(f917540193955ea7).();
8278 aGameData->numbercxx . . $ GameData#number. = room_number;
8279 aGameData->gameModecxx . . $ GameData#gameMode. = modeMatchcxx . . $ modeMatch.;
8280 aGameData->our_invitationcxx . . $ GameData#our_invitation. = true;
8281 /*GameListing * gl = room->getGameListing(game_number);
8282 //FIXME get first time records
8283 if(gl)
8284 {
8285 aGameData->black_name = gl->black_name();
8286 aGameData->black_rank = gl->black_rank();
8287 aGameData->white_name = gl->white_name();
8288 aGameData->white_rank = gl->white_rank();
8289 // Unfortunately relevant to time records
8290 //aGameData->white_first_flag = gl->white_first_flag;
8291 }*/
8292 boarddispatch->openBoardcxx . . $ BoardDispatch#openBoard(49f6e7a06ebc5aa8).();
8293 }
8294
8295 /* These needs to be more versatile later */
8296 void TygemConnectioncxx . . $ TygemConnection#::onReadycxx . . $ TygemConnection#onReady(49f6e7a06ebc5aa8).(void)
8297 {
8298 //sendInvitationSettings(true); //for now
8299 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Ready!\n");
8300 NetworkConnectioncxx . . $ NetworkConnection#::onReadycxx . . $ NetworkConnection#onReady(49f6e7a06ebc5aa8).();
8301 }
8302
8303 int TygemConnectioncxx . . $ TygemConnection#::time_to_secondscxx . . $ TygemConnection#time_to_seconds(645d6210e0be3a78).(const QStringcxx . . $ QString# & time)
8304 {
8305 QRegExpcxx . . $ QRegExp# re = QRegExpcxx . . $ QRegExp#QRegExp(31e086911ff70bd0).("([0-9]{1,2}):([0-9]{1,2})"cxx . . $ QString#QString(85c52e162fed56f9).);
8306 int min, sec;
8307
8308 if(re.indexIncxx . . $ QRegExp#indexIn(46f502bdfc4aeb33).(time) >= 0)
8309 {
8310 min = re.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(1).toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
8311 sec = re.capcxx . . $ QRegExp#cap(ce915ed341d4a7f0).(2).toIntcxx . . $ QString#toInt(d7972accae11ee1f).();
8312 }
8313 else
8314 {
8315 qDebugcxx . . $ `<external>/10450329605257866924/qlogging.h:164:9`!("Bad time string");
8316 return 0xffff;
8317 }
8318
8319 return (60 * min) + sec;
8320 }
8321
8322 void TygemConnectioncxx . . $ TygemConnection#::secondsToDatecxx . . $ TygemConnection#secondsToDate(4b79e85d1d97ff5b).(unsigned short & year, unsigned char & month, unsigned char & day, unsigned char & hour, unsigned char & minute, unsigned char & second)
8323 {
8324 unsigned long seconds = time(0);
8325 year = (seconds / 31536000);
8326 seconds -= ((year * 31536000) + ((year / 4) * 86400));
8327 year += 1970;
8328 bool leap = (year % 4 == 0);
8329 day = (seconds / 86400);
8330 seconds -= (day * 86400);
8331 hour = (seconds / 3600);
8332 seconds -= (hour * 3600);
8333 minute = (seconds / 60);
8334 seconds -= (minute * 60);
8335 second = seconds;
8336 int days_in_each_month[12] = { 31, 28 + leap, 31, 30, 31, 30, 31, 31, 31, 31, 30, 31};
8337 int i;
8338
8339 for(i = 1; i < 13; i++)
8340 {
8341 int sum, j;
8342 sum = 0;
8343 for(j = 0; j < i; j++)
8344 sum += days_in_each_month[j];
8345 if(day <= sum)
8346 {
8347 month = i;
8348 day -= (sum - days_in_each_month[i - 1]);
8349 break;
8350 }
8351 }
8352
8353 printf("Todays date is: %d %d %d - %d %d %d\n", year, month, day, hour, minute, second);
8354 }