test network 2
[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
14 static int network_scores_updated = 0;
15
16 /*
17 * Interface
18 */
19 //#define SR_USE_LOCALHOST
20
21 /* Call it at start; Connects us to the gameserver */
22 static void network_init(void);
23
24 /* Run this from main loop */
25 static void network_update(void);
26
27 /* Call it at shutdown */
28 static void network_end(void);
29
30 /*
31 * Can buffer up a bunch of these by calling many times, they will be
32 * sent at the next connection
33 */
34 static void network_submit_highscore( u32 trackid, u16 points, u16 time );
35
36 /*
37 * Game endpoints are provided with the same names to allow running without a
38 * network connection.
39 */
40
41 struct {
42 u8 app_symmetric_key[ 1024 ];
43 u32 app_key_length;
44 EServerMode auth_mode;
45
46 HSteamNetConnection remote;
47 ESteamNetworkingConnectionState state;
48
49 f64 last_attempt, last_frame;
50 u32 retries;
51
52 i32 network_info;
53 }
54 static network_client = {
55 .state = k_ESteamNetworkingConnectionState_None,
56 .auth_mode = eServerModeAuthentication,
57 };
58
59 static int packet_minsize( SteamNetworkingMessage_t *msg, u32 size );
60
61 #endif /* NETWORK_H */