From: Holger Schemel Date: Sat, 12 Jun 2004 10:06:42 +0000 (+0200) Subject: rnd-20040612-1-src X-Git-Tag: 3.1.1^2~92 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=216566521353a144d859e1d93d326934996d85a0 rnd-20040612-1-src * fixed waste of static memory usage of the binary, making it smaller * fixed very little graphical bug in Supaplex explosion --- diff --git a/ChangeLog b/ChangeLog index 929c9f4a..829c0d5b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2004-06-11 * fixed bug with wrong door state after trying to quickload empty tape + * fixed waste of static memory usage of the binary, making it smaller + * fixed very little graphical bug in Supaplex explosion 2004-06-07 * version number set to 3.1.1 diff --git a/src/conf_gfx.c b/src/conf_gfx.c index ada412c6..5e5e998c 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -19,7 +19,7 @@ reliable default values. If that value is GFX_ARG_UNDEFINED, it will be dynamically determined, using some of the other list values. */ -struct ConfigInfo image_config_suffix[] = +struct ConfigTypeInfo image_config_suffix[] = { { ".x", ARG_UNDEFINED, TYPE_INTEGER }, { ".y", ARG_UNDEFINED, TYPE_INTEGER }, diff --git a/src/conf_mus.c b/src/conf_mus.c index 1c29c617..27ec9056 100644 --- a/src/conf_mus.c +++ b/src/conf_mus.c @@ -19,7 +19,7 @@ reliable default values. If that value is MUS_ARG_UNDEFINED, it will be dynamically determined, using some of the other list values. */ -struct ConfigInfo music_config_suffix[] = +struct ConfigTypeInfo music_config_suffix[] = { { ".mode_loop", ARG_UNDEFINED, TYPE_BOOLEAN }, diff --git a/src/conf_snd.c b/src/conf_snd.c index cd9869b0..45a8753f 100644 --- a/src/conf_snd.c +++ b/src/conf_snd.c @@ -19,7 +19,7 @@ reliable default values. If that value is SND_ARG_UNDEFINED, it will be dynamically determined, using some of the other list values. */ -struct ConfigInfo sound_config_suffix[] = +struct ConfigTypeInfo sound_config_suffix[] = { { ".mode_loop", ARG_UNDEFINED, TYPE_BOOLEAN }, diff --git a/src/conftime.h b/src/conftime.h index 10db8e49..dae3329a 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2004-06-11 03:48]" +#define COMPILE_DATE_STRING "[2004-06-12 03:59]" diff --git a/src/game.c b/src/game.c index 6de0372c..d43970ca 100644 --- a/src/game.c +++ b/src/game.c @@ -29,6 +29,8 @@ /* EXPERIMENTAL STUFF */ #define USE_NEW_MOVEMENT FALSE +#define USE_NEW_MOVE_DELAY TRUE *1 +#define USE_NEW_PUSH_DELAY TRUE *1 /* for DigField() */ #define DF_NO_PUSH 0 @@ -295,6 +297,8 @@ /* forward declaration for internal use */ +static void AdvanceFrameAndPlayerCounters(int); + static boolean MovePlayerOneStep(struct PlayerInfo *, int, int, int, int); static boolean MovePlayer(struct PlayerInfo *, int, int); static void ScrollPlayer(struct PlayerInfo *, int); @@ -1153,7 +1157,7 @@ static void resolve_group_element(int group_element, int recursion_depth) /* ============================================================================= - InitGameEngine() + InitGameEngine() ----------------------------------------------------------------------------- initialize game engine due to level / tape version number ============================================================================= @@ -1189,6 +1193,15 @@ static void InitGameEngine() /* ---------- initialize player's initial move delay --------------------- */ +#if USE_NEW_MOVE_DELAY + /* dynamically adjust player properties according to level information */ + game.initial_move_delay_value = + (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); + + /* dynamically adjust player properties according to game engine version */ + game.initial_move_delay = (game.engine_version <= VERSION_IDENT(2,0,1,0) ? + game.initial_move_delay_value : 0); +#else /* dynamically adjust player properties according to game engine version */ game.initial_move_delay = (game.engine_version <= VERSION_IDENT(2,0,1,0) ? INITIAL_MOVE_DELAY_ON : @@ -1197,6 +1210,7 @@ static void InitGameEngine() /* dynamically adjust player properties according to level information */ game.initial_move_delay_value = (level.double_speed ? MOVE_DELAY_HIGH_SPEED : MOVE_DELAY_NORMAL_SPEED); +#endif /* ---------- initialize player's initial push delay --------------------- */ @@ -1573,8 +1587,13 @@ void InitGame() player->move_delay_reset_counter = 0; - player->push_delay = 0; +#if USE_NEW_PUSH_DELAY + player->push_delay = -1; /* initialized when pushing starts */ player->push_delay_value = game.initial_push_delay_value; +#else + player->push_delay = 0; + player->push_delay_value = game.initial_push_delay_value; +#endif player->drop_delay = 0; @@ -2890,7 +2909,12 @@ void RelocatePlayer(int jx, int jy, int el_player_raw) { ScrollPlayer(player, SCROLL_GO_ON); ScrollScreen(NULL, SCROLL_GO_ON); + +#if USE_NEW_MOVE_DELAY + AdvanceFrameAndPlayerCounters(player->index_nr); +#else FrameCounter++; +#endif DrawPlayer(player); @@ -8323,6 +8347,45 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) } #endif +void AdvanceFrameAndPlayerCounters(int player_nr) +{ + int i; + + /* advance frame counters (global frame counter and time frame counter) */ + FrameCounter++; + TimeFrames++; + + /* advance player counters (counters for move delay, move animation etc.) */ + for (i = 0; i < MAX_PLAYERS; i++) + { + boolean advance_player_counters = (player_nr == -1 || player_nr == i); + int move_frames = + MOVE_DELAY_NORMAL_SPEED / stored_player[i].move_delay_value; + + if (!advance_player_counters) /* not all players may be affected */ + continue; + + stored_player[i].Frame += move_frames; + + if (stored_player[i].MovPos != 0) + stored_player[i].StepFrame += move_frames; + +#if USE_NEW_MOVE_DELAY + if (stored_player[i].move_delay > 0) + stored_player[i].move_delay--; +#endif + +#if USE_NEW_PUSH_DELAY + /* due to bugs in previous versions, counter must count up, not down */ + if (stored_player[i].push_delay != -1) + stored_player[i].push_delay++; +#endif + + if (stored_player[i].drop_delay > 0) + stored_player[i].drop_delay--; + } +} + void GameActions() { static unsigned long action_delay = 0; @@ -9014,7 +9077,9 @@ void GameActions() stored_player[0].StepFrame); #endif -#if 1 +#if USE_NEW_MOVE_DELAY + AdvanceFrameAndPlayerCounters(-1); /* advance counters for all players */ +#else FrameCounter++; TimeFrames++; @@ -9028,6 +9093,11 @@ void GameActions() if (stored_player[i].MovPos != 0) stored_player[i].StepFrame += move_frames; +#if USE_NEW_MOVE_DELAY + if (stored_player[i].move_delay > 0) + stored_player[i].move_delay--; +#endif + if (stored_player[i].drop_delay > 0) stored_player[i].drop_delay--; } @@ -9513,7 +9583,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) player->move_delay + player->move_delay_value); #endif +#if USE_NEW_MOVE_DELAY + if (player->move_delay > 0) +#else if (!FrameReached(&player->move_delay, player->move_delay_value)) +#endif { #if 0 printf("::: can NOT move\n"); @@ -9533,6 +9607,10 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) printf("::: COULD move now\n"); #endif +#if USE_NEW_MOVE_DELAY + player->move_delay = -1; /* set to "uninitialized" value */ +#endif + /* store if player is automatically moved to next field */ player->is_auto_moving = (player->programmed_action != MV_NO_MOVING); @@ -9558,7 +9636,13 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) { ScrollPlayer(player, SCROLL_GO_ON); ScrollScreen(NULL, SCROLL_GO_ON); + +#if USE_NEW_MOVE_DELAY + AdvanceFrameAndPlayerCounters(player->index_nr); +#else FrameCounter++; +#endif + DrawAllPlayers(); BackToFront(); } @@ -9756,6 +9840,11 @@ boolean MovePlayer(struct PlayerInfo *player, int dx, int dy) #endif } +#if USE_NEW_MOVE_DELAY + if (player->move_delay == -1) /* not yet initialized by DigField() */ + player->move_delay = player->move_delay_value; +#endif + if (game.engine_version < VERSION_IDENT(3,0,7,0)) { TestIfHeroTouchesBadThing(jx, jy); @@ -10810,7 +10899,11 @@ int DigField(struct PlayerInfo *player, if (mode == DF_NO_PUSH) /* player just stopped pushing */ { player->is_switching = FALSE; +#if USE_NEW_PUSH_DELAY + player->push_delay = -1; +#else player->push_delay = 0; +#endif return MF_NO_ACTION; } @@ -11373,16 +11466,56 @@ int DigField(struct PlayerInfo *player, if (!checkDiagonalPushing(player, x, y, real_dx, real_dy)) return MF_NO_ACTION; +#if USE_NEW_PUSH_DELAY + +#if 0 + if ( (player->push_delay == -1) != (player->push_delay2 == 0) ) + printf("::: ALERT: %d, %d [%d / %d]\n", + player->push_delay, player->push_delay2, + FrameCounter, FrameCounter / 50); +#endif + + if (player->push_delay == -1) /* new pushing; restart delay */ + player->push_delay = 0; +#else if (player->push_delay == 0) /* new pushing; restart delay */ player->push_delay = FrameCounter; +#endif + +#if USE_NEW_PUSH_DELAY +#if 0 + if ( (player->push_delay > 0) != (!xxx_fr) ) + printf("::: PUSH BUG! %d, (%d -> %d) %d [%d / %d]\n", + player->push_delay, + xxx_pdv2, player->push_delay2, player->push_delay_value, + FrameCounter, FrameCounter / 50); +#endif + +#if 0 + if (player->push_delay > 0 && + !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + element != EL_SPRING && element != EL_BALLOON) +#else + /* !!! */ + if (player->push_delay < player->push_delay_value && + !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + element != EL_SPRING && element != EL_BALLOON) +#endif +#else if (!FrameReached(&player->push_delay, player->push_delay_value) && !(tape.playing && tape.file_version < FILE_VERSION_2_0) && element != EL_SPRING && element != EL_BALLOON) +#endif { /* make sure that there is no move delay before next try to push */ +#if USE_NEW_MOVE_DELAY + if (game.engine_version >= VERSION_IDENT(3,0,7,1)) + player->move_delay = 0; +#else if (game.engine_version >= VERSION_IDENT(3,0,7,1)) player->move_delay = INITIAL_MOVE_DELAY_OFF; +#endif return MF_NO_ACTION; } @@ -11608,7 +11741,11 @@ int DigField(struct PlayerInfo *player, return MF_NO_ACTION; } +#if USE_NEW_PUSH_DELAY + player->push_delay = -1; +#else player->push_delay = 0; +#endif if (Feld[x][y] != element) /* really digged/collected something */ player->is_collecting = !player->is_digging; diff --git a/src/init.c b/src/init.c index 02b29cdc..c62b8c4e 100644 --- a/src/init.c +++ b/src/init.c @@ -3655,6 +3655,15 @@ void InitElementPropertiesEngine(int engine_version) static void InitGlobal() { + int i; + + for (i = 0; i < MAX_NUM_ELEMENTS + 1; i++) + { + element_info[i].token_name = element_name_info[i].token_name; + element_info[i].class_name = element_name_info[i].class_name; + element_info[i].editor_description=element_name_info[i].editor_description; + } + global.autoplay_leveldir = NULL; global.convert_leveldir = NULL; diff --git a/src/libgame/image.c b/src/libgame/image.c index 108fd39c..977111f4 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -845,7 +845,7 @@ struct PropertyMapping *getImageListPropertyMapping() } void InitImageList(struct ConfigInfo *config_list, int num_file_list_entries, - struct ConfigInfo *config_suffix_list, + struct ConfigTypeInfo *config_suffix_list, char **base_prefixes, char **ext1_suffixes, char **ext2_suffixes, char **ext3_suffixes, char **ignore_tokens) diff --git a/src/libgame/image.h b/src/libgame/image.h index e48e04cc..e9f1dbcd 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -82,7 +82,7 @@ int getImageIDFromToken(char *); char *getImageConfigFilename(); int getImageListPropertyMappingSize(); struct PropertyMapping *getImageListPropertyMapping(); -void InitImageList(struct ConfigInfo *, int, struct ConfigInfo *, +void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *, char **, char **, char **, char **, char **); void ReloadCustomImages(); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index ba379625..225d385c 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1707,7 +1707,7 @@ static void FreeCustomArtworkList(struct ArtworkListInfo *, struct ListNodeInfo ***, int *); struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, - struct ConfigInfo *suffix_list, + struct ConfigTypeInfo *suffix_list, char **ignore_tokens, int num_file_list_entries) { @@ -1842,7 +1842,7 @@ static boolean token_suffix_match(char *token, char *suffix, int start_pos) #define KNOWN_TOKEN_VALUE "[KNOWN_TOKEN_VALUE]" static void read_token_parameters(SetupFileHash *setup_file_hash, - struct ConfigInfo *suffix_list, + struct ConfigTypeInfo *suffix_list, struct FileInfo *file_list_entry) { /* check for config token that is the base token without any suffixes */ @@ -1895,7 +1895,7 @@ static void read_token_parameters(SetupFileHash *setup_file_hash, static void add_dynamic_file_list_entry(struct FileInfo **list, int *num_list_entries, SetupFileHash *extra_file_hash, - struct ConfigInfo *suffix_list, + struct ConfigTypeInfo *suffix_list, int num_suffix_list_entries, char *token) { @@ -1944,7 +1944,7 @@ static void LoadArtworkConfigFromFilename(struct ArtworkListInfo *artwork_info, char *filename) { struct FileInfo *file_list = artwork_info->file_list; - struct ConfigInfo *suffix_list = artwork_info->suffix_list; + struct ConfigTypeInfo *suffix_list = artwork_info->suffix_list; char **base_prefixes = artwork_info->base_prefixes; char **ext1_suffixes = artwork_info->ext1_suffixes; char **ext2_suffixes = artwork_info->ext2_suffixes; diff --git a/src/libgame/misc.h b/src/libgame/misc.h index 2f3a957a..62f3607e 100644 --- a/src/libgame/misc.h +++ b/src/libgame/misc.h @@ -166,7 +166,8 @@ int get_parameter_value(char *, char *, int); int get_auto_parameter_value(char *, char *); struct FileInfo *getFileListFromConfigList(struct ConfigInfo *, - struct ConfigInfo *, char **, int); + struct ConfigTypeInfo *, + char **, int); void LoadArtworkConfig(struct ArtworkListInfo *); void ReloadCustomArtworkList(struct ArtworkListInfo *); void FreeCustomArtworkLists(struct ArtworkListInfo *); diff --git a/src/libgame/sound.c b/src/libgame/sound.c index b9fd88c6..6eb1de14 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -2035,7 +2035,7 @@ struct PropertyMapping *getMusicListPropertyMapping() } void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, - struct ConfigInfo *config_suffix_list, + struct ConfigTypeInfo *config_suffix_list, char **base_prefixes, char **ext1_suffixes, char **ext2_suffixes, char **ext3_suffixes, char **ignore_tokens) @@ -2115,7 +2115,7 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, } void InitMusicList(struct ConfigInfo *config_list, int num_file_list_entries, - struct ConfigInfo *config_suffix_list, + struct ConfigTypeInfo *config_suffix_list, char **base_prefixes, char **ext1_suffixes, char **ext2_suffixes, char **ext3_suffixes, char **ignore_tokens) diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 17a1cee2..ca1e26a6 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -153,9 +153,9 @@ int getSoundListPropertyMappingSize(); int getMusicListPropertyMappingSize(); struct PropertyMapping *getSoundListPropertyMapping(); struct PropertyMapping *getMusicListPropertyMapping(); -void InitSoundList(struct ConfigInfo *, int, struct ConfigInfo *, +void InitSoundList(struct ConfigInfo *, int, struct ConfigTypeInfo *, char **, char **, char **, char **, char **); -void InitMusicList(struct ConfigInfo *, int, struct ConfigInfo *, +void InitMusicList(struct ConfigInfo *, int, struct ConfigTypeInfo *, char **, char **, char **, char **, char **); void InitReloadCustomSounds(char *); void InitReloadCustomMusic(char *); diff --git a/src/libgame/system.h b/src/libgame/system.h index 74a74a67..ad9634a3 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -691,6 +691,12 @@ struct ValueTextInfo }; struct ConfigInfo +{ + char *token; + char *value; +}; + +struct ConfigTypeInfo { char *token; char *value; @@ -750,7 +756,7 @@ struct ArtworkListInfo struct FileInfo *dynamic_file_list; /* dynamic artwrk file array */ int num_suffix_list_entries; - struct ConfigInfo *suffix_list; /* parameter suffixes array */ + struct ConfigTypeInfo *suffix_list; /* parameter suffixes array */ int num_base_prefixes; int num_ext1_suffixes; diff --git a/src/main.c b/src/main.c index 81319ed6..596f996a 100644 --- a/src/main.c +++ b/src/main.c @@ -122,7 +122,10 @@ SetupFileHash *helptext_info = NULL; /* element definitions */ /* ------------------------------------------------------------------------- */ -struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1] = +struct ElementInfo element_info[MAX_NUM_ELEMENTS + 1]; + +/* this contains predefined structure elements to initialize "element_info" */ +struct ElementNameInfo element_name_info[MAX_NUM_ELEMENTS + 1] = { /* keyword to start parser: "ELEMENT_INFO_START" <-- do not change! */ diff --git a/src/main.h b/src/main.h index b4c3c495..b7a70f9f 100644 --- a/src/main.h +++ b/src/main.h @@ -1417,13 +1417,23 @@ struct PlayerInfo int show_envelope; +#if 1 /* USE_NEW_MOVE_DELAY */ + int move_delay; + int move_delay_value; +#else unsigned long move_delay; int move_delay_value; +#endif int move_delay_reset_counter; +#if 1 /* USE_NEW_PUSH_DELAY */ + int push_delay; + int push_delay_value; +#else unsigned long push_delay; unsigned long push_delay_value; +#endif unsigned long actual_frame_counter; @@ -1662,6 +1672,15 @@ struct ElementGroupInfo int choice_pos; /* current element choice position */ }; +struct ElementNameInfo +{ + /* ---------- token and description strings ---------- */ + + char *token_name; /* element token used in config files */ + char *class_name; /* element class used in config files */ + char *editor_description; /* pre-defined description for level editor */ +}; + struct ElementInfo { /* ---------- token and description strings ---------- */ @@ -1961,6 +1980,7 @@ extern struct GlobalInfo global; extern struct MenuInfo menu; extern struct DoorInfo door_1, door_2; extern struct ElementInfo element_info[]; +extern struct ElementNameInfo element_name_info[]; extern struct ElementActionInfo element_action_info[]; extern struct ElementDirectionInfo element_direction_info[]; extern struct SpecialSuffixInfo special_suffix_info[]; @@ -1973,12 +1993,12 @@ extern struct MusicInfo *music_info; extern struct MusicFileInfo *music_file_info; extern struct HelpAnimInfo *helpanim_info; extern SetupFileHash *helptext_info; +extern struct ConfigTypeInfo image_config_suffix[]; +extern struct ConfigTypeInfo sound_config_suffix[]; +extern struct ConfigTypeInfo music_config_suffix[]; extern struct ConfigInfo image_config[]; extern struct ConfigInfo sound_config[]; extern struct ConfigInfo music_config[]; -extern struct ConfigInfo image_config_suffix[]; -extern struct ConfigInfo sound_config_suffix[]; -extern struct ConfigInfo music_config_suffix[]; extern struct ConfigInfo helpanim_config[]; extern struct ConfigInfo helptext_config[];