Selecting Remote Partners


Enumerations

enum  {
  SGP_NONE = 0x0,
  SGP_HOT_SEAT = 0x4,
  SGP_CYBIKO = 0x2,
  SGP_CYBIKO_EASY = 0x10,
  SGP_CYBIKO_HARD = 0x20,
  SGP_SINGLE_GAME = 0x40,
  SGP_CYLANDIA = 0x100,
  SGP_DONT_INVITE = 0x8000
}
enum  {
  SGP_RES_HOT_SEAT = -3L,
  SGP_RES_CYBIKO = -2L,
  SGP_RES_CYBIKO_EASY = -5L,
  SGP_RES_CYBIKO_HARD = -6L,
  SGP_RES_SINGLE_GAME = -7L
}
enum  invite_mode_t {
  IM_DEFAULT = 0x1000000,
  IM_GAME = 0x02000000,
  IM_CHAT = 0x3000000,
  IM_PHONEBOOK = 0x4000000
}

Functions

cyid_t select_partner (struct Process *ptr_process, int style, char *sz_partner_name)
cyid_t select_partner_Ex (struct Process *ptr_process, int style, char *sz_partner_name, char *sz_caption, cyid_t *exclude_cyids)
cyid_t select_app_partner (struct Process *ptr_process, char *sz_text, int style, char *sz_partner_name, char *sz_caption, long invite_mode, cyid_t *exclude_cyids)
cyid_t select_game_partner (struct Process *ptr_process, char *sz_game_name, long style, char *sz_partner_name)


Detailed Description

These structures allow the user to find a partner for a multiplayer game.


Enumeration Type Documentation

anonymous enum
 

"Select partner" dialog styles.

Enumeration values:
SGP_NONE   No additional strings.
SGP_HOT_SEAT   Allows user to select a game in hot seat mode on one CYBIKO computer.
SGP_CYBIKO   Allows the user to select the Cybiko computer as a game play partner.
SGP_CYBIKO_EASY   Allows the user to select the Cybiko computer as an Easy game play partner.
SGP_CYBIKO_HARD   Allows the user to select the Cybiko computer as a Hard game partner.
SGP_SINGLE_GAME   Allows the user to play the game without a partner.
SGP_CYLANDIA   Shows CYPETNAMEs instead of NICKNAMEs in the "select partner" dialog.
SGP_DONT_INVITE   Does not invite a partner; only selects nickname from list and retrieves the partner's Cy ID.

anonymous enum
 

Results of the "select partner" functions.

Enumeration values:
SGP_RES_HOT_SEAT   Game in hot seat mode on one CYBIKO computer.
SGP_RES_CYBIKO   Game with the CYBIKO computer as a partner.
SGP_RES_CYBIKO_EASY   Game with the CYBIKO computer as an Easy partner.
SGP_RES_CYBIKO_HARD   Game with the CYBIKO computer as a Hard partner.
SGP_RES_SINGLE_GAME   Game without a partner.

enum invite_mode_t
 

Modes of invitation.

Enumeration values:
IM_DEFAULT   Shows "Yes" and "No" buttons.
IM_GAME   Makes dialog text to look like "<NICKNAME> wants to play <GAME>. Play?" and shows "Yes" and "No" buttons
IM_CHAT   Shows "Chat" and "Cancel" buttons.
IM_PHONEBOOK   Makes dialog text to look like " wishes to send you a B-Card. Accept?" and shows "Yes" and "No" buttons


Function Documentation

cyid_t select_app_partner ( struct Process * ptr_process,
char * sz_text,
int style,
char * sz_partner_name,
char * sz_caption,
long invite_mode,
cyid_t * exclude_cyids )
 

Invites a partner to launch a specified application.
If the user's partner accepts the invitation, the application will launch on his CYBIKO computer. long module_main (int argc, char* argv[], bool start) of the invited application will have 2 parameters :

  • string with the partner's computer Cy ID
  • string with the partner's Cy Name
Parameters:
ptr_process   The pointer to the Process object that calls the function
sz_text   The invitation text or game name if the invite_mode is IM_GAME
style   The dialog style. This parameter can be any combination of the following values: SGP_NONE, SGP_HOT_SEAT, SGP_CYBIKO, SGP_CYBIKO_EASY, SGP_CYBIKO_HARD, SGP_SINGLE_GAME, SGP_CYLANDIA, SGP_DONT_INVITE
sz_partner_name   A pointer to the buffer in which the partner's Cy Name will be stored
sz_caption   The "select partner" dialog caption
invite_move   An invitation mode. This parameter can be one of the following values: IM_DEFAULT, IM_CHAT, IM_GAME, IM_PHONEBOOK
exclude_cyids   An array of computer's Cy IDs, whose Cy Names will be excluded from the "select partner" dialog
Returns:
If the function succeeds, the Cy ID of the partner's computer, or special ID ( SGP_RES_HOT_SEAT, SGP_RES_CYBIKO, SGP_RES_CYBIKO_EASY, SGP_RES_CYBIKO_HARD, SGP_RES_SINGLE_GAME ). If the function fails or player presses "Escape", the return value is 0
       #include <cybiko.h>
       ...
       long main( int argc, char* argv[], int start )
       {
         ...
         struct module_t main_module;
         char sz_partner_name[9];
         cyid_t partner_id;
         cyid_t exclude_list[2] = { 110, 0 };
         ...
         init_module( &main_module );
         ...
         if(argc != 1)       //  Application was invited.
         {
           partner_id = atoul(argv[1]);
           strcpy(sz_partner_name, argv[2]);
         }
         else               //  Application will invite another application.
         {
           //  Nickname of the computer with Cy ID 110 will be excluded from the
           //  list of available partners.
           partner_id = select_app_partner( main_module.m_process,
                                            "Enter private chat?",
                                            SGP_NONE,
                                            sz_partner_name,
                                            "Available Partners",
                                            IM_CHAT,
                                            exclude_list );
         }
         ...
         TRACE("Partner name: %s, partner computer id: %ld", sz_partner_name, partner_id );
         ...
       }

cyid_t select_game_partner ( struct Process * ptr_process,
char * sz_game_name,
long style,
char * sz_partner_name )
 

Select a partner for single or multi-player games.
If the user's partner accepts the invitation, the game will launch on his CYBIKO computer. long module_main (int argc, char* argv[], bool start) of the invited application will have 2 parameters :

  • string with partner's computer's Cy ID
  • string with partner's Cy Name
Parameters:
ptr_process   The pointer to the Process object, that calls the function
sz_game_name   The name of the game the user wants his partner to play with him
style   The dialog style. This parameter can be any combination of the following values: SGP_NONE, SGP_HOT_SEAT, SGP_CYBIKO, SGP_CYBIKO_EASY, SGP_CYBIKO_HARD, SGP_SINGLE_GAME, SGP_CYLANDIA, SGP_DONT_INVITE
sz_partner_name   A pointer to the buffer in which the partner's Cy Name of your will be stored
Returns:
If the function succeeds, Cy ID of the partner's computer, or special ID ( SGP_RES_HOT_SEAT, SGP_RES_CYBIKO, SGP_RES_CYBIKO_EASY, SGP_RES_CYBIKO_HARD, SGP_RES_SINGLE_GAME ). If the function fails or the player presses "Escape", the return value is 0
       #include <cybiko.h>
       ...
       long main( int argc, char* argv[], int start )
       {
         ...
         struct module_t main_module;
         char sz_partner_name[9];
         cyid_t partner_id;
         ...
         init_module( &main_module );
         ...
         if(argc != 1)       //  Application was invited.
         {
           partner_id = atoul(argv[1]); 
           strcpy(sz_partner_name, argv[2]);
         }
         else               //  Application will invite another application.
         {
           partner_id = select_game_partner( main_module.m_process,
                                             "Billiard",
                                             SGP_CYBIKO | SGP_HOT_SEAT,
                                             sz_partner_name );
         }
         ...
         TRACE("Partner name: %s, partner computer id: %ld", sz_partner_name, partner_id );
         ...
       }

cyid_t select_partner ( struct Process * ptr_process,
int style,
char * sz_partner_name )
 

Selects a partner.

Parameters:
ptr_process   The pointer to the Process object, that calls the function
style   The dialog style. This parameter can be any combination of the following values: SGP_NONE, SGP_HOT_SEAT, SGP_CYBIKO, SGP_CYBIKO_EASY, SGP_CYBIKO_HARD, SGP_SINGLE_GAME, SGP_CYLANDIA, SGP_DONT_INVITE
sz_partner_name   A pointer to the buffer in which the partner's Cy Name will be stored
Returns:
If the function succeeds, ID of the partner's computer, or special ID ( SGP_RES_HOT_SEAT, SGP_RES_CYBIKO, SGP_RES_CYBIKO_EASY, SGP_RES_CYBIKO_HARD, SGP_RES_SINGLE_GAME ). If the function fails or player presses "Escape", the return value is 0
       #include <cybiko.h>
       ...
       struct module_t main_module;
       char sz_partner_name[9];
       cyid_t partner_id;
       ...
       init_module( &main_module );
       ...
       partner_id = select_partner( main_module.m_process, 
                                    SGP_SINGLE_GAME, 
                                    sz_partner_name );
       if( ( partner_id ) 
          && ( partner_id != SGP_RES_SINGLE_GAME ) )
       {
         ...
         TRACE("Partner name: %s, partner computer id: %ld", sz_partner_name, partner_id );
         ...
       }
       ...
See also:
select_partner_Ex.

cyid_t select_partner_Ex ( struct Process * ptr_process,
int style,
char * sz_partner_name,
char * sz_caption,
cyid_t * exclude_cyids )
 

Extended version of the select_partner function.

Parameters:
ptr_process   The pointer to the Process object, that calls the function
sz_partner_name   A pointer to the buffer in which the partner's Cy Name will be stored
style   The dialog style. This parameter can be any combination of the following values: SGP_NONE, SGP_HOT_SEAT, SGP_CYBIKO, SGP_CYBIKO_EASY, SGP_CYBIKO_HARD, SGP_SINGLE_GAME, SGP_CYLANDIA, SGP_DONT_INVITE
sz_caption   The "select partner" dialog caption
exclude_cyids   NULL-terminated array of the Cybiko computer's IDs, whose Cy Names will be excluded from the "select partner" dialog
Returns:
If the function succeeds, Cy ID of the partner computer or special ID ( SGP_RES_HOT_SEAT, SGP_RES_CYBIKO, SGP_RES_CYBIKO_EASY, SGP_RES_CYBIKO_HARD, SGP_RES_SINGLE_GAME ). If the function fails or player presses "Escape", the return value is 0
       #include <cybiko.h>
       ...
       struct module_t main_module;
       char sz_partner_name[9];
       cyid_t partner_id;
       cyid_t exclude_list[2] = { 110, 0 };
       ...
       init_module( &main_module );
       ...
       //  Nickname of the computer with Cy ID 110 will be excluded from the
       //  list of available partners.
       partner_id = select_partner_Ex( main_module.m_process,
                                       SGP_SINGLE_GAME,
                                       sz_partner_name,
                                       "Available Partners",
                                       exclude_list );
       if( ( partner_id ) && ( partner_id != SGP_RES_SINGLE_GAME ) )
       {
         ...
         TRACE("Partner name: %s, partner computer id: %ld", sz_partner_name, partner_id );
         ...
       }
       ...
See also:
select_partner.