From dd1fc1bbc09d61585abeb4958f2f9708747e85f8 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Sat, 9 Nov 2024 16:50:45 +0100 Subject: [PATCH] added using native level name when showing story before game start --- src/files.c | 13 +++++++++++++ src/main.h | 1 + src/screens.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index 3844e664..9496b89e 100644 --- a/src/files.c +++ b/src/files.c @@ -2395,12 +2395,15 @@ static void setLevelInfoToDefaults_Level(struct LevelInfo *level) level->encoding_16bit_amoeba = TRUE; // clear level name and level author string buffers + for (i = 0; i < MAX_OUTPUT_LINESIZE; i++) + level->name_native[i] = '\0'; for (i = 0; i < MAX_LEVEL_NAME_LEN; i++) level->name[i] = '\0'; for (i = 0; i < MAX_LEVEL_AUTHOR_LEN; i++) level->author[i] = '\0'; // set level name and level author to default values + strcpy(level->name_native, NAMELESS_LEVEL_NAME); strcpy(level->name, NAMELESS_LEVEL_NAME); strcpy(level->author, ANONYMOUS_NAME); @@ -3255,6 +3258,8 @@ static int LoadLevel_NAME(File *file, int chunk_size, struct LevelInfo *level) level->name[i] = getFile8Bit(file); level->name[MAX_LEVEL_NAME_LEN] = 0; + strncpy(level->name_native, level->name, MAX_OUTPUT_LINESIZE); + return chunk_size; } @@ -4685,6 +4690,9 @@ static void CopyNativeLevel_BD_to_RND(struct LevelInfo *level) getStringPrint("%s / %d", cave_name_latin1, bd_level_nr + 1) : getStringCopy(cave_name_latin1)); + strncpy(level->name_native, cave_name_latin1, MAX_OUTPUT_LINESIZE); + level->name_native[MAX_OUTPUT_LINESIZE] = '\0'; + strncpy(level->name, cave_name_final, MAX_LEVEL_NAME_LEN); level->name[MAX_LEVEL_NAME_LEN] = '\0'; @@ -5351,6 +5359,7 @@ static void CopyNativeLevel_MM_to_RND(struct LevelInfo *level) level->df_laser_green = level_mm->df_laser_green; level->df_laser_blue = level_mm->df_laser_blue; + strcpy(level->name_native, level_mm->name); strcpy(level->name, level_mm->name); // only overwrite author from 'levelinfo.conf' if author defined in level @@ -6939,6 +6948,10 @@ static void LoadLevelFromFileStream_DC(File *file, struct LevelInfo *level) level->envelope[0].autowrap = TRUE; level->envelope[0].centered = TRUE; + for (i = 0; i < level_name_len; i++) + level->name_native[i] = header[level_name_pos + 1 + i]; + level->name_native[level_name_len] = '\0'; + for (i = 0; i < level_name_len; i++) level->name[i] = header[level_name_pos + 1 + i]; level->name[level_name_len] = '\0'; diff --git a/src/main.h b/src/main.h index 3b22f255..4422c99e 100644 --- a/src/main.h +++ b/src/main.h @@ -3735,6 +3735,7 @@ struct LevelInfo boolean auto_count_gems; boolean rate_time_over_score; + char name_native[MAX_OUTPUT_LINESIZE + 1]; char name[MAX_LEVEL_NAME_LEN + 1]; char author[MAX_LEVEL_AUTHOR_LEN + 1]; diff --git a/src/screens.c b/src/screens.c index 779e7b31..f5f47981 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1765,7 +1765,7 @@ static void DrawInfoScreen_Headline(int screen_nr, int num_screens, int max_text_len = SXSIZE / getFontWidth(FONT_TITLE_2); int max_name_len = max_text_len - text_format_len; char name_cut[max_name_len]; - char *name_full = (info_mode == INFO_MODE_STORY ? level.name : + char *name_full = (info_mode == INFO_MODE_STORY ? level.name_native : use_global_screens ? getProgramTitleString() : leveldir_current->name); -- 2.34.1