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