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