From 4b1b5a2a67227d3023ff6da4596be31eae8eaefc Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 25 May 2005 01:21:33 +0200 Subject: [PATCH] rnd-20050525-1-src * fixed bug with moving up despite gravity due to "block last field" * fixed small bug with wrong draw offset when typing name in main menu * when reading user names from "passwd", ignore data after first comma * when creating new "levelinfo.conf", only write some selected entries --- ChangeLog | 6 ++++++ src/conftime.h | 2 +- src/game.c | 3 +++ src/init.c | 1 + src/libgame/misc.c | 24 +++++++++++------------- src/libgame/setup.c | 42 +++++++++++++++++++++++++++++++++++++----- src/main.c | 6 +++--- src/main.h | 3 --- src/screens.c | 13 +++++++------ 9 files changed, 69 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index da554aa6..0f4e570a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-05-24 + * fixed bug with moving up despite gravity due to "block last field" + * fixed small bug with wrong draw offset when typing name in main menu + * when reading user names from "passwd", ignore data after first comma + * when creating new "levelinfo.conf", only write some selected entries + 2005-05-15 * added setup option "skip levels" and possibility to skip levels diff --git a/src/conftime.h b/src/conftime.h index 42000960..31aef8cd 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2005-05-23 21:29]" +#define COMPILE_DATE_STRING "[2005-05-25 01:17]" diff --git a/src/game.c b/src/game.c index 5b9577fb..bac83725 100644 --- a/src/game.c +++ b/src/game.c @@ -9484,6 +9484,9 @@ static boolean canFallDown(struct PlayerInfo *player) return (IN_LEV_FIELD(jx, jy + 1) && (IS_FREE(jx, jy + 1) || +#if USE_NEW_BLOCK_STYLE + Feld[jx][jy + 1] == EL_PLAYER_IS_LEAVING || +#endif (Feld[jx][jy + 1] == EL_ACID && player->can_fall_into_acid)) && IS_WALKABLE_FROM(Feld[jx][jy], MV_DOWN) && !IS_WALKABLE_INSIDE(Feld[jx][jy])); diff --git a/src/init.c b/src/init.c index dbecf851..bce31372 100644 --- a/src/init.c +++ b/src/init.c @@ -2529,6 +2529,7 @@ void InitElementPropertiesStatic() EL_PENGUIN, EL_PIG, EL_DRAGON, + EL_PLAYER_IS_LEAVING, /* needed for gravity + "block last field" */ -1 }; diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 59a273e1..a502ec49 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -337,26 +337,24 @@ static char *get_corrected_real_name(char *real_name) char *from_ptr = real_name; char *to_ptr = real_name_new; - if (strchr(real_name, 'ß') == NULL) /* name does not contain 'ß' */ - { - strncpy(real_name_new, real_name, MAX_USERNAME_LEN); - real_name_new[MAX_USERNAME_LEN] = '\0'; - - return real_name_new; - } - - /* the user's real name may contain a 'ß' character (german sharp s), - which has no equivalent in upper case letters (which our fonts use) */ + /* copy the name string, but not more than MAX_USERNAME_LEN characters */ while (*from_ptr && (long)(to_ptr - real_name_new) < MAX_USERNAME_LEN - 1) { - if (*from_ptr != 'ß') - *to_ptr++ = *from_ptr++; - else + /* the name field read from "passwd" file may also contain additional + user information, separated by commas, which will be removed here */ + if (*from_ptr == ',') + break; + + /* the user's real name may contain 'ß' characters (german sharp s), + which have no equivalent in upper case letters (used by our fonts) */ + if (*from_ptr == 'ß') { from_ptr++; *to_ptr++ = 's'; *to_ptr++ = 's'; } + else + *to_ptr++ = *from_ptr++; } *to_ptr = '\0'; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 63ac0d59..130182df 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -73,10 +73,14 @@ static char *levelclass_desc[NUM_LEVELCLASS_DESC] = IS_ARTWORKCLASS_PRIVATE(n) ? 3 : \ 9) -#define TOKEN_VALUE_POSITION 40 -#define TOKEN_COMMENT_POSITION 60 +#define TOKEN_VALUE_POSITION_SHORT 32 +#define TOKEN_VALUE_POSITION_DEFAULT 40 +#define TOKEN_COMMENT_POSITION_DEFAULT 60 -#define MAX_COOKIE_LEN 256 +#define MAX_COOKIE_LEN 256 + +static int token_value_position = TOKEN_VALUE_POSITION_DEFAULT; +static int token_comment_position = TOKEN_COMMENT_POSITION_DEFAULT; /* ------------------------------------------------------------------------- */ @@ -1205,7 +1209,7 @@ char *getFormattedSetupEntry(char *token, char *value) /* start with the token and some spaces to format output line */ sprintf(entry, "%s:", token); - for (i = strlen(entry); i < TOKEN_VALUE_POSITION; i++) + for (i = strlen(entry); i < token_value_position; i++) strcat(entry, " "); /* continue with the token's value */ @@ -2025,6 +2029,14 @@ static boolean LoadLevelInfoFromLevelConf(TreeInfo **node_first, (leveldir_new->basepath == options.level_directory ? FALSE : TRUE); #endif +#if 1 + /* adjust sort priority if user's private level directory was detected */ + if (leveldir_new->sort_priority == LEVELCLASS_UNDEFINED && + leveldir_new->in_user_dir && + strcmp(leveldir_new->subdir, getLoginName()) == 0) + leveldir_new->sort_priority = LEVELCLASS_PRIVATE_START; +#endif + leveldir_new->user_defined = (leveldir_new->in_user_dir && IS_LEVELCLASS_PRIVATE(leveldir_new)); @@ -2631,11 +2643,13 @@ static void SaveUserLevelInfo() setString(&level_info->author, getRealName()); level_info->levels = 100; level_info->first_level = 1; +#if 0 level_info->sort_priority = LEVELCLASS_PRIVATE_START; level_info->readonly = FALSE; setString(&level_info->graphics_set, GFX_CLASSIC_SUBDIR); setString(&level_info->sounds_set, SND_CLASSIC_SUBDIR); setString(&level_info->music_set, MUS_CLASSIC_SUBDIR); +#endif #else ldi.name = getStringCopy(getLoginName()); ldi.author = getStringCopy(getRealName()); @@ -2648,11 +2662,25 @@ static void SaveUserLevelInfo() ldi.music_set = getStringCopy(MUS_CLASSIC_SUBDIR); #endif + token_value_position = TOKEN_VALUE_POSITION_SHORT; + fprintf(file, "%s\n\n", getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER, getCookie("LEVELINFO"))); ldi = *level_info; for (i = 0; i < NUM_LEVELINFO_TOKENS; i++) + { +#if 1 + if (i == LEVELINFO_TOKEN_NAME || + i == LEVELINFO_TOKEN_AUTHOR || + i == LEVELINFO_TOKEN_LEVELS || + i == LEVELINFO_TOKEN_FIRST_LEVEL) + fprintf(file, "%s\n", getSetupLine(levelinfo_tokens, "", i)); + + /* just to make things nicer :) */ + if (i == LEVELINFO_TOKEN_AUTHOR) + fprintf(file, "\n"); +#else if (i != LEVELINFO_TOKEN_IDENTIFIER && i != LEVELINFO_TOKEN_NAME_SORTING && i != LEVELINFO_TOKEN_IMPORTED_FROM && @@ -2660,6 +2688,10 @@ static void SaveUserLevelInfo() i != LEVELINFO_TOKEN_FILENAME && i != LEVELINFO_TOKEN_FILETYPE) fprintf(file, "%s\n", getSetupLine(levelinfo_tokens, "", i)); +#endif + } + + token_value_position = TOKEN_VALUE_POSITION_DEFAULT; fclose(file); @@ -2741,7 +2773,7 @@ char *getSetupLine(struct TokenInfo *token_info, char *prefix, int token_nr) { /* add at least one whitespace */ strcat(line, " "); - for (i = strlen(line); i < TOKEN_COMMENT_POSITION; i++) + for (i = strlen(line); i < token_comment_position; i++) strcat(line, " "); strcat(line, "# "); diff --git a/src/main.c b/src/main.c index 8c47e61c..8769913c 100644 --- a/src/main.c +++ b/src/main.c @@ -4235,8 +4235,8 @@ struct TokenIntPtrInfo image_config_vars[] = { { "global.num_toons", &global.num_toons }, - { "menu.draw_xoffset", &menu.draw_xoffset_default }, - { "menu.draw_yoffset", &menu.draw_yoffset_default }, + { "menu.draw_xoffset", &menu.draw_xoffset[GFX_SPECIAL_ARG_DEFAULT]}, + { "menu.draw_yoffset", &menu.draw_yoffset[GFX_SPECIAL_ARG_DEFAULT]}, { "menu.draw_xoffset.MAIN", &menu.draw_xoffset[GFX_SPECIAL_ARG_MAIN] }, { "menu.draw_yoffset.MAIN", &menu.draw_yoffset[GFX_SPECIAL_ARG_MAIN] }, { "menu.draw_xoffset.LEVELS", &menu.draw_xoffset[GFX_SPECIAL_ARG_LEVELS] }, @@ -4252,7 +4252,7 @@ struct TokenIntPtrInfo image_config_vars[] = { "menu.scrollbar_xoffset", &menu.scrollbar_xoffset }, - { "menu.list_size", &menu.list_size_default }, + { "menu.list_size", &menu.list_size[GFX_SPECIAL_ARG_DEFAULT] }, { "menu.list_size.LEVELS", &menu.list_size[GFX_SPECIAL_ARG_LEVELS] }, { "menu.list_size.SCORES", &menu.list_size[GFX_SPECIAL_ARG_SCORES] }, { "menu.list_size.INFO", &menu.list_size[GFX_SPECIAL_ARG_INFO] }, diff --git a/src/main.h b/src/main.h index 414ff7fc..c8c83033 100644 --- a/src/main.h +++ b/src/main.h @@ -1441,14 +1441,11 @@ struct MenuInfo { - int draw_xoffset_default; - int draw_yoffset_default; int draw_xoffset[NUM_SPECIAL_GFX_ARGS]; int draw_yoffset[NUM_SPECIAL_GFX_ARGS]; int scrollbar_xoffset; - int list_size_default; int list_size[NUM_SPECIAL_GFX_ARGS]; int sound[NUM_SPECIAL_GFX_ARGS]; diff --git a/src/screens.c b/src/screens.c index 8d4fa282..7d783a9b 100644 --- a/src/screens.c +++ b/src/screens.c @@ -97,12 +97,13 @@ static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; static int setup_mode = SETUP_MODE_MAIN; static int info_mode = INFO_MODE_MAIN; -#define mSX (SX + (game_status >= GAME_MODE_MAIN && \ - game_status <= GAME_MODE_SETUP ? \ - menu.draw_xoffset[game_status] : menu.draw_xoffset_default)) -#define mSY (SY + (game_status >= GAME_MODE_MAIN && \ - game_status <= GAME_MODE_SETUP ? \ - menu.draw_yoffset[game_status] : menu.draw_yoffset_default)) +#define DRAW_OFFSET_MODE(x) (x >= GAME_MODE_MAIN && \ + x <= GAME_MODE_SETUP ? x : \ + x == GAME_MODE_PSEUDO_TYPENAME ? \ + GAME_MODE_MAIN : GAME_MODE_DEFAULT) + +#define mSX (SX + menu.draw_xoffset[DRAW_OFFSET_MODE(game_status)]) +#define mSY (SY + menu.draw_yoffset[DRAW_OFFSET_MODE(game_status)]) #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ? \ menu.list_size[game_status] : \ -- 2.34.1