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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#include <stdio.h>
#include <string.h>
#include "SDL/SDL.h"
#include "parser.h"
#include "loader.h"
#include "utils.h"
#define PATH_STYLE "../styles"
#define PATH_LEVEL "../level"
#define MAX_PATH_LEN 255
int main(int argc, char **argv) {
int res;
char filepath[MAX_PATH_LEN];
gameIni_t gIni;
gameRess_t gRess;
if (argc != 3) {
fprintf(stderr, "Usage %s <levelpack_name> <ini_file>\n", argv[0]);
return 1;
}
openLog(NULL);
// Setting default values
memset(&gIni,0,sizeof(gameIni_t));
// Loading levelpack.ini
snprintf(filepath, MAX_PATH_LEN, "%s/%s/levelpack.ini", PATH_LEVEL, argv[1]);
res=loadIni(&gIni, filepath);
if (res!=0) exit(res);
// Loading lvl ini file
snprintf(filepath, MAX_PATH_LEN, "%s/%s/%s", PATH_LEVEL, argv[1], argv[2]);
res=loadIni(&gIni, filepath);
if (res!=0) exit(res);
// Check if we found a "style =" line in level ini file
if (gIni.level.style==NULL) {
fprintf(stderr, "No valid style detected\n");
exit(1);
}
gIni.style.name=gIni.level.style;
// Loading style ini file
snprintf(filepath, MAX_PATH_LEN, "%s/%s/%s.ini", PATH_STYLE, gIni.level.style, gIni.level.style);
res=loadIni(&gIni, filepath);
if (res!=0) exit(res);
res=loadRessources(&gIni, &gRess);
closeLog(NULL);
return res;
}
|