From: Holger Schemel Date: Sat, 25 Feb 2006 17:03:45 +0000 (+0100) Subject: rnd-20060225-1-src X-Git-Tag: 3.2.0^2~64 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=a765d70dda7da4500e7005ffa5913e24cd32c0fa;p=rocksndiamonds.git rnd-20060225-1-src --- diff --git a/src/conftime.h b/src/conftime.h index f9dde6fb..1baa07fc 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-02-22 23:30]" +#define COMPILE_DATE_STRING "[2006-02-25 18:03]" diff --git a/src/engines.h b/src/engines.h index 2194a7c9..0b736da9 100644 --- a/src/engines.h +++ b/src/engines.h @@ -24,8 +24,10 @@ extern void SetBitmaps_EM(Bitmap **); extern void UpdateEngineValues(int, int); extern void DrawAllGameValues(int, int, int, int, int); + extern int getGameFrameDelay_EM(int); -extern int getCenteredPlayer_EM(); +extern int getCenteredPlayerNr_EM(); + extern void PlayLevelSound_EM(int, int, int, int); extern void InitGraphicInfo_EM(void); diff --git a/src/events.c b/src/events.c index f9627a15..f478a86b 100644 --- a/src/events.c +++ b/src/events.c @@ -700,9 +700,12 @@ void HandleKey(Key key, int key_status) if (game_status == GAME_MODE_PLAYING) { - for (i = 0; i < MAX_PLAYERS; i++) - if (key == KSYM_1 + i) - game.centered_to_player_next = i; + if (key == KSYM_5) + game.centered_player_nr_next = -1; + else + for (i = 0; i < MAX_PLAYERS; i++) + if (key == KSYM_1 + i) + game.centered_player_nr_next = i; } HandleKeysSpecial(key); diff --git a/src/game.c b/src/game.c index 19fcafdd..8fdc17e2 100644 --- a/src/game.c +++ b/src/game.c @@ -1933,7 +1933,7 @@ void InitGame() game.envelope_active = FALSE; - game.centered_to_player = game.centered_to_player_next = 0; /* player_1 */ + game.centered_player_nr = game.centered_player_nr_next = -1; /* focus all */ for (i = 0; i < NUM_BELTS; i++) { @@ -3266,8 +3266,14 @@ void RelocatePlayer(int jx, int jy, int el_player_raw) InitField(jx, jy, FALSE); } +#if 1 + /* only visually relocate centered player */ + if (player->index_nr == game.centered_player_nr) + DrawRelocatePlayer(player, level.instant_relocation); +#else if (player == local_player) /* only visually relocate local player */ DrawRelocatePlayer(player, level.instant_relocation); +#endif TestIfPlayerTouchesBadThing(jx, jy); TestIfPlayerTouchesCustomElement(jx, jy); @@ -8811,16 +8817,22 @@ void GameActions() if (ScreenMovPos == 0) /* screen currently aligned at tile position */ { - struct PlayerInfo *player = &stored_player[game.centered_to_player_next]; + struct PlayerInfo *player; + int player_nr = game.centered_player_nr_next; + + if (game.centered_player_nr_next == -1) + player_nr = local_player->index_nr; + + player = &stored_player[player_nr]; if (!player->active) - game.centered_to_player_next = game.centered_to_player; + game.centered_player_nr_next = game.centered_player_nr; - if (game.centered_to_player != game.centered_to_player_next) + if (game.centered_player_nr != game.centered_player_nr_next) { DrawRelocatePlayer(player, setup.quick_switch); - game.centered_to_player = game.centered_to_player_next; + game.centered_player_nr = game.centered_player_nr_next; } } @@ -9652,7 +9664,11 @@ boolean MovePlayerOneStep(struct PlayerInfo *player, #endif } -#if 0 +#if 1 + if (!options.network && game.centered_player_nr == -1 && + !AllPlayersInSight(player, new_jx, new_jy)) + return MP_NO_ACTION; +#else if (!options.network && !AllPlayersInSight(player, new_jx, new_jy)) return MP_NO_ACTION; #endif @@ -9800,7 +9816,8 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) #if 1 if (moved & MP_MOVING && !ScreenMovPos && - player->index_nr == game.centered_to_player) + (player->index_nr == game.centered_player_nr || + game.centered_player_nr == -1)) #else if (moved & MP_MOVING && !ScreenMovPos && (player == local_player || !options.network)) @@ -9859,7 +9876,15 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) if (scroll_x != old_scroll_x || scroll_y != old_scroll_y) { -#if 0 +#if 1 + if (!options.network && game.centered_player_nr == -1 && + !AllPlayersInVisibleScreen()) + { + scroll_x = old_scroll_x; + scroll_y = old_scroll_y; + } + else +#else if (!options.network && !AllPlayersInVisibleScreen()) { scroll_x = old_scroll_x; diff --git a/src/game_em/graphics.c b/src/game_em/graphics.c index 90f43f71..d64863b4 100644 --- a/src/game_em/graphics.c +++ b/src/game_em/graphics.c @@ -45,7 +45,7 @@ static int crumbled_state[MAX_BUF_YSIZE][MAX_BUF_XSIZE]; static boolean redraw[MAX_BUF_XSIZE][MAX_BUF_YSIZE]; -static int centered_to_player; +static int centered_player_nr; /* copy the entire screen to the window at the scroll position * @@ -479,12 +479,18 @@ void game_initscreen(void) int dynamite_state = ply[0].dynamite; /* !!! ONLY PLAYER 1 !!! */ int all_keys_state = ply[0].keys | ply[1].keys | ply[2].keys | ply[3].keys; #if 1 - int player_nr = getCenteredPlayer_EM(); + int player_nr; +#else +#if 1 + int player_nr = getCenteredPlayerNr_EM(); #else int player_nr = 0; /* !!! FIX THIS (CENTERED TO PLAYER 1) !!! */ #endif +#endif + + centered_player_nr = getCenteredPlayerNr_EM(); - centered_to_player = player_nr; + player_nr = (centered_player_nr != -1 ? centered_player_nr : 0); frame = 6; #if 1 @@ -612,7 +618,8 @@ void DrawRelocatePlayer(struct PlayerInfo *player, boolean quick_relocation) void RedrawPlayfield_EM(boolean force_redraw) { #if 1 - int player_nr = getCenteredPlayer_EM(); + int centered_player_nr_next = getCenteredPlayerNr_EM(); + int player_nr = (centered_player_nr_next != -1 ? centered_player_nr_next :0); boolean draw_new_player_location = FALSE; boolean quick_relocation = setup.quick_switch; #else @@ -627,9 +634,9 @@ void RedrawPlayfield_EM(boolean force_redraw) if (!scrolling) /* screen currently aligned at tile position */ { - if (player_nr != centered_to_player) + if (centered_player_nr != centered_player_nr_next) { - centered_to_player = player_nr; + centered_player_nr = centered_player_nr_next; draw_new_player_location = TRUE; force_redraw = TRUE; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 4fc58a40..084bb388 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -799,7 +799,7 @@ void InitLevelSetupDirectory(char *level_subdir) /* ------------------------------------------------------------------------- */ -/* some functions to handle lists of level directories */ +/* some functions to handle lists of level and artwork directories */ /* ------------------------------------------------------------------------- */ TreeInfo *newTreeInfo() @@ -927,6 +927,43 @@ TreeInfo *getTreeInfoFromIdentifier(TreeInfo *node, char *identifier) return NULL; } +TreeInfo *cloneTreeNode(TreeInfo **node_top, TreeInfo *node_parent, + TreeInfo *node, boolean skip_sets_without_levels) +{ + TreeInfo *node_new; + + if (node == NULL) + return NULL; + + if (!node->parent_link && !node->level_group && + skip_sets_without_levels && node->levels == 0) + return cloneTreeNode(node_top, node_parent, node->next, + skip_sets_without_levels); + + node_new = newTreeInfo(); + + *node_new = *node; /* copy complete node */ + + node_new->node_top = node_top; /* correct top node link */ + node_new->node_parent = node_parent; /* correct parent node link */ + + if (node->level_group) + node_new->node_group = cloneTreeNode(node_top, node_new, node->node_group, + skip_sets_without_levels); + + node_new->next = cloneTreeNode(node_top, node_parent, node->next, + skip_sets_without_levels); + + return node_new; +} + +void cloneTree(TreeInfo **ti_new, TreeInfo *ti, boolean skip_empty_sets) +{ + TreeInfo *ti_cloned = cloneTreeNode(ti_new, NULL, ti, skip_empty_sets); + + *ti_new = ti_cloned; +} + void dumpTreeInfo(TreeInfo *node, int depth) { int i; @@ -1989,6 +2026,8 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, (leveldir_new->user_defined || !leveldir_new->handicap ? leveldir_new->last_level : leveldir_new->first_level); +#if 0 + /* !!! don't skip sets without levels (else artwork base sets are missing) */ #if 1 if (leveldir_new->levels < 1 && !leveldir_new->level_group) { @@ -2000,6 +2039,7 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, return FALSE; } +#endif #endif pushTreeInfo(node_first, leveldir_new); @@ -2093,6 +2133,11 @@ void LoadLevelInfo() LoadLevelInfoFromLevelDir(&leveldir_first, NULL, options.level_directory); LoadLevelInfoFromLevelDir(&leveldir_first, NULL, getUserLevelDir(NULL)); +#if 1 + leveldir_first_all = leveldir_first; + cloneTree(&leveldir_first, leveldir_first_all, TRUE); +#endif + /* before sorting, the first entries will be from the user directory */ leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); @@ -2448,9 +2493,9 @@ void LoadLevelArtworkInfo() { DrawInitText("Looking for custom level artwork:", 120, FC_GREEN); - LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, leveldir_first); - LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first); - LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first); + LoadArtworkInfoFromLevelInfo(&artwork.gfx_first, leveldir_first_all); + LoadArtworkInfoFromLevelInfo(&artwork.snd_first, leveldir_first_all); + LoadArtworkInfoFromLevelInfo(&artwork.mus_first, leveldir_first_all); /* needed for reloading level artwork not known at ealier stage */ diff --git a/src/libgame/system.c b/src/libgame/system.c index 2980d7b9..12e72404 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -41,6 +41,7 @@ struct ArtworkInfo artwork; struct JoystickInfo joystick; struct SetupInfo setup; +LevelDirTree *leveldir_first_all = NULL; LevelDirTree *leveldir_first = NULL; LevelDirTree *leveldir_current = NULL; int level_nr; diff --git a/src/libgame/system.h b/src/libgame/system.h index a0108a28..4c05596d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -891,6 +891,7 @@ extern struct ArtworkInfo artwork; extern struct JoystickInfo joystick; extern struct SetupInfo setup; +extern LevelDirTree *leveldir_first_all; extern LevelDirTree *leveldir_first; extern LevelDirTree *leveldir_current; extern int level_nr; diff --git a/src/main.h b/src/main.h index 8ae10491..ffde34c3 100644 --- a/src/main.h +++ b/src/main.h @@ -2081,8 +2081,8 @@ struct GameInfo boolean restart_level; /* values for special game control */ - int centered_to_player; - int centered_to_player_next; + int centered_player_nr; + int centered_player_nr_next; }; struct GlobalInfo diff --git a/src/tools.c b/src/tools.c index 712be239..4ce30345 100644 --- a/src/tools.c +++ b/src/tools.c @@ -5129,15 +5129,16 @@ int getGameFrameDelay_EM(int native_em_game_frame_delay) return game_frame_delay_value; } -int getCenteredPlayer_EM() +int getCenteredPlayerNr_EM() { - if (!native_em_level.ply[game.centered_to_player_next]->alive) - game.centered_to_player_next = game.centered_to_player; + if (game.centered_player_nr_next >= 0 && + !native_em_level.ply[game.centered_player_nr_next]->alive) + game.centered_player_nr_next = game.centered_player_nr; - if (game.centered_to_player != game.centered_to_player_next) - game.centered_to_player = game.centered_to_player_next; + if (game.centered_player_nr != game.centered_player_nr_next) + game.centered_player_nr = game.centered_player_nr_next; - return game.centered_to_player; + return game.centered_player_nr; } unsigned int InitRND(long seed)