~ubuntu-branches/ubuntu/maverick/crossfire-client/maverick

« back to all changes in this revision

Viewing changes to common/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Kari Pahula
  • Date: 2007-04-13 21:15:44 UTC
  • mfrom: (1.2.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070413211544-vjo6zesj6g0wgmwf
Tags: 1.10.0-1
* New upstream release
* Install the README, README-dev and TODO files specific to the GTK2
  client to the corresponding package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
const char *rcsid_common_client_c =
2
 
    "$Id: client.c,v 1.34 2006/05/21 10:32:55 akirschbaum Exp $";
 
2
    "$Id: client.c 5076 2006-11-04 08:15:16Z mwedel $";
3
3
/*
4
4
    Crossfire client, a client program for the crossfire program.
5
5
 
40
40
 */
41
41
 
42
42
 
 
43
#ifdef WIN32
 
44
#include <windows.h>
 
45
#define usleep(x) Sleep((x)/1000)
 
46
#endif
43
47
#include <client.h>
44
48
#include <external.h>
45
49
#include <errno.h>
46
50
#include <script.h>
 
51
#include <ctype.h>
47
52
 
48
53
#include "mapdata.h"
49
54
 
50
55
/* actually declare the globals */
51
56
 
52
 
char *server=SERVER,*client_libdir=NULL,*meta_server=META_SERVER;
 
57
#ifdef SERVER
 
58
char *server=SERVER;
 
59
#else
 
60
char *server=NULL;
 
61
#endif
 
62
 
 
63
char *client_libdir=NULL,*meta_server=META_SERVER;
53
64
char *image_file="", *sound_server="cfsndserv";
54
65
char *skill_names[MAX_SKILL];
55
66
 
58
69
    maxfd,map1cmd=0,metaserver_on=METASERVER;
59
70
uint32  tick=0;
60
71
 
 
72
uint16  exp_table_max=0;
 
73
uint64  *exp_table=NULL;
 
74
 
61
75
FILE *fpin,*fpout;
62
76
Client_Player cpl;
63
77
ClientSocket csocket;
127
141
    { "ExtendedInfoSet", (CmdProc)ExtendedInfoSetCmd, NODATA},
128
142
 
129
143
    { "query", (CmdProc)handle_query, ASCII},
130
 
    { "replyinfo", (CmdProc)ReplyInfoCmd, ASCII},
 
144
    { "replyinfo", ReplyInfoCmd, ASCII},
131
145
    { "ExtendedTextSet", (CmdProc)SinkCmd, NODATA},
132
146
};
133
147
 
159
173
            data++;
160
174
        }
161
175
        len = csocket->inbuf.len - (data - csocket->inbuf.buf);
162
 
        LOG(0,"Common::DoClient","Command:%s (%d)",csocket->inbuf.buf+2, len);
163
176
        for(i=0;i < NCOMMANDS;i++) {
164
177
            if (strcmp((char*)csocket->inbuf.buf+2,commands[i].cmdname)==0) {
165
178
                    script_watch((char*)csocket->inbuf.buf+2,data,len,commands[i].cmdformat);
174
187
    }
175
188
}
176
189
 
177
 
#ifndef WIN32
 
190
#ifdef WIN32
 
191
#define socklen_t int
 
192
#else
178
193
#include <netdb.h>
179
194
#include <sys/types.h>
180
195
#include <sys/socket.h>
188
203
 
189
204
int init_connection(char *host, int port)
190
205
{
191
 
    int fd = -1, oldbufsize, newbufsize=65535, buflen=sizeof(int);
 
206
    int fd = -1, oldbufsize, newbufsize=65535;
 
207
    socklen_t buflen=sizeof(int);
192
208
#if !HAVE_GETADDRINFO || WIN32
193
209
    struct sockaddr_in insock;
194
210
    struct protoent *protox;
258
274
        return -1;
259
275
#endif
260
276
 
261
 
    if (csocket.servername != NULL)
262
 
        free(csocket.servername);
 
277
    free(csocket.servername);
263
278
    csocket.servername = malloc(sizeof(char)*(strlen(host)+1));
264
279
    strcpy(csocket.servername, host);
265
280
 
356
371
                    want_config[CONFIG_LIGHTING]?1:0, face_info.faceset,
357
372
                    want_config[CONFIG_CACHE]);
358
373
 
 
374
    /* We can do this right now also - isn't any reason to wait */
 
375
    cs_print_string(csocket.fd,"requestinfo exp_table");
 
376
 
359
377
    use_config[CONFIG_MAPHEIGHT]=want_config[CONFIG_MAPHEIGHT];
360
378
    use_config[CONFIG_MAPWIDTH]=want_config[CONFIG_MAPWIDTH];
361
379
    mapdata_set_size(use_config[CONFIG_MAPWIDTH], use_config[CONFIG_MAPHEIGHT]);