-
Notifications
You must be signed in to change notification settings - Fork 2
/
dc_savegame.c
43 lines (36 loc) · 968 Bytes
/
dc_savegame.c
1
2
3
4
5
6
7
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
// ---------------------------------------
// speud (27-06-2004) - Replacing fprintf
// ---------------------------------------
void DC_fprintf(FILE *stream, const char *format, ...) {
char tmp_buf[40000];
sprintf(tmp_buf, format);
fwrite(tmp_buf, strlen(tmp_buf), 1, stream);
}
// -----------------------------------------
// BlackAura (08-12-2002) - Replacing fscanf
// -----------------------------------------
int cur; // speud (27-06-2004) - Replacing fgetc in Host_Loadgame_f
static void DC_ScanString(FILE *file, char *string)
{
char newchar;
fread(&newchar, 1, 1, file);
while(newchar != '\n')
{
*string++ = newchar;
fread(&newchar, 1, 1, file);
cur ++;
}
*string++ = '\0';
}
static int DC_ScanInt(FILE *file)
{
char sbuf[32768];
DC_ScanString(file, sbuf);
return Q_atoi(sbuf);
}
static float DC_ScanFloat(FILE *file)
{
char sbuf[32768];
DC_ScanString(file, sbuf);
return Q_atof(sbuf);
}