#define CONF_CONTENTS_ELEMENT(b,c,x,y) ((b[CONF_CONTENT_BYTE_POS(c,x,y)]<< 8)|\
(b[CONF_CONTENT_BYTE_POS(c,x,y) + 1]))
+#if 0
+static void LoadLevel_InitPlayfield(struct LevelInfo *, char *);
+#endif
+
static struct LevelInfo li;
static struct
/* !!! now done in InitElementPropertiesStatic() (see above) !!! */
/* !!! (else properties set there will be overwritten here) !!! */
/* start with no properties at all */
+#if 1
+ for (j = 0; j < NUM_EP_BITFIELDS; j++)
+ ei->properties[j] = EP_BITMASK_DEFAULT;
+#else
for (j = 0; j < NUM_EP_BITFIELDS; j++)
Properties[element][j] = EP_BITMASK_DEFAULT;
+#endif
#endif
/* now set default properties */
static void ActivateLevelTemplate()
{
+#if 1
+ /* Currently there is no special action needed to activate the template
+ data, because 'element_info' property settings overwrite the original
+ level data, while all other variables do not change. */
+#else
/* Currently there is no special action needed to activate the template
data, because 'element_info' and 'Properties' overwrite the original
level data, while all other variables do not change. */
+#endif
}
static char *getLevelFilenameFromBasename(char *basename)
int element = getFile16BitBE(file);
int properties = getFile32BitBE(file);
+#if 1
+ if (IS_CUSTOM_ELEMENT(element))
+ element_info[element].properties[EP_BITFIELD_BASE] = properties;
+ else
+ Error(ERR_WARN, "invalid custom element number %d", element);
+#else
if (IS_CUSTOM_ELEMENT(element))
Properties[element][EP_BITFIELD_BASE] = properties;
else
Error(ERR_WARN, "invalid custom element number %d", element);
+#endif
}
return chunk_size;
ei->description[j] = getFile8Bit(file);
ei->description[MAX_ELEMENT_NAME_LEN] = 0;
+#if 1
+ ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file);
+#else
Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file);
+#endif
/* some free bytes for future properties and padding */
ReadUnusedBytesFromFile(file, 7);
ei->description[i] = getFile8Bit(file);
ei->description[MAX_ELEMENT_NAME_LEN] = 0;
+#if 1
+ ei->properties[EP_BITFIELD_BASE] = getFile32BitBE(file);
+#else
Properties[element][EP_BITFIELD_BASE] = getFile32BitBE(file);
+#endif
ReadUnusedBytesFromFile(file, 4); /* reserved for more base properties */
ei->num_change_pages = getFile8Bit(file);
};
struct LevelInfo_EM *level_em = level->native_em_level;
struct LEVEL *lev = level_em->lev;
- struct PLAYER *ply1 = level_em->ply1;
- struct PLAYER *ply2 = level_em->ply2;
+ struct PLAYER **ply = level_em->ply;
int i, j, x, y;
+#if 0
+ printf("::: A\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
+
lev->width = MIN(level->fieldx, EM_MAX_CAVE_WIDTH);
lev->height = MIN(level->fieldy, EM_MAX_CAVE_HEIGHT);
map_element_RND_to_EM(level->
ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#if 0
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
+
map_android_clone_elements_RND_to_EM(level);
#if 0
for (x = 0; x < EM_MAX_CAVE_WIDTH; x++)
level_em->cave[x][y] = ZBORDER;
+#if 1
+
+#if 0
+#if 1
+ LoadLevel_InitPlayfield();
+#else
+ lev_fieldx = lev->width; /* !!! also in LoadLevel_InitPlayfield() !!! */
+ lev_fieldy = lev->height; /* !!! also in LoadLevel_InitPlayfield() !!! */
+ SetBorderElement(); /* !!! also in LoadLevel_InitPlayfield() !!! */
+#endif
+#endif
+
+#if 0
+ printf("::: BorderElement == %d\n", BorderElement);
+#endif
+
+ if (BorderElement == EL_STEELWALL)
+ {
+ for (y = 0; y < lev->height + 2; y++)
+ for (x = 0; x < lev->width + 2; x++)
+ level_em->cave[x + 1][y + 1] = map_element_RND_to_EM(EL_STEELWALL);
+ }
+
+ /* then copy the real level contents from level file into the playfield */
+ for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++)
+ {
+ int new_element = map_element_RND_to_EM(level->field[x][y]);
+ int offset = (BorderElement == EL_STEELWALL ? 1 : 0);
+ int xx = x + 1 + offset;
+ int yy = y + 1 + offset;
+
+ if (level->field[x][y] == EL_AMOEBA_DEAD)
+ new_element = map_element_RND_to_EM(EL_AMOEBA_WET);
+
+ level_em->cave[xx][yy] = new_element;
+ }
+
+#else
+
/* then copy the real level contents from level file into the playfield */
for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++)
{
level_em->cave[x + 1][y + 1] = new_element;
}
+#endif
+
+#if 1
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ ply[i]->x_initial = 0;
+ ply[i]->y_initial = 0;
+ }
+
+#else
+
ply1->x_initial = 0;
ply1->y_initial = 0;
ply2->x_initial = 0;
ply2->y_initial = 0;
+#endif
+
/* initialize player positions and delete players from the playfield */
for (y = 0; y < lev->height; y++) for (x = 0; x < lev->width; x++)
{
+
+#if 1
+ if (ELEM_IS_PLAYER(level->field[x][y]))
+ {
+ int player_nr = GET_PLAYER_NR(level->field[x][y]);
+ int offset = (BorderElement == EL_STEELWALL ? 1 : 0);
+ int xx = x + 1 + offset;
+ int yy = y + 1 + offset;
+
+ ply[player_nr]->x_initial = xx;
+ ply[player_nr]->y_initial = yy;
+
+ level_em->cave[xx][yy] = map_element_RND_to_EM(EL_EMPTY);
+ }
+
+#else
+
#if 1
/* !!! CURRENTLY ONLY SUPPORT FOR ONE PLAYER !!! */
if (ELEM_IS_PLAYER(level->field[x][y]))
level_em->cave[x + 1][y + 1] = map_element_RND_to_EM(EL_EMPTY);
}
#endif
+
+#endif
+
+ }
+
+ if (BorderElement == EL_STEELWALL)
+ {
+#if 1
+ lev->width += 2;
+ lev->height += 2;
+#endif
}
}
};
struct LevelInfo_EM *level_em = level->native_em_level;
struct LEVEL *lev = level_em->lev;
- struct PLAYER *ply1 = level_em->ply1;
- struct PLAYER *ply2 = level_em->ply2;
+ struct PLAYER **ply = level_em->ply;
int i, j, x, y;
level->fieldx = MIN(lev->width, MAX_LEV_FIELDX);
level->wind_direction_initial =
map_direction_EM_to_RND(lev->wind_direction_initial);
+#if 0
+ printf("::: foo\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
+
for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
for (j = 0; j < 8; j++)
level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]] =
map_element_EM_to_RND(lev->ball_array[i][j]);
+#if 0
+ printf("::: bar\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
+
map_android_clone_elements_EM_to_RND(level);
#if 0
level->field[x][y] = new_element;
}
+#if 0
+ printf("::: bar 0\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
+
+#if 1
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ /* in case of all players set to the same field, use the first player */
+ int nr = MAX_PLAYERS - i - 1;
+ int jx = ply[nr]->x_initial - 1;
+ int jy = ply[nr]->y_initial - 1;
+
+#if 0
+ printf("::: player %d: %d, %d\n", nr, jx, jy);
+#endif
+
+ if (jx != -1 && jy != -1)
+ level->field[jx][jy] = EL_PLAYER_1 + nr;
+ }
+
+#else
+
/* in case of both players set to the same field, use the first player */
level->field[ply2->x_initial - 1][ply2->y_initial - 1] = EL_PLAYER_2;
level->field[ply1->x_initial - 1][ply1->y_initial - 1] = EL_PLAYER_1;
+#endif
+
#if 0
printf("::: native Emerald Mine file version: %d\n", level_em->file_version);
#endif
+
+#if 0
+ printf("::: bar 2\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+#endif
}
static void LoadLevelFromFileInfo_EM(struct LevelInfo *level,
void CopyNativeLevel_Native_to_RND(struct LevelInfo *level)
{
+
+#if 0
+ {
+ static int ball_xy[8][2] =
+ {
+ { 0, 0 },
+ { 1, 0 },
+ { 2, 0 },
+ { 0, 1 },
+ { 2, 1 },
+ { 0, 2 },
+ { 1, 2 },
+ { 2, 2 },
+ };
+ int i, j;
+
+ printf("::: A6\n");
+ for (i = 0; i < MAX_ELEMENT_CONTENTS; i++)
+ for (j = 0; j < 8; j++)
+ printf("::: ball %d, %d: %d\n", i, j,
+ level->ball_content[i].e[ball_xy[j][0]][ball_xy[j][1]]);
+ }
+#endif
+
if (level->game_engine_type == GAME_ENGINE_TYPE_EM)
CopyNativeLevel_EM_to_RND(level);
}
if (level->game_engine_type == GAME_ENGINE_TYPE_UNKNOWN)
level->game_engine_type = GAME_ENGINE_TYPE_RND;
+#if 1
+ if (level_file_info->type != LEVEL_FILE_TYPE_RND)
+ CopyNativeLevel_Native_to_RND(level);
+#else
if (level_file_info->type == LEVEL_FILE_TYPE_RND)
CopyNativeLevel_RND_to_Native(level);
else
CopyNativeLevel_Native_to_RND(level);
+#endif
}
void LoadLevelFromFilename(struct LevelInfo *level, char *filename)
if (leveldir_current == NULL) /* only when dumping level */
return;
+ /* all engine modifications also valid for levels which use latest engine */
+#if 1
+ if (level->game_version < VERSION_IDENT(3,2,0,5))
+ {
+ /* time bonus score was given for 10 s instead of 1 s before 3.2.0-5 */
+ level->score[SC_TIME_BONUS] /= 10;
+ }
+#endif
+
if (leveldir_current->latest_engine)
{
/* ---------- use latest game engine ----------------------------------- */
/* extra time score was same value as time left score before 3.2.0-5 */
level->extra_time_score = level->score[SC_TIME_BONUS];
+#if 0
/* time bonus score was given for 10 s instead of 1 s before 3.2.0-5 */
level->score[SC_TIME_BONUS] /= 10;
+#endif
}
/* only few elements were able to actively move into acid before 3.1.0 */
SetBorderElement();
}
+static void LoadLevel_InitNativeEngines(struct LevelInfo *level,char *filename)
+{
+ struct LevelFileInfo *level_file_info = &level->file_info;
+
+#if 1
+ if (level_file_info->type == LEVEL_FILE_TYPE_RND)
+ CopyNativeLevel_RND_to_Native(level);
+#else
+ if (level_file_info->type == LEVEL_FILE_TYPE_RND)
+ CopyNativeLevel_RND_to_Native(level);
+ else
+ CopyNativeLevel_Native_to_RND(level);
+#endif
+}
+
void LoadLevelTemplate(int nr)
{
char *filename;
LoadLevel_InitVersion(&level, filename);
LoadLevel_InitElements(&level, filename);
LoadLevel_InitPlayfield(&level, filename);
+
+ LoadLevel_InitNativeEngines(&level, filename);
}
static void SaveLevel_VERS(FILE *file, struct LevelInfo *level)
{
int element = EL_CUSTOM_START + i;
+#if 1
+ struct ElementInfo *ei = &element_info[element];
+
+ if (ei->properties[EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT)
+ {
+ if (check < num_changed_custom_elements)
+ {
+ putFile16BitBE(file, element);
+ putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+ }
+
+ check++;
+ }
+#else
if (Properties[element][EP_BITFIELD_BASE] != EP_BITMASK_DEFAULT)
{
if (check < num_changed_custom_elements)
check++;
}
+#endif
}
if (check != num_changed_custom_elements) /* should not happen */
for (j = 0; j < MAX_ELEMENT_NAME_LEN; j++)
putFile8Bit(file, ei->description[j]);
+#if 1
+ putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+#else
putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
+#endif
/* some free bytes for future properties and padding */
WriteUnusedBytesToFile(file, 7);
for (i = 0; i < MAX_ELEMENT_NAME_LEN; i++)
putFile8Bit(file, ei->description[i]);
+#if 1
+ putFile32BitBE(file, ei->properties[EP_BITFIELD_BASE]);
+#else
putFile32BitBE(file, Properties[element][EP_BITFIELD_BASE]);
+#endif
WriteUnusedBytesToFile(file, 4); /* reserved for more base properties */
putFile8Bit(file, ei->num_change_pages);
void DumpTape(struct TapeInfo *tape)
{
+ int tape_frame_counter;
int i, j;
if (tape->no_valid_file)
printf("Level series identifier: '%s'\n", tape->level_identifier);
printf_line("-", 79);
+ tape_frame_counter = 0;
+
for (i = 0; i < tape->length; i++)
{
if (i >= MAX_TAPE_LEN)
break;
- printf("%03d: ", i);
+ printf("%04d: ", i);
for (j = 0; j < MAX_PLAYERS; j++)
{
}
}
- printf("(%03d)\n", tape->pos[i].delay);
+ printf("(%03d) ", tape->pos[i].delay);
+ printf("[%05d]\n", tape_frame_counter);
+
+ tape_frame_counter += tape->pos[i].delay;
}
printf_line("-", 79);
#define SETUP_TOKEN_TIME_LIMIT 14
#define SETUP_TOKEN_FULLSCREEN 15
#define SETUP_TOKEN_ASK_ON_ESCAPE 16
-#define SETUP_TOKEN_GRAPHICS_SET 17
-#define SETUP_TOKEN_SOUNDS_SET 18
-#define SETUP_TOKEN_MUSIC_SET 19
-#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 20
-#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 21
-#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 22
+#define SETUP_TOKEN_ASK_ON_ESCAPE_EDITOR 17
+#define SETUP_TOKEN_QUICK_SWITCH 18
+#define SETUP_TOKEN_GRAPHICS_SET 19
+#define SETUP_TOKEN_SOUNDS_SET 20
+#define SETUP_TOKEN_MUSIC_SET 21
+#define SETUP_TOKEN_OVERRIDE_LEVEL_GRAPHICS 22
+#define SETUP_TOKEN_OVERRIDE_LEVEL_SOUNDS 23
+#define SETUP_TOKEN_OVERRIDE_LEVEL_MUSIC 24
-#define NUM_GLOBAL_SETUP_TOKENS 23
+#define NUM_GLOBAL_SETUP_TOKENS 25
/* editor setup */
#define SETUP_TOKEN_EDITOR_EL_BOULDERDASH 0
#define SETUP_TOKEN_SHORTCUT_SAVE_GAME 0
#define SETUP_TOKEN_SHORTCUT_LOAD_GAME 1
#define SETUP_TOKEN_SHORTCUT_TOGGLE_PAUSE 2
+#define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_1 3
+#define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_2 4
+#define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_3 5
+#define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_4 6
+#define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_ALL 7
-#define NUM_SHORTCUT_SETUP_TOKENS 3
+#define NUM_SHORTCUT_SETUP_TOKENS 8
/* player setup */
#define SETUP_TOKEN_PLAYER_USE_JOYSTICK 0
{ TYPE_SWITCH, &si.time_limit, "time_limit" },
{ TYPE_SWITCH, &si.fullscreen, "fullscreen" },
{ TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" },
+ { TYPE_SWITCH, &si.ask_on_escape_editor, "ask_on_escape_editor" },
+ { TYPE_SWITCH, &si.quick_switch, "quick_player_switch" },
{ TYPE_STRING, &si.graphics_set, "graphics_set" },
{ TYPE_STRING, &si.sounds_set, "sounds_set" },
{ TYPE_STRING, &si.music_set, "music_set" },
{ TYPE_SWITCH, &seci.el_ce, "editor.cascade.el_ce" },
{ TYPE_SWITCH, &seci.el_ge, "editor.cascade.el_ge" },
{ TYPE_SWITCH, &seci.el_user, "editor.cascade.el_user" },
- { TYPE_SWITCH, &seci.el_generic, "editor.cascade.el_generic" },
{ TYPE_SWITCH, &seci.el_dynamic, "editor.cascade.el_dynamic" },
};
{
{ TYPE_KEY_X11, &ssi.save_game, "shortcut.save_game" },
{ TYPE_KEY_X11, &ssi.load_game, "shortcut.load_game" },
- { TYPE_KEY_X11, &ssi.toggle_pause, "shortcut.toggle_pause" }
+ { TYPE_KEY_X11, &ssi.toggle_pause, "shortcut.toggle_pause" },
+ { TYPE_KEY_X11, &ssi.focus_player[0], "shortcut.focus_player_1" },
+ { TYPE_KEY_X11, &ssi.focus_player[1], "shortcut.focus_player_2" },
+ { TYPE_KEY_X11, &ssi.focus_player[2], "shortcut.focus_player_3" },
+ { TYPE_KEY_X11, &ssi.focus_player[3], "shortcut.focus_player_4" },
+ { TYPE_KEY_X11, &ssi.focus_player_all,"shortcut.focus_player_all" },
};
static struct TokenInfo player_setup_tokens[] =
{ TYPE_KEY_X11, &sii.key.up, ".key.move_up" },
{ TYPE_KEY_X11, &sii.key.down, ".key.move_down" },
{ TYPE_KEY_X11, &sii.key.snap, ".key.snap_field" },
- { TYPE_KEY_X11, &sii.key.drop, ".key.place_bomb" }
+ { TYPE_KEY_X11, &sii.key.drop, ".key.place_bomb" },
};
static struct TokenInfo system_setup_tokens[] =
{
{ TYPE_STRING, &syi.sdl_audiodriver, "system.sdl_audiodriver" },
- { TYPE_INTEGER, &syi.audio_fragment_size,"system.audio_fragment_size" }
+ { TYPE_INTEGER, &syi.audio_fragment_size,"system.audio_fragment_size" },
};
static struct TokenInfo options_setup_tokens[] =
{
- { TYPE_BOOLEAN, &soi.verbose, "options.verbose" }
+ { TYPE_BOOLEAN, &soi.verbose, "options.verbose" },
};
static char *get_corrected_login_name(char *login_name)
si->time_limit = TRUE;
si->fullscreen = FALSE;
si->ask_on_escape = TRUE;
+ si->ask_on_escape_editor = TRUE;
+ si->quick_switch = FALSE;
si->graphics_set = getStringCopy(GFX_CLASSIC_SUBDIR);
si->sounds_set = getStringCopy(SND_CLASSIC_SUBDIR);
si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME;
si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE;
+ si->shortcut.focus_player[0] = DEFAULT_KEY_FOCUS_PLAYER_1;
+ si->shortcut.focus_player[1] = DEFAULT_KEY_FOCUS_PLAYER_2;
+ si->shortcut.focus_player[2] = DEFAULT_KEY_FOCUS_PLAYER_3;
+ si->shortcut.focus_player[3] = DEFAULT_KEY_FOCUS_PLAYER_4;
+ si->shortcut.focus_player_all = DEFAULT_KEY_FOCUS_PLAYER_ALL;
+
for (i = 0; i < MAX_PLAYERS; i++)
{
si->input[i].use_joystick = FALSE;
si->editor_cascade.el_ce = FALSE;
si->editor_cascade.el_ge = FALSE;
si->editor_cascade.el_user = FALSE;
- si->editor_cascade.el_generic = FALSE;
si->editor_cascade.el_dynamic = FALSE;
}
{
char *player_name_new;
- checkSetupFileHashIdentifier(setup_file_hash, getCookie("SETUP"));
+ checkSetupFileHashIdentifier(setup_file_hash, filename,getCookie("SETUP"));
decodeSetupFileHash(setup_file_hash);
setup.direct_draw = !setup.double_buffering;
if (setup_file_hash)
{
- checkSetupFileHashIdentifier(setup_file_hash, getCookie("SETUP"));
+ checkSetupFileHashIdentifier(setup_file_hash, filename,getCookie("SETUP"));
decodeSetupFileHash_EditorCascade(setup_file_hash);
freeSetupFileHash(setup_file_hash);
#if 0
for (i = 0; i < num_list_entries; i++)
- printf("::: %d, %d, %d => %d\n",
+ printf("::: '%s': %d, %d, %d => %d\n",
+ EL_NAME(helpanim_info[i].element),
helpanim_info[i].element,
helpanim_info[i].action,
helpanim_info[i].direction,