e6407eb031d619ed2ebb839813efeba8af53f6c4
[carveJwlIkooP6JGAAIwe30JlM.git] / network.h
1 /*
2 * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved
3 * All trademarks are property of their respective owners
4 */
5
6 #ifndef NETWORK_H
7 #define NETWORK_H
8
9 #include "vg/vg_stdint.h"
10 #include "steam.h"
11 #include "network_msg.h"
12 #include "highscores.h"
13 #include "addon_types.h"
14
15 static int network_scores_updated = 0;
16
17 /*
18 * Interface
19 */
20 //#define SR_USE_LOCALHOST
21
22 /* Call it at start; Connects us to the gameserver */
23 static void network_init(void);
24
25 /* Run this from main loop */
26 static void network_update(void);
27
28 /* Call it at shutdown */
29 static void network_end(void);
30
31 /*
32 * Can buffer up a bunch of these by calling many times, they will be
33 * sent at the next connection
34 */
35 static void network_submit_highscore( u32 trackid, u16 points, u16 time );
36
37 /*
38 * Game endpoints are provided with the same names to allow running without a
39 * network connection.
40 */
41
42 struct {
43 u8 app_symmetric_key[ 1024 ];
44 u32 app_key_length;
45 EServerMode auth_mode;
46
47 HSteamNetConnection remote;
48 ESteamNetworkingConnectionState state;
49
50 f64 last_attempt, last_frame;
51 u32 retries;
52
53 i32 network_info;
54 }
55 static network_client = {
56 .state = k_ESteamNetworkingConnectionState_None,
57 .auth_mode = eServerModeAuthentication,
58 };
59
60 static int packet_minsize( SteamNetworkingMessage_t *msg, u32 size );
61 static void network_send_item( enum netmsg_playeritem_type type );
62
63 #endif /* NETWORK_H */