X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=network.h;h=bb019fb7b9e39bb3ec0683d9bcaa3b191e58ae0e;hb=b1f5771eda7a9788b86604a4368eb83babdf486d;hp=f97cfbc8f5fdfeb3d50b4009b03c51fb07306e07;hpb=91d035f4845a6f9f62487b43e5142c4148e7f047;p=carveJwlIkooP6JGAAIwe30JlM.git diff --git a/network.h b/network.h index f97cfbc..bb019fb 100644 --- a/network.h +++ b/network.h @@ -1,8 +1,61 @@ +/* + * Copyright (C) 2021-2022 Mt.ZERO Software, Harry Godden - All Rights Reserved + * All trademarks are property of their respective owners + */ + #ifndef NETWORK_H #define NETWORK_H #include "vg/vg_stdint.h" +#include "steam.h" +#include "network_msg.h" +#include "highscores.h" + +static int network_scores_updated = 0; + +/* + * Interface + */ +//#define SR_USE_LOCALHOST + +/* Call it at start; Connects us to the gameserver */ +static void network_init(void); + +/* Run this from main loop */ +static void network_update(void); + +/* Call it at shutdown */ +static void network_end(void); + +/* + * Can buffer up a bunch of these by calling many times, they will be + * sent at the next connection + */ +static void network_submit_highscore( u32 trackid, u16 points, u16 time ); + +/* + * Game endpoints are provided with the same names to allow running without a + * network connection. + */ + +struct { + u8 app_symmetric_key[ 1024 ]; + u32 app_key_length; + EServerMode auth_mode; + + HSteamNetConnection remote; + ESteamNetworkingConnectionState state; + + f64 last_attempt, last_frame; + u32 retries; + i32 network_info; +} +static network_client = { + .state = k_ESteamNetworkingConnectionState_None, + .auth_mode = eServerModeAuthentication, +}; +static int packet_minsize( SteamNetworkingMessage_t *msg, u32 size ); #endif /* NETWORK_H */