Subversion Repositories Games.Chess Giants

Rev

Rev 161 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 161 Rev 172
Line 9... Line 9...
9
 
9
 
10
// local type definitions
10
// local type definitions
11
typedef struct sendchallenge_s
11
typedef struct sendchallenge_s
12
{
12
{
13
   wchar_t challengee[32]; // challengee's nickname
13
   wchar_t challengee[32]; // challengee's nickname
-
 
14
   wchar_t game_rules[32]; // the rules with which to play (standard, losers, etc)
14
   int color; // color we want to play
15
   int color; // color we want to play
15
   bool is_rated; // whether this game is rated or not
16
   bool is_rated; // whether this game is rated or not
16
   int initial_time; // initial time of the game for each color
17
   int initial_time; // initial time of the game for each color
17
   int increment; // eventual time increment (Fischer pace)
18
   int increment; // eventual time increment (Fischer pace)
18
} sendchallenge_t;
19
} sendchallenge_t;
19
 
20
 
20
 
21
 
21
// global variables used in this module only
22
// global variables used in this module only
22
static sendchallenge_t sendchallenge = { L"", COLOR_UNSPECIFIED, false, 2, 12};
23
static sendchallenge_t sendchallenge = { L"", L"", COLOR_UNSPECIFIED, false, 2, 12};
23
static HWND hThisWnd = NULL;
24
static HWND hThisWnd = NULL;
24
 
25
 
25
 
26
 
26
// prototypes of local functions
27
// prototypes of local functions
27
static void StartThread_ThisDialog (void *thread_parms);
28
static void StartThread_ThisDialog (void *thread_parms);
Line 32... Line 33...
32
{
33
{
33
   // helper function to fire up the modeless dialog box
34
   // helper function to fire up the modeless dialog box
34
 
35
 
35
   // prepare the sendchallenge structure
36
   // prepare the sendchallenge structure
36
   wcscpy_s (sendchallenge.challengee, WCHAR_SIZEOF (sendchallenge.challengee), challengee_name);
37
   wcscpy_s (sendchallenge.challengee, WCHAR_SIZEOF (sendchallenge.challengee), challengee_name);
-
 
38
   sendchallenge.game_rules[0] = 0; // no special rules until told otherwise
37
 
39
 
38
   is_dialogbox_displayed = true;
40
   is_dialogbox_displayed = true;
39
   _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread
41
   _beginthread (StartThread_ThisDialog, 0, NULL); // fire up the thread
40
   return; // return as soon as the thread is fired up
42
   return; // return as soon as the thread is fired up
41
}
43
}
Line 53... Line 55...
53
   network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player
55
   network_player = Player_FindByType (PLAYER_INTERNET); // quick access to network player
54
   if (network_player == NULL)
56
   if (network_player == NULL)
55
      return; // consistency check
57
      return; // consistency check
56
 
58
 
57
   // send the challenge
59
   // send the challenge
58
   Player_SendBuffer_Add (network_player, 1000, L"match %s %s %d %d %s\n",
60
   Player_SendBuffer_Add (network_player, 1000, L"match %s %s %d %d %s %s\n",
59
                                                sendchallenge.challengee,
61
                                                sendchallenge.challengee,
60
                                                (sendchallenge.is_rated ? L"rated" : L"unrated"),
62
                                                (sendchallenge.is_rated ? L"rated" : L"unrated"),
61
                                                sendchallenge.initial_time,
63
                                                sendchallenge.initial_time,
62
                                                sendchallenge.increment,
64
                                                sendchallenge.increment,
63
                                                (sendchallenge.color == COLOR_BLACK ? L"black" : (sendchallenge.color == COLOR_WHITE ? L"white" : L"")));
65
                                                (sendchallenge.color == COLOR_BLACK ? L"black" : (sendchallenge.color == COLOR_WHITE ? L"white" : L"")),
-
 
66
                                                sendchallenge.game_rules);
64
 
67
 
65
   // send a notification to this player's chat window
68
   // send a notification to this player's chat window
66
   Interlocutor_Notify (Interlocutor_FindOrCreate (sendchallenge.challengee), LOCALIZE (L"Chat_InvitationSent"), sendchallenge.challengee);
69
   Interlocutor_Notify (Interlocutor_FindOrCreate (sendchallenge.challengee), LOCALIZE (L"Chat_InvitationSent"), sendchallenge.challengee);
67
   return; // finished, invitation is sent
70
   return; // finished, invitation is sent
68
}
71
}
Line 157... Line 160...
157
            sendchallenge.initial_time = 2; // default value
160
            sendchallenge.initial_time = 2; // default value
158
         sendchallenge.increment = GetDlgItemInt (hWnd, EDITBOX_SENDCHALLENGE_INCREMENT, &was_translated, false);
161
         sendchallenge.increment = GetDlgItemInt (hWnd, EDITBOX_SENDCHALLENGE_INCREMENT, &was_translated, false);
159
         if (!was_translated)
162
         if (!was_translated)
160
            sendchallenge.increment = 12; // default value
163
            sendchallenge.increment = 12; // default value
161
         sendchallenge.is_rated = (Button_GetCheck (GetDlgItem (hWnd, CHECKBOX_SENDCHALLENGE_RATETHISGAME)) != 0);
164
         sendchallenge.is_rated = (Button_GetCheck (GetDlgItem (hWnd, CHECKBOX_SENDCHALLENGE_RATETHISGAME)) != 0);
-
 
165
 
-
 
166
         sendchallenge.game_rules[0] = 0; // TODO: support other game rules
162
 
167
 
163
         EndDialog (hWnd, 1); // close the dialog box and return OK
168
         EndDialog (hWnd, 1); // close the dialog box and return OK
164
      }
169
      }
165
 
170
 
166
      // else was it the status bar hyperlink ?
171
      // else was it the status bar hyperlink ?