project_files/frontlib/net/netconn_internal.h
changeset 10017 de822cd3df3a
parent 10015 4feced261c68
equal deleted inserted replaced
10015:4feced261c68 10017:de822cd3df3a
    34 #include <stdbool.h>
    34 #include <stdbool.h>
    35 #include <stdint.h>
    35 #include <stdint.h>
    36 #include <stddef.h>
    36 #include <stddef.h>
    37 
    37 
    38 struct _flib_netconn {
    38 struct _flib_netconn {
    39 	flib_netbase *netBase;
    39     flib_netbase *netBase;
    40 	char *playerName;
    40     char *playerName;
    41 	char *dataDirPath;
    41     char *dataDirPath;
    42 
    42 
    43 	int netconnState;			//!< One of the NETCONN_STATE constants
    43     int netconnState;           //!< One of the NETCONN_STATE constants
    44 
    44 
    45 	bool isChief;				//!< Player can modify the current room
    45     bool isChief;               //!< Player can modify the current room
    46 	flib_map *map;
    46     flib_map *map;
    47 	flib_teamlist pendingTeamlist;
    47     flib_teamlist pendingTeamlist;
    48 	flib_teamlist teamlist;
    48     flib_teamlist teamlist;
    49 	flib_scheme *scheme;
    49     flib_scheme *scheme;
    50 	char *style;
    50     char *style;
    51 	flib_weaponset *weaponset;
    51     flib_weaponset *weaponset;
    52 
    52 
    53 	void (*onMessageCb)(void *context, int msgtype, const char *msg);
    53     void (*onMessageCb)(void *context, int msgtype, const char *msg);
    54 	void *onMessageCtx;
    54     void *onMessageCtx;
    55 
    55 
    56 	void (*onConnectedCb)(void *context);
    56     void (*onConnectedCb)(void *context);
    57 	void *onConnectedCtx;
    57     void *onConnectedCtx;
    58 
    58 
    59 	void (*onDisconnectedCb)(void *context, int reason, const char *message);
    59     void (*onDisconnectedCb)(void *context, int reason, const char *message);
    60 	void *onDisconnectedCtx;
    60     void *onDisconnectedCtx;
    61 
    61 
    62 	void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount);
    62     void (*onRoomlistCb)(void *context, const flib_room **rooms, int roomCount);
    63 	void *onRoomlistCtx;
    63     void *onRoomlistCtx;
    64 
    64 
    65 	void (*onRoomAddCb)(void *context, const flib_room *room);
    65     void (*onRoomAddCb)(void *context, const flib_room *room);
    66 	void *onRoomAddCtx;
    66     void *onRoomAddCtx;
    67 
    67 
    68 	void (*onRoomDeleteCb)(void *context, const char *name);
    68     void (*onRoomDeleteCb)(void *context, const char *name);
    69 	void *onRoomDeleteCtx;
    69     void *onRoomDeleteCtx;
    70 
    70 
    71 	void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room);
    71     void (*onRoomUpdateCb)(void *context, const char *oldName, const flib_room *room);
    72 	void *onRoomUpdateCtx;
    72     void *onRoomUpdateCtx;
    73 
    73 
    74 	void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState);
    74     void (*onClientFlagsCb)(void *context, const char *nick, const char *flags, bool newFlagState);
    75 	void *onClientFlagsCtx;
    75     void *onClientFlagsCtx;
    76 
    76 
    77 	void (*onChatCb)(void *context, const char *nick, const char *msg);
    77     void (*onChatCb)(void *context, const char *nick, const char *msg);
    78 	void *onChatCtx;
    78     void *onChatCtx;
    79 
    79 
    80 	void (*onLobbyJoinCb)(void *context, const char *nick);
    80     void (*onLobbyJoinCb)(void *context, const char *nick);
    81 	void *onLobbyJoinCtx;
    81     void *onLobbyJoinCtx;
    82 
    82 
    83 	void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage);
    83     void (*onLobbyLeaveCb)(void *context, const char *nick, const char *partMessage);
    84 	void *onLobbyLeaveCtx;
    84     void *onLobbyLeaveCtx;
    85 
    85 
    86 	void (*onRoomJoinCb)(void *context, const char *nick);
    86     void (*onRoomJoinCb)(void *context, const char *nick);
    87 	void *onRoomJoinCtx;
    87     void *onRoomJoinCtx;
    88 
    88 
    89 	void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage);
    89     void (*onRoomLeaveCb)(void *context, const char *nick, const char *partMessage);
    90 	void *onRoomLeaveCtx;
    90     void *onRoomLeaveCtx;
    91 
    91 
    92 	void (*onNickTakenCb)(void *context, const char *nick);
    92     void (*onNickTakenCb)(void *context, const char *nick);
    93 	void *onNickTakenCtx;
    93     void *onNickTakenCtx;
    94 
    94 
    95 	void (*onPasswordRequestCb)(void *context, const char *nick);
    95     void (*onPasswordRequestCb)(void *context, const char *nick);
    96 	void *onPasswordRequestCtx;
    96     void *onPasswordRequestCtx;
    97 
    97 
    98 	void (*onEnterRoomCb)(void *context, bool chief);
    98     void (*onEnterRoomCb)(void *context, bool chief);
    99 	void *onEnterRoomCtx;
    99     void *onEnterRoomCtx;
   100 
   100 
   101 	void (*onLeaveRoomCb)(void *context, int reason, const char *message);
   101     void (*onLeaveRoomCb)(void *context, int reason, const char *message);
   102 	void *onLeaveRoomCtx;
   102     void *onLeaveRoomCtx;
   103 
   103 
   104 	void (*onTeamAddCb)(void *context, const flib_team *team);
   104     void (*onTeamAddCb)(void *context, const flib_team *team);
   105 	void *onTeamAddCtx;
   105     void *onTeamAddCtx;
   106 
   106 
   107 	void (*onTeamDeleteCb)(void *context, const char *teamname);
   107     void (*onTeamDeleteCb)(void *context, const char *teamname);
   108 	void *onTeamDeleteCtx;
   108     void *onTeamDeleteCtx;
   109 
   109 
   110 	void (*onRunGameCb)(void *context);
   110     void (*onRunGameCb)(void *context);
   111 	void *onRunGameCtx;
   111     void *onRunGameCtx;
   112 
   112 
   113 	void (*onTeamAcceptedCb)(void *context, const char *teamName);
   113     void (*onTeamAcceptedCb)(void *context, const char *teamName);
   114 	void *onTeamAcceptedCtx;
   114     void *onTeamAcceptedCtx;
   115 
   115 
   116 	void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs);
   116     void (*onHogCountChangedCb)(void *context, const char *teamName, int hogs);
   117 	void *onHogCountChangedCtx;
   117     void *onHogCountChangedCtx;
   118 
   118 
   119 	void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex);
   119     void (*onTeamColorChangedCb)(void *context, const char *teamName, int colorIndex);
   120 	void *onTeamColorChangedCtx;
   120     void *onTeamColorChangedCtx;
   121 
   121 
   122 	void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size);
   122     void (*onEngineMessageCb)(void *context, const uint8_t *message, size_t size);
   123 	void *onEngineMessageCtx;
   123     void *onEngineMessageCtx;
   124 
   124 
   125 	void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme);
   125     void (*onSchemeChangedCb)(void *context, const flib_scheme *scheme);
   126 	void *onSchemeChangedCtx;
   126     void *onSchemeChangedCtx;
   127 
   127 
   128 	void (*onMapChangedCb)(void *context, const flib_map *map, int changetype);
   128     void (*onMapChangedCb)(void *context, const flib_map *map, int changetype);
   129 	void *onMapChangedCtx;
   129     void *onMapChangedCtx;
   130 
   130 
   131 	void (*onScriptChangedCb)(void *context, const char *script);
   131     void (*onScriptChangedCb)(void *context, const char *script);
   132 	void *onScriptChangedCtx;
   132     void *onScriptChangedCtx;
   133 
   133 
   134 	void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset);
   134     void (*onWeaponsetChangedCb)(void *context, const flib_weaponset *weaponset);
   135 	void *onWeaponsetChangedCtx;
   135     void *onWeaponsetChangedCtx;
   136 
   136 
   137 	void (*onServerVarCb)(void *context, const char *name, const char *value);
   137     void (*onServerVarCb)(void *context, const char *name, const char *value);
   138 	void *onServerVarCtx;
   138     void *onServerVarCtx;
   139 
   139 
   140 	bool running;
   140     bool running;
   141 	bool destroyRequested;
   141     bool destroyRequested;
   142 };
   142 };
   143 
   143 
   144 void netconn_clearCallbacks(flib_netconn *conn);
   144 void netconn_clearCallbacks(flib_netconn *conn);
   145 void netconn_leaveRoom(flib_netconn *conn);
   145 void netconn_leaveRoom(flib_netconn *conn);
   146 void netconn_setMap(flib_netconn *conn, const flib_map *map);
   146 void netconn_setMap(flib_netconn *conn, const flib_map *map);