10015
|
1 |
/*
|
|
2 |
* Hedgewars, a free turn based strategy game
|
|
3 |
* Copyright (C) 2012 Simeon Maxein <smaxein@googlemail.com>
|
|
4 |
*
|
|
5 |
* This program is free software; you can redistribute it and/or
|
|
6 |
* modify it under the terms of the GNU General Public License
|
|
7 |
* as published by the Free Software Foundation; either version 2
|
|
8 |
* of the License, or (at your option) any later version.
|
|
9 |
*
|
|
10 |
* This program is distributed in the hope that it will be useful,
|
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13 |
* GNU General Public License for more details.
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License
|
|
16 |
* along with this program; if not, write to the Free Software
|
|
17 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
18 |
*/
|
|
19 |
|
|
20 |
/**
|
|
21 |
* Common definitions needed by netconn functions, to allow splitting them into several files.
|
|
22 |
*/
|
|
23 |
|
|
24 |
#ifndef NETCONN_INTERNAL_H_
|
|
25 |
#define NETCONN_INTERNAL_H_
|
|
26 |
|
|
27 |
#include "netconn.h"
|
|
28 |
#include "netbase.h"
|
|
29 |
#include "../model/map.h"
|
|
30 |
#include "../model/team.h"
|
|
31 |
#include "../model/weapon.h"
|
|
32 |
#include "../model/room.h"
|
|
33 |
|
|
34 |
#include <stdbool.h>
|
|
35 |
#include <stdint.h>
|
|
36 |
#include <stddef.h>
|
|
37 |
|
|
38 |
struct _flib_netconn {
|
|
39 |
flib_netbase *netBase;
|
|
40 |
char *playerName;
|
|
41 |
char *dataDirPath;
|
|
42 |
|
|
43 |
int netconnState; //!< One of the NETCONN_STATE constants
|
|
44 |
|
|
45 |
bool isChief; //!< Player can modify the current room
|
|
46 |
flib_map *map;
|
|
47 |
flib_teamlist pendingTeamlist;
|
|
48 |
flib_teamlist teamlist;
|
|
49 |
flib_scheme *scheme;
|
|
50 |
char *style;
|
|
51 |
flib_weaponset *weaponset;
|
|
52 |
|
|
53 |
void (*onMessageCb)(void *context, int msgtype, const char *msg);
|
|
54 |
void *onMessageCtx;
|
|
55 |
|
|
56 |
void (*onConnectedCb)(void *context);
|
|
57 |
void *onConnectedCtx;
|
|
58 |
|
|
59 |
void (*onDisconnectedCb)(void *context, int reason, const char *message);
|
|
60 |
void *onDisconnectedCtx;
|
|
61 |
|
|
62 |
void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount);
|
|
63 |
void *onRoomlistCtx;
|
|
64 |
|
|
65 |
void (*onRoomAddCb)(void *context, const flib_room *room);
|
|
66 |
void *onRoomAddCtx;
|
|
67 |
|
|
68 |
void (*onRoomDeleteCb)(void *context, const char *name);
|
|
69 |
void *onRoomDeleteCtx;
|
|
70 |
|
|
71 |
void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room);
|
|
72 |
void *onRoomUpdateCtx;
|
|
73 |
|
|
74 |
void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState);
|
|
75 |
void *onClientFlagsCtx;
|
|
76 |
|
|
77 |
void (*onChatCb)(void *context, const char *nick, const char *msg);
|
|
78 |
void *onChatCtx;
|
|
79 |
|
|
80 |
void (*onLobbyJoinCb)(void *context, const char *nick);
|
|
81 |
void *onLobbyJoinCtx;
|
|
82 |
|
|
83 |
void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage);
|
|
84 |
void *onLobbyLeaveCtx;
|
|
85 |
|
|
86 |
void (*onRoomJoinCb)(void *context, const char *nick);
|
|
87 |
void *onRoomJoinCtx;
|
|
88 |
|
|
89 |
void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage);
|
|
90 |
void *onRoomLeaveCtx;
|
|
91 |
|
|
92 |
void (*onNickTakenCb)(void *context, const char *nick);
|
|
93 |
void *onNickTakenCtx;
|
|
94 |
|
|
95 |
void (*onPasswordRequestCb)(void *context, const char *nick);
|
|
96 |
void *onPasswordRequestCtx;
|
|
97 |
|
|
98 |
void (*onEnterRoomCb)(void *context, bool chief);
|
|
99 |
void *onEnterRoomCtx;
|
|
100 |
|
|
101 |
void (*onLeaveRoomCb)(void *context, int reason, const char *message);
|
|
102 |
void *onLeaveRoomCtx;
|
|
103 |
|
|
104 |
void (*onTeamAddCb)(void *context, const flib_team *team);
|
|
105 |
void *onTeamAddCtx;
|
|
106 |
|
|
107 |
void (*onTeamDeleteCb)(void *context, const char *teamname);
|
|
108 |
void *onTeamDeleteCtx;
|
|
109 |
|
|
110 |
void (*onRunGameCb)(void *context);
|
|
111 |
void *onRunGameCtx;
|
|
112 |
|
|
113 |
void (*onTeamAcceptedCb)(void *context, const char *teamName);
|
|
114 |
void *onTeamAcceptedCtx;
|
|
115 |
|
|
116 |
void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs);
|
|
117 |
void *onHogCountChangedCtx;
|
|
118 |
|
|
119 |
void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex);
|
|
120 |
void *onTeamColorChangedCtx;
|
|
121 |
|
|
122 |
void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size);
|
|
123 |
void *onEngineMessageCtx;
|
|
124 |
|
|
125 |
void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme);
|
|
126 |
void *onSchemeChangedCtx;
|
|
127 |
|
|
128 |
void (*onMapChangedCb)(void *context, const flib_map *map, int changetype);
|
|
129 |
void *onMapChangedCtx;
|
|
130 |
|
|
131 |
void (*onScriptChangedCb)(void *context, const char *script);
|
|
132 |
void *onScriptChangedCtx;
|
|
133 |
|
|
134 |
void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset);
|
|
135 |
void *onWeaponsetChangedCtx;
|
|
136 |
|
|
137 |
void (*onServerVarCb)(void *context, const char *name, const char *value);
|
|
138 |
void *onServerVarCtx;
|
|
139 |
|
|
140 |
bool running;
|
|
141 |
bool destroyRequested;
|
|
142 |
};
|
|
143 |
|
|
144 |
void netconn_clearCallbacks(flib_netconn *conn);
|
|
145 |
void netconn_leaveRoom(flib_netconn *conn);
|
|
146 |
void netconn_setMap(flib_netconn *conn, const flib_map *map);
|
|
147 |
void netconn_setWeaponset(flib_netconn *conn, const flib_weaponset *weaponset);
|
|
148 |
void netconn_setScript(flib_netconn *conn, const char *script);
|
|
149 |
void netconn_setScheme(flib_netconn *conn, const flib_scheme *scheme);
|
|
150 |
|
|
151 |
#endif
|