begin network integration
[carveJwlIkooP6JGAAIwe30JlM.git] / steam.h
1 #ifndef STEAM_H
2 #define STEAM_H
3
4 #include "vg/vg_steam.h"
5 #include "vg/vg_steam_networking.h"
6 #include "vg/vg_steam_auth.h"
7 #include "vg/vg_steam_http.h"
8
9 /*
10 * We only want to use steamworks if building for the networked version,
11 * theres not much point otherwise. We mainly want steamworks for setting
12 * achievements etc.. so that includes our own server too.
13 *
14 * This file also wraps the functions and interfaces that we want to use to
15 * make them a bit easier to read, since they are the flat API they have very
16 * long names. in non-networked builds they will return default errors or do
17 * nothing.
18 */
19
20 static int steam_ready = 0;
21 static void *hSteamNetworkingSockets,
22 *hSteamUser;
23
24 static HSteamPipe hSteamClientPipe;
25
26 static void steam_init(void)
27 {
28 #ifdef SR_NETWORKED
29 if( !SteamAPI_Init() )
30 {
31 vg_error( "Steamworks failed to initialize\n" );
32 return;
33 }
34 steam_ready = 1;
35
36 SteamAPI_ManualDispatch_Init();
37 vg_success( "Steamworks API running\n" );
38
39 /* Connect interfaces */
40 hSteamClientPipe = SteamAPI_GetHSteamPipe();
41 hSteamNetworkingSockets = SteamAPI_SteamNetworkingSockets_SteamAPI();
42 hSteamUser = SteamAPI_SteamUser();
43 #endif
44 }
45
46 static void steam_update(void)
47 {
48 if( steam_ready )
49 steamworks_event_loop( hSteamClientPipe );
50 }
51
52 static void steam_end(void)
53 {
54 if( steam_ready )
55 {
56 vg_info( "Shutting down\n..." );
57 SteamAPI_Shutdown();
58 }
59 }
60
61 #endif /* STEAM_H */