QTfrontend/xfire.cpp
changeset 2948 3f21a9dc93d0
parent 2830 571a9deffeac
child 3229 9e7ded374113
equal deleted inserted replaced
2947:803b277e4894 2948:3f21a9dc93d0
    28 char *values[XFIRE_KEY_COUNT];
    28 char *values[XFIRE_KEY_COUNT];
    29 
    29 
    30 // xfire_init(): used to initialize all variables and set their default values
    30 // xfire_init(): used to initialize all variables and set their default values
    31 void xfire_init(void)
    31 void xfire_init(void)
    32 {
    32 {
    33 	if(use_xfire)
    33     if(use_xfire)
    34 		return;
    34         return;
    35 	use_xfire = XfireIsLoaded() == 1;
    35     use_xfire = XfireIsLoaded() == 1;
    36 	
    36     
    37 	if(!use_xfire)
    37     if(!use_xfire)
    38 		return;
    38         return;
    39 	
    39     
    40 	for(int i = 0; i < XFIRE_KEY_COUNT; i++)
    40     for(int i = 0; i < XFIRE_KEY_COUNT; i++)
    41 	{
    41     {
    42 		keys[i] = new char[256];
    42         keys[i] = new char[256];
    43 		values[i] = new char[256];
    43         values[i] = new char[256];
    44 		strcpy(keys[i], "");
    44         strcpy(keys[i], "");
    45 		strcpy(values[i], "");
    45         strcpy(values[i], "");
    46 	}
    46     }
    47 	
    47     
    48 	strcpy(keys[XFIRE_NICKNAME], "Nickname");
    48     strcpy(keys[XFIRE_NICKNAME], "Nickname");
    49 	strcpy(keys[XFIRE_ROOM], "Room");
    49     strcpy(keys[XFIRE_ROOM], "Room");
    50 	strcpy(keys[XFIRE_SERVER], "Server");
    50     strcpy(keys[XFIRE_SERVER], "Server");
    51 	strcpy(keys[XFIRE_STATUS], "Status");
    51     strcpy(keys[XFIRE_STATUS], "Status");
    52 	xfire_update();
    52     xfire_update();
    53 }
    53 }
    54 
    54 
    55 // xfire_free(): used to free up ressources used etc.
    55 // xfire_free(): used to free up ressources used etc.
    56 void xfire_free(void)
    56 void xfire_free(void)
    57 {
    57 {
    58 	if(!use_xfire)
    58     if(!use_xfire)
    59 		return;
    59         return;
    60 	
    60     
    61 	for(int i = 0; i < XFIRE_KEY_COUNT; i++)
    61     for(int i = 0; i < XFIRE_KEY_COUNT; i++)
    62 	{
    62     {
    63 		delete [] keys[i];
    63         delete [] keys[i];
    64 		delete [] values[i];
    64         delete [] values[i];
    65 	}
    65     }
    66 }
    66 }
    67 
    67 
    68 // xfire_setvalue(): set a specific value
    68 // xfire_setvalue(): set a specific value
    69 void xfire_setvalue(const XFIRE_KEYS status, const char *value)
    69 void xfire_setvalue(const XFIRE_KEYS status, const char *value)
    70 {
    70 {
    71 	if(!use_xfire || strlen(value) > 255)
    71     if(!use_xfire || strlen(value) > 255)
    72 		return;
    72         return;
    73 	strcpy(values[status], value);
    73     strcpy(values[status], value);
    74 }
    74 }
    75 
    75 
    76 // xfire_update(): submits current values to the xfire app
    76 // xfire_update(): submits current values to the xfire app
    77 void xfire_update(void)
    77 void xfire_update(void)
    78 {
    78 {
    79 	if(!use_xfire)
    79     if(!use_xfire)
    80 		return;
    80         return;
    81 	XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values);
    81     XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values);
    82 }
    82 }