Debian Codegraph @

build-projects/android/app/jni/src/game_em/cave.c

raw symbols SCIP
1 /* 2000-08-10T16:43:50Z
2 *
3 * cave data structures
4 */
5
6 #include "main_em.h"
7
8
9 struct LevelInfo_EM native_em_level;
10
11 void setLevelInfoToDefaults_EM(void)
12 {
13 int i, j, x, y;
14
15 native_em_level.file_version = FILE_VERSION_EM_ACTUAL;
16 native_em_level.cav = &cav;
17
18 game_em.lev = &lev;
19 for (i = 0; i < MAX_PLAYERS; i++)
20 game_em.ply[i] = &ply[i];
21
22 cav.width = 64;
23 cav.height = 32;
24
25 for (i = 0; i < MAX_PLAYERS; i++)
26 {
27 cav.player_x[i] = -1;
28 cav.player_y[i] = -1;
29 }
30
31 cav.time_seconds = 0;
32 cav.gems_needed = 0;
33
34 cav.eater_score = 0;
35 cav.alien_score = 0;
36 cav.bug_score = 0;
37 cav.tank_score = 0;
38 cav.slurp_score = 0;
39 cav.nut_score = 0;
40 cav.emerald_score = 0;
41 cav.diamond_score = 0;
42 cav.dynamite_score = 0;
43 cav.key_score = 0;
44 cav.lenses_score = 0;
45 cav.magnify_score = 0;
46 cav.exit_score = 0;
47
48 cav.android_move_time = 0;
49 cav.android_clone_time= 0;
50 cav.ball_time = 0;
51 cav.amoeba_time = 0;
52 cav.wonderwall_time = 0;
53 cav.wheel_time = 0;
54 cav.wheel_x = 0;
55 cav.wheel_y = 0;
56 cav.lenses_time = 0;
57 cav.magnify_time = 0;
58 cav.wind_time = 0;
59 cav.wind_direction = 0;
60
61 cav.num_eater_arrays = 8;
62 cav.num_ball_arrays = 8;
63
64 cav.testmode = FALSE;
65 cav.teamwork = FALSE;
66 cav.infinite = TRUE;
67 cav.infinite_true = FALSE; // default: use original EMC behaviour
68
69 cav.ball_random = FALSE;
70 cav.ball_active = FALSE;
71 cav.wonderwall_active = FALSE;
72 cav.wheel_active = FALSE;
73 cav.lenses_active = FALSE;
74 cav.magnify_active = FALSE;
75
76 for (i = 0; i < 8; i++)
77 for (j = 0; j < 9; j++)
78 cav.eater_array[i][j] = Cblank;
79
80 for (i = 0; i < 8; i++)
81 for (j = 0; j < 8; j++)
82 cav.ball_array[i][j] = Cblank;
83
84 for (i = 0; i < GAME_TILE_MAX; i++)
85 cav.android_array[i] = Cblank;
86
87 for (x = 0; x < CAVE_WIDTH; x++)
88 for (y = 0; y < CAVE_HEIGHT; y++)
89 cav.cave[x][y] = Cblank;
90 }
91
92
93 /* load cave
94 *
95 * completely initializes the level structure, ready for a game
96 */
97
98 #define MAX_EM_LEVEL_SIZE 16384
99
100 boolean LoadNativeLevel_EM(char *filename, boolean level_info_only)
101 {
102 unsigned char raw_leveldata[MAX_EM_LEVEL_SIZE];
103 int raw_leveldata_length;
104 int file_version;
105 File *file;
106
107 /* always start with reliable default values */
108 setLevelInfoToDefaults_EM();
109
110 if (!(file = openFile(filename, MODE_READ)))
111 {
112 if (!level_info_only)
113 Warn("cannot open level '%s' -- using empty level", filename);
114
115 return FALSE;
116 }
117
118 raw_leveldata_length = readFile(file, raw_leveldata, 1, MAX_EM_LEVEL_SIZE);
119
120 closeFile(file);
121
122 if (raw_leveldata_length <= 0)
123 {
124 Warn("cannot read level '%s' -- using empty level", filename);
125
126 return FALSE;
127 }
128
129 file_version = cleanup_em_level(raw_leveldata, raw_leveldata_length, filename);
130
131 if (file_version == FILE_VERSION_EM_UNKNOWN)
132 {
133 Warn("unknown EM level '%s' -- using empty level", filename);
134
135 return FALSE;
136 }
137
138 convert_em_level(raw_leveldata, file_version);
139 prepare_em_level();
140
141 return TRUE;
142 }