3 * convert intermediate cave format to internal cave structure for
4 * use in logic(). initializes entire internal structure.
10 void prepare_em_level(void)
16 /* initialize runtime level structure */
19 /* reset all runtime variables to their initial values */
21 game_init_cave_buffers();
23 lev.left = CAVE_BUFFER_XOFFSET;
24 lev.top = CAVE_BUFFER_YOFFSET;
25 lev.right = lev.left + lev.width;
26 lev.bottom = lev.top + lev.height;
28 /* add linked cave buffer columns for wrap-around movement */
29 for (x = 0; x < lev.left; x++)
31 lev.cavecol[x] = lev.cavecol[lev.width + x];
32 lev.nextcol[x] = lev.nextcol[lev.width + x];
33 lev.drawcol[x] = lev.drawcol[lev.width + x];
34 lev.boomcol[x] = lev.boomcol[lev.width + x];
36 lev.cavecol[lev.right + x] = lev.cavecol[lev.left + x];
37 lev.nextcol[lev.right + x] = lev.nextcol[lev.left + x];
38 lev.drawcol[lev.right + x] = lev.drawcol[lev.left + x];
39 lev.boomcol[lev.right + x] = lev.boomcol[lev.left + x];
42 for (x = 0; x < lev.width; x++)
43 for (y = 0; y < lev.height; y++)
44 lev.cave[lev.left + x][lev.top + y] = lev.cave_raw[x][y];
46 for (x = lev.left; x < lev.right; x++)
47 for (y = lev.top; y < lev.bottom; y++)
48 lev.next[x][y] = lev.draw[x][y] = lev.cave[x][y];
50 lev.time_initial = lev.time_seconds;
51 lev.time = lev.time_initial;
53 lev.required = lev.required_initial;
56 lev.android_move_cnt = lev.android_move_time;
57 lev.android_clone_cnt = lev.android_clone_time;
60 lev.ball_state = lev.ball_state_initial;
61 lev.ball_cnt = lev.ball_time;
66 lev.lenses_cnt = lev.lenses_cnt_initial;
67 lev.magnify_cnt = lev.magnify_cnt_initial;
69 lev.wheel_cnt = lev.wheel_cnt_initial;
70 lev.wheel_x = lev.wheel_x_initial;
71 lev.wheel_y = lev.wheel_y_initial;
73 lev.wind_direction = lev.wind_direction_initial;
74 lev.wind_cnt = lev.wind_cnt_initial;
76 lev.wonderwall_state = lev.wonderwall_state_initial;
77 lev.wonderwall_time = lev.wonderwall_time_initial;
79 lev.killed_out_of_time = FALSE;
81 /* determine number of players in this level */
84 for (i = 0; i < MAX_PLAYERS; i++)
87 ply[i].alive_initial = FALSE;
89 if (lev.player_x[i] != -1 &&
90 lev.player_y[i] != -1)
98 team_mode = getTeamMode_EM();
101 lev.home_initial = 1;
103 lev.home = lev.home_initial;
104 players_left = lev.home_initial;
106 for (i = 0; i < MAX_PLAYERS; i++)
112 ply[i].alive_initial = TRUE;
117 int x = lev.player_x[i];
118 int y = lev.player_y[i];
120 lev.cave_raw[x][y] = Xblank;
122 lev.cave[lev.left + x][lev.top + y] = Xblank;
123 lev.next[lev.left + x][lev.top + y] = Xblank;
124 lev.draw[lev.left + x][lev.top + y] = Xblank;
129 for (i = 0; i < MAX_PLAYERS; i++)
132 ply[i].alive = ply[i].alive_initial;
134 ply[i].dynamite_cnt = 0;
137 ply[i].oldx = ply[i].x = lev.player_x[i] + lev.left;
138 ply[i].oldy = ply[i].y = lev.player_y[i] + lev.top;
139 ply[i].last_move_dir = MV_NONE;
140 ply[i].joy_n = ply[i].joy_e = ply[i].joy_s = ply[i].joy_w = 0;
141 ply[i].joy_snap = ply[i].joy_drop = 0;
142 ply[i].joy_stick = ply[i].joy_spin = 0;
145 // the following engine variables are initialized to version-specific values
146 // in function InitGameEngine() (src/game.c):
148 // - game_em.use_single_button (default: TRUE)
149 // - game_em.use_snap_key_bug (default: FALSE)
151 game_em.level_solved = FALSE;
152 game_em.game_over = FALSE;
154 game_em.any_player_moving = FALSE;
155 game_em.any_player_snapping = FALSE;
157 game_em.last_moving_player = 0; /* default: first player */
159 for (i = 0; i < MAX_PLAYERS; i++)
160 game_em.last_player_direction[i] = MV_NONE;
162 lev.exit_x = lev.exit_y = -1; /* kludge for playing player exit sound */