QTfrontend/xfire.cpp
author mk12
Fri, 07 Dec 2012 16:03:53 -0500
changeset 8266 927da572bcdc
parent 6952 7f70f37bbf08
permissions -rw-r--r--
will fix this http://code.google.com/p/hedgewars/source/detail?r=9f0e79ab51f00f3b1e133ae70cdd63f6963439c0 and will allow hedgewars to build without video recording enabled, for the time being although i want to talk to koda or someone to understand what should be #ifdef'd and if i've done too much or too little.. but at least that will let it build
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     1
/*
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 3972
diff changeset
     2
 * Hedgewars, a free turn based strategy game
6952
7f70f37bbf08 license header year range adjustments
sheepluva
parents: 6700
diff changeset
     3
 * Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com>
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     4
 *
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     8
 *
67815ee123d7 Frontend:
smxx
parents:
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    12
 * GNU General Public License for more details.
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    13
 *
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    14
 * You should have received a copy of the GNU General Public License
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    15
 * along with this program; if not, write to the Free Software
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    17
 */
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    18
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    19
#include <string>
3229
9e7ded374113 Fix build
unc0rr
parents: 2948
diff changeset
    20
#include <cstring>
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    21
#include <stdio.h>
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    22
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    23
#include "xfire.h"
2830
571a9deffeac Frontend:
smxx
parents: 2821
diff changeset
    24
#include "../misc/xfire/xfiregameclient.h"
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    25
6573
632fa142c2cf small tweak for compiling with xfire and qt under windows
bovi
parents: 4976
diff changeset
    26
#ifdef USE_XFIRE
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    27
// use_xfire: stores if xfire is loaded and functions should do something at all
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    28
bool use_xfire = false;
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    29
char *keys[XFIRE_KEY_COUNT];
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    30
char *values[XFIRE_KEY_COUNT];
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    31
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    32
// xfire_init(): used to initialize all variables and set their default values
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    33
void xfire_init(void)
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    34
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    35
    if(use_xfire)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    36
        return;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    37
    use_xfire = XfireIsLoaded() == 1;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3229
diff changeset
    38
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    39
    if(!use_xfire)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    40
        return;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3229
diff changeset
    41
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    42
    for(int i = 0; i < XFIRE_KEY_COUNT; i++)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    43
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    44
        keys[i] = new char[256];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    45
        values[i] = new char[256];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    46
        strcpy(keys[i], "");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    47
        strcpy(values[i], "");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    48
    }
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3229
diff changeset
    49
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    50
    strcpy(keys[XFIRE_NICKNAME], "Nickname");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    51
    strcpy(keys[XFIRE_ROOM], "Room");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    52
    strcpy(keys[XFIRE_SERVER], "Server");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    53
    strcpy(keys[XFIRE_STATUS], "Status");
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    54
    xfire_update();
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    55
}
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    56
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    57
// xfire_free(): used to free up ressources used etc.
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    58
void xfire_free(void)
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    59
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    60
    if(!use_xfire)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    61
        return;
3697
d5b30d6373fc remove trailing spaces from end of line
koda
parents: 3229
diff changeset
    62
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    63
    for(int i = 0; i < XFIRE_KEY_COUNT; i++)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    64
    {
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    65
        delete [] keys[i];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    66
        delete [] values[i];
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    67
    }
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    68
}
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    69
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    70
// xfire_setvalue(): set a specific value
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    71
void xfire_setvalue(const XFIRE_KEYS status, const char *value)
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    72
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    73
    if(!use_xfire || strlen(value) > 255)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    74
        return;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    75
    strcpy(values[status], value);
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    76
}
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    77
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    78
// xfire_update(): submits current values to the xfire app
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    79
void xfire_update(void)
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    80
{
2948
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    81
    if(!use_xfire)
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    82
        return;
3f21a9dc93d0 Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents: 2830
diff changeset
    83
    XfireSetCustomGameDataA(XFIRE_KEY_COUNT, (const char**)keys, (const char**)values);
2821
67815ee123d7 Frontend:
smxx
parents:
diff changeset
    84
}
6573
632fa142c2cf small tweak for compiling with xfire and qt under windows
bovi
parents: 4976
diff changeset
    85
#endif // USE_XFIRE