File: client.h

package info (click to toggle)
conquest 8.1-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 7,984 kB
  • ctags: 3,086
  • sloc: ansic: 39,393; sh: 8,540; yacc: 446; makefile: 296; lex: 146
file content (93 lines) | stat: -rw-r--r-- 2,701 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* 
 * Per client (conquest) info
 *
 * $Id: client.h,v 1.6 2004/08/09 00:45:36 jon Exp $
 *
 * Copyright 2003 Jon Trulson under the ARTISTIC LICENSE. (See LICENSE).
 */

#ifndef CLIENT_H_INCLUDED
#define CLIENT_H_INCLUDED

#include "conqdef.h"
#include "datatypes.h"
#include "conqnet.h"
#include "protocol.h"
#include "packet.h"

#ifdef CLIENT_NOEXTERN
# define EXTERNAL 
#else
# define EXTERNAL extern
#endif

#define CLT_STATE_NONE      0x00000000	
#define CLT_STATE_PREINIT   0x00000001	/* local init */
#define CLT_STATE_INIT      0x00000002	/* negotiate with client/login */
#define CLT_STATE_MAINMENU  0x00000004	/* in main menu */
#define CLT_STATE_PLAYMENU  0x00000008	/* a menu/info screen engaged
					   during play */
#define CLT_STATE_PLAY      0x00000010	/* playing */
#define CLT_STATE_TERMINATE 0x00000020	/* terminating */

typedef struct {
  int sock;			/* socket to client */
  int usock;			/* UDP socket to client */
  int doUDP;                    /* whether we should look for udp packets */
  int tryUDP;                   /* should we try UDP? */
  struct sockaddr_in  servaddr;
  Unsgn32 state;		/* current state */
  Unsgn32 serverDead;		/* is the client dead/ */
  Unsgn32 isLoggedIn;		/* is the client logged in? */
  Unsgn8 localhost[MAXHOSTNAME];
  Unsgn8 *remotehost; /* self evident */
  Unsgn16 remoteport;
} ClientInfo_t;

EXTERNAL ClientInfo_t cInfo;
EXTERNAL spHello_t sHello;		/* some server info we want to keep */
EXTERNAL spServerStat_t sStat;		/* server status info */
#ifdef CLIENT_NOEXTERN
int lastServerError = 0;	/* set by an ACK from server */
Unsgn8 clientFlags = 0;         /* set according to CLIENTSTAT packets */
#else
EXTERNAL int lastServerError;
EXTERNAL Unsgn8 clientFlags;    
#endif

#undef EXTERNAL

int sendAuth(int sock, Unsgn8 flag, Unsgn8 *login, Unsgn8 *pw);
int sendSetCourse(int sock, Sgn8 lock, real head);

/* packet proc routines */
int procUser(Unsgn8 *buf);
int procShip(Unsgn8 *buf);
int procShipSml(Unsgn8 *buf);
int procShipLoc(Unsgn8 *buf);
int procPlanet(Unsgn8 *buf);
int procPlanetSml(Unsgn8 *buf);
int procPlanetLoc(Unsgn8 *buf);
int procPlanetLoc2(Unsgn8 *buf);
int procPlanetInfo(Unsgn8 *buf);
int procTorp(Unsgn8 *buf);
int procTorpLoc(Unsgn8 *buf);
int procTorpEvent(Unsgn8 *buf);
int procTeam(Unsgn8 *buf);
int procMessage(Unsgn8 *buf);
int procServerStat(Unsgn8 *buf);
int procConqInfo(Unsgn8 *buf);
int procHistory(Unsgn8 *buf);
int procDoomsday(Unsgn8 *buf);

int sendSetName(Unsgn8 *name);
int sendCommand(Unsgn8 cmd, Unsgn16 detail);
int sendFireTorps(int num, real dir);
int sendMessage(int to, char *msg);

int clientHello(char *clientname);

void processPacket(Unsgn8 *buf);


#endif /* CLIENT_H_INCLUDED */