Skip to content

Latest commit

 

History

History
95 lines (78 loc) · 2.37 KB

testapp.c

File metadata and controls

95 lines (78 loc) · 2.37 KB
 
Sep 16, 2015
Sep 16, 2015
1
2
3
4
5
6
7
// This example assumes you own Postal 1 on Steam...
//
// http://store.steampowered.com/app/232770
//
// ...and it will RESET ALL YOUR ACHIEVEMENTS for that game, so BE CAREFUL
// before running this!
Jul 25, 2013
Jul 25, 2013
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "steamshim_child.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
static void printEvent(const STEAMSHIM_Event *e)
{
if (!e) return;
printf("CHILD EVENT: ");
switch (e->type)
{
#define PRINTGOTEVENT(x) case SHIMEVENT_##x: printf("%s(", #x); break
PRINTGOTEVENT(BYE);
PRINTGOTEVENT(STATSRECEIVED);
PRINTGOTEVENT(STATSSTORED);
PRINTGOTEVENT(SETACHIEVEMENT);
PRINTGOTEVENT(GETACHIEVEMENT);
PRINTGOTEVENT(RESETSTATS);
PRINTGOTEVENT(SETSTATI);
PRINTGOTEVENT(GETSTATI);
PRINTGOTEVENT(SETSTATF);
PRINTGOTEVENT(GETSTATF);
#undef PRINTGOTEVENT
default: printf("UNKNOWN("); break;
} /* switch */
printf("%sokay, ival=%d, fval=%f, time=%llu, name='%s').\n",
e->okay ? "" : "!", e->ivalue, e->fvalue, e->epochsecs, e->name);
} /* printEvent */
int main(int argc, char **argv)
{
const int retval = (int) time(NULL) % 127;
int i;
printf("Child argv (argc=%d):\n", argc);
for (i = 0; i <= argc; i++)
printf(" - '%s'\n", argv[i]);
printf("\n");
if (!STEAMSHIM_init())
{
printf("Child init failed, terminating.\n");
return 42;
} /* if */
STEAMSHIM_requestStats();
while (STEAMSHIM_alive())
{
const STEAMSHIM_Event *e = STEAMSHIM_pump();
printEvent(e);
if (e && e->type == SHIMEVENT_STATSRECEIVED)
break;
usleep(100 * 1000);
} // while
STEAMSHIM_getStatI("BulletsFired");
STEAMSHIM_getAchievement("KILL_FIRST_VICTIM");
STEAMSHIM_resetStats(1);
STEAMSHIM_storeStats();
STEAMSHIM_setAchievement("KILL_FIRST_VICTIM", 1);
STEAMSHIM_getAchievement("KILL_FIRST_VICTIM");
STEAMSHIM_setStatI("BulletsFired", 22);
STEAMSHIM_storeStats();
{
time_t x = time(NULL) + 5;
while ( STEAMSHIM_alive() && (time(NULL) < x) )
{
const STEAMSHIM_Event *e = STEAMSHIM_pump();
printEvent(e);
usleep(100 * 1000);
} // while
}
STEAMSHIM_deinit();
Sep 16, 2015
Sep 16, 2015
90
sleep(3);
Jul 25, 2013
Jul 25, 2013
91
92
93
94
printf("Child returning %d\n", retval);
return retval;
} /* main */