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