From 8555e08bda91e309c9878785a5aef82ca3497394 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 22 Sep 1999 01:32:05 +0200 Subject: [PATCH] rnd-19990922-1-src --- src/editor.c | 9 +++-- src/files.c | 94 ++++++++++++++++++++++++++++++++++++++++++++-------- src/game.c | 48 ++++++++++++++++++++++----- src/init.c | 71 ++++++++++++++++++++++++++++----------- src/main.c | 20 +++++++++-- src/main.h | 45 ++++++++++++++++++++++++- src/misc.c | 1 + src/pcx.c | 6 ++++ src/tools.c | 29 ++++++++++++++++ src/tools.h | 1 + 10 files changed, 276 insertions(+), 48 deletions(-) diff --git a/src/editor.c b/src/editor.c index f3feeba7..a0f9ca0b 100644 --- a/src/editor.c +++ b/src/editor.c @@ -933,8 +933,13 @@ int editor_element[] = EL_LEERRAUM, EL_MOLE_DOWN, - EL_LEERRAUM, - EL_LEERRAUM, + EL_BALLOON, + EL_BALLOON_SEND_ANY, + + EL_BALLOON_SEND_LEFT, + EL_BALLOON_SEND_RIGHT, + EL_BALLOON_SEND_UP, + EL_BALLOON_SEND_DOWN, EL_SONDE, EL_MAUER_X, diff --git a/src/files.c b/src/files.c index 67f0168c..69e05a60 100644 --- a/src/files.c +++ b/src/files.c @@ -1061,12 +1061,13 @@ void SaveScore(int level_nr) /* level directory info */ #define LEVELINFO_TOKEN_NAME 29 #define LEVELINFO_TOKEN_NAME_SHORT 30 -#define LEVELINFO_TOKEN_AUTHOR 31 -#define LEVELINFO_TOKEN_IMPORTED_FROM 32 -#define LEVELINFO_TOKEN_LEVELS 33 -#define LEVELINFO_TOKEN_FIRST_LEVEL 34 -#define LEVELINFO_TOKEN_SORT_PRIORITY 35 -#define LEVELINFO_TOKEN_READONLY 36 +#define LEVELINFO_TOKEN_NAME_SORTING 31 +#define LEVELINFO_TOKEN_AUTHOR 32 +#define LEVELINFO_TOKEN_IMPORTED_FROM 33 +#define LEVELINFO_TOKEN_LEVELS 34 +#define LEVELINFO_TOKEN_FIRST_LEVEL 35 +#define LEVELINFO_TOKEN_SORT_PRIORITY 36 +#define LEVELINFO_TOKEN_READONLY 37 #define FIRST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_PLAYER_NAME #define LAST_GLOBAL_SETUP_TOKEN SETUP_TOKEN_TIME_LIMIT @@ -1135,6 +1136,7 @@ static struct /* level directory info */ { TYPE_STRING, &ldi.name, "name" }, { TYPE_STRING, &ldi.name_short, "name_short" }, + { TYPE_STRING, &ldi.name_sorting, "name_sorting" }, { TYPE_STRING, &ldi.author, "author" }, { TYPE_STRING, &ldi.imported_from, "imported_from" }, { TYPE_INTEGER, &ldi.levels, "levels" }, @@ -1403,6 +1405,7 @@ static void setLevelDirInfoToDefaults(struct LevelDirInfo *ldi) ldi->filename = NULL; ldi->name = getStringCopy(ANONYMOUS_NAME); ldi->name_short = NULL; + ldi->name_sorting = NULL; ldi->author = getStringCopy(ANONYMOUS_NAME); ldi->imported_from = NULL; ldi->levels = 0; @@ -1548,8 +1551,8 @@ static int compareLevelDirInfoEntries(const void *object1, const void *object2) if (entry1->sort_priority == entry2->sort_priority) { - char *name1 = getStringToLower(entry1->name_short); - char *name2 = getStringToLower(entry2->name_short); + char *name1 = getStringToLower(entry1->name_sorting); + char *name2 = getStringToLower(entry2->name_sorting); compare_result = strcmp(name1, name2); @@ -1604,6 +1607,8 @@ static int LoadLevelInfoFromLevelDir(char *level_directory, int start_entry) if (setup_file_list) { + DrawInitText(dir_entry->d_name, 150, FC_YELLOW); + checkSetupFileListIdentifier(setup_file_list, LEVELINFO_COOKIE); setLevelDirInfoToDefaults(&leveldir[current_entry]); @@ -1616,6 +1621,10 @@ static int LoadLevelInfoFromLevelDir(char *level_directory, int start_entry) leveldir[current_entry].name_short = getStringCopy(leveldir[current_entry].name); + if (leveldir[current_entry].name_sorting == NULL) + leveldir[current_entry].name_sorting = + getStringCopy(leveldir[current_entry].name_short); + leveldir[current_entry].filename = getStringCopy(dir_entry->d_name); leveldir[current_entry].last_level = leveldir[current_entry].first_level + @@ -1636,13 +1645,15 @@ static int LoadLevelInfoFromLevelDir(char *level_directory, int start_entry) free(filename); } - if (current_entry == MAX_LEVDIR_ENTRIES) - Error(ERR_WARN, "using %d level directories -- ignoring the rest", - current_entry); - closedir(dir); - if (current_entry == start_entry) + if (current_entry == MAX_LEVDIR_ENTRIES) + { + Error(ERR_WARN, "maximum of %d level directories reached", current_entry); + Error(ERR_WARN, "remaining level directories ignored in directory '%s'", + level_directory); + } + else if (current_entry == start_entry) Error(ERR_WARN, "cannot find any valid level series in directory '%s'", level_directory); @@ -1656,6 +1667,8 @@ void LoadLevelInfo() num_leveldirs = 0; leveldir_nr = 0; + DrawInitText("Loading level series:", 120, FC_GREEN); + num_leveldirs = LoadLevelInfoFromLevelDir(options.level_directory, num_leveldirs); num_leveldirs = LoadLevelInfoFromLevelDir(getUserLevelDir(""), @@ -1698,7 +1711,9 @@ static void SaveUserLevelInfo() getFormattedSetupEntry(TOKEN_STR_FILE_IDENTIFIER, LEVELINFO_COOKIE)); for (i=FIRST_LEVELINFO_TOKEN; i<=LAST_LEVELINFO_TOKEN; i++) - if (i != LEVELINFO_TOKEN_NAME_SHORT && i != LEVELINFO_TOKEN_IMPORTED_FROM) + if (i != LEVELINFO_TOKEN_NAME_SHORT && + i != LEVELINFO_TOKEN_NAME_SORTING && + i != LEVELINFO_TOKEN_IMPORTED_FROM) fprintf(file, "%s\n", getSetupLine("", i)); fclose(file); @@ -1923,6 +1938,55 @@ void SaveLevelSetup_LastSeries() chmod(filename, SETUP_PERMS); } +static void checkSeriesInfo(int leveldir_nr) +{ + static char *level_directory = NULL; + DIR *dir; + struct dirent *dir_entry; + + /* check for more levels besides the 'levels' field of 'levelinfo.conf' */ + + level_directory = getPath2((leveldir[leveldir_nr].user_defined ? + getUserLevelDir("") : + options.level_directory), + leveldir[leveldir_nr].filename); + + if ((dir = opendir(level_directory)) == NULL) + { + Error(ERR_WARN, "cannot read level directory '%s'", level_directory); + return; + } + + while ((dir_entry = readdir(dir)) != NULL) /* last directory entry */ + { + if (strlen(dir_entry->d_name) > 4 && + dir_entry->d_name[3] == '.' && + strcmp(&dir_entry->d_name[4], LEVELFILE_EXTENSION) == 0) + { + char levelnum_str[4]; + int levelnum_value; + + strncpy(levelnum_str, dir_entry->d_name, 3); + levelnum_str[3] = '\0'; + + levelnum_value = atoi(levelnum_str); + + if (levelnum_value < leveldir[leveldir_nr].first_level) + { + Error(ERR_WARN, "additional level %d found", levelnum_value); + leveldir[leveldir_nr].first_level = levelnum_value; + } + else if (levelnum_value > leveldir[leveldir_nr].last_level) + { + Error(ERR_WARN, "additional level %d found", levelnum_value); + leveldir[leveldir_nr].last_level = levelnum_value; + } + } + } + + closedir(dir); +} + void LoadLevelSetup_SeriesInfo(int leveldir_nr) { char *filename; @@ -1933,6 +1997,8 @@ void LoadLevelSetup_SeriesInfo(int leveldir_nr) level_nr = 0; leveldir[leveldir_nr].handicap_level = 0; + checkSeriesInfo(leveldir_nr); + /* ----------------------------------------------------------------------- */ /* ~/.rocksndiamonds/levelsetup//levelsetup.conf */ /* ----------------------------------------------------------------------- */ diff --git a/src/game.c b/src/game.c index 70febf63..8c18d89c 100644 --- a/src/game.c +++ b/src/game.c @@ -519,6 +519,7 @@ void InitGame() game.light_time_left = 0; game.timegate_time_left = 0; game.switchgate_pos = 0; + game.balloon_dir = MV_NO_MOVING; for (i=0; i<4; i++) { @@ -2213,6 +2214,11 @@ void TurnRound(int x, int y) if (MovDir[x][y] != old_move_dir) MovDelay[x][y] = 9; } + else if (element == EL_BALLOON) + { + MovDir[x][y] = game.balloon_dir; + MovDelay[x][y] = 0; + } else if (element == EL_ROBOT || element == EL_SONDE || element == EL_PINGUIN) { int attr_x = -1, attr_y = -1; @@ -2517,7 +2523,8 @@ void StartMoving(int x, int y) { int newx, newy; - if (element == EL_SONDE && JustBeingPushed(x, y)) + if ((element == EL_SONDE || element == EL_BALLOON) + && JustBeingPushed(x, y)) return; if (!MovDelay[x][y]) /* start new movement phase */ @@ -2633,8 +2640,8 @@ void StartMoving(int x, int y) #endif } - else if ((element == EL_PINGUIN || - element == EL_ROBOT || element == EL_SONDE) && + else if ((element == EL_PINGUIN || element == EL_ROBOT || + element == EL_SONDE || element == EL_BALLOON) && IN_LEV_FIELD(newx, newy) && MovDir[x][y] == MV_DOWN && Feld[newx][newy] == EL_SALZSAEURE) { @@ -2812,7 +2819,8 @@ void StartMoving(int x, int y) else if (element == EL_SP_ELECTRON) DrawGraphicAnimation(x, y, GFX2_SP_ELECTRON, 8, 2, ANIM_NORMAL); - TestIfBadThingHitsHero(x, y); + if (DONT_TOUCH(element)) + TestIfBadThingHitsHero(x, y); return; } @@ -4061,7 +4069,8 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) if (IN_LEV_FIELD(jx+dx, jy) && IS_PUSHABLE(Feld[jx+dx][jy])) { int el = Feld[jx+dx][jy]; - int push_delay = (IS_SB_ELEMENT(el) || el == EL_SONDE ? 2 : 10); + int push_delay = (IS_SB_ELEMENT(el) || el == EL_SONDE ? 2 : + el == EL_BALLOON ? 0 : 10); if (tape.delay_played + push_delay >= tape.pos[tape.counter].delay) { @@ -5311,6 +5320,23 @@ int DigField(struct PlayerInfo *player, return MF_ACTION; break; + case EL_BALLOON_SEND_LEFT: + case EL_BALLOON_SEND_RIGHT: + case EL_BALLOON_SEND_UP: + case EL_BALLOON_SEND_DOWN: + case EL_BALLOON_SEND_ANY: + if (element == EL_BALLOON_SEND_ANY) + game.balloon_dir = move_direction; + else + game.balloon_dir = (element == EL_BALLOON_SEND_LEFT ? MV_LEFT : + element == EL_BALLOON_SEND_RIGHT ? MV_RIGHT : + element == EL_BALLOON_SEND_UP ? MV_UP : + element == EL_BALLOON_SEND_DOWN ? MV_DOWN : + MV_NO_MOVING); + + return MF_ACTION; + break; + case EL_SP_EXIT: if (local_player->gems_still_needed > 0) return MF_NO_ACTION; @@ -5358,7 +5384,7 @@ int DigField(struct PlayerInfo *player, else if (IS_SP_ELEMENT(element)) PlaySoundLevel(x+dx, y+dy, SND_SP_ZONKPUSH); else - PlaySoundLevel(x+dx, y+dy, SND_KLOPF); + PlaySoundLevel(x+dx, y+dy, SND_PUSCH); /* better than "SND_KLOPF" */ break; case EL_PFORTE1: @@ -5505,6 +5531,7 @@ int DigField(struct PlayerInfo *player, case EL_SOKOBAN_OBJEKT: case EL_SONDE: case EL_SP_DISK_YELLOW: + case EL_BALLOON: if (mode == DF_SNAP) return MF_NO_ACTION; @@ -5530,7 +5557,7 @@ int DigField(struct PlayerInfo *player, if (player->push_delay == 0) player->push_delay = FrameCounter; if (!FrameReached(&player->push_delay, player->push_delay_value) && - !tape.playing) + !tape.playing && element != EL_BALLOON) return MF_NO_ACTION; if (IS_SB_ELEMENT(element)) @@ -5559,11 +5586,14 @@ int DigField(struct PlayerInfo *player, Feld[x+dx][y+dy] = element; } - player->push_delay_value = 2; + player->push_delay_value = (element == EL_BALLOON ? 0 : 2); DrawLevelField(x, y); DrawLevelField(x+dx, y+dy); - PlaySoundLevel(x+dx, y+dy, SND_PUSCH); + if (element == EL_BALLOON) + PlaySoundLevel(x+dx, y+dy, SND_SCHLURF); + else + PlaySoundLevel(x+dx, y+dy, SND_PUSCH); if (IS_SB_ELEMENT(element) && local_player->sokobanfields_still_needed == 0 && diff --git a/src/init.c b/src/init.c index daac6396..a9f06177 100644 --- a/src/init.c +++ b/src/init.c @@ -63,8 +63,6 @@ void OpenAll(int argc, char *argv[]) exit(0); } - InitLevelAndPlayerInfo(); - InitCounter(); InitSound(); InitSoundServer(); @@ -81,8 +79,10 @@ void OpenAll(int argc, char *argv[]) XFlush(display); InitGfx(); - InitElementProperties(); + InitElementProperties(); /* initializes IS_CHAR() for el2gfx() */ + InitGadgets(); + InitLevelAndPlayerInfo(); DrawMainMenu(); @@ -456,17 +456,6 @@ void InitWindow(int argc, char *argv[]) gc = XCreateGC(display, window, gc_valuemask, &gc_values); } -void DrawInitText(char *text, int ypos, int color) -{ - if (display && window && pix[PIX_SMALLFONT]) - { - XFillRectangle(display,window,gc,0,ypos, WIN_XSIZE,FONT2_YSIZE); - DrawTextExt(window,gc,(WIN_XSIZE-strlen(text)*FONT2_XSIZE)/2, - ypos,text,FS_SMALL,color); - XFlush(display); - } -} - void InitGfx() { int i,j; @@ -964,7 +953,19 @@ void InitElementProperties() EL_SIGN_EXIT, EL_SIGN_YINYANG, EL_SIGN_OTHER, - EL_STEEL_SLANTED + EL_STEEL_SLANTED, + EL_EMC_STEEL_WALL_1, + EL_EMC_STEEL_WALL_2, + EL_EMC_STEEL_WALL_3, + EL_EMC_STEEL_WALL_4, + EL_EMC_WALL_1, + EL_EMC_WALL_2, + EL_EMC_WALL_3, + EL_EMC_WALL_4, + EL_EMC_WALL_5, + EL_EMC_WALL_6, + EL_EMC_WALL_7, + EL_EMC_WALL_8 }; static int ep_solid_num = sizeof(ep_solid)/sizeof(int); @@ -1035,7 +1036,11 @@ void InitElementProperties() EL_SIGN_EXIT, EL_SIGN_YINYANG, EL_SIGN_OTHER, - EL_STEEL_SLANTED + EL_STEEL_SLANTED, + EL_EMC_STEEL_WALL_1, + EL_EMC_STEEL_WALL_2, + EL_EMC_STEEL_WALL_3, + EL_EMC_STEEL_WALL_4 }; static int ep_massive_num = sizeof(ep_massive)/sizeof(int); @@ -1135,7 +1140,19 @@ void InitElementProperties() EL_SP_TERMINAL, EL_SP_EXIT, EL_INVISIBLE_STEEL, - EL_STEEL_SLANTED + EL_STEEL_SLANTED, + EL_EMC_STEEL_WALL_1, + EL_EMC_STEEL_WALL_2, + EL_EMC_STEEL_WALL_3, + EL_EMC_STEEL_WALL_4, + EL_EMC_WALL_1, + EL_EMC_WALL_2, + EL_EMC_WALL_3, + EL_EMC_WALL_4, + EL_EMC_WALL_5, + EL_EMC_WALL_6, + EL_EMC_WALL_7, + EL_EMC_WALL_8 }; static int ep_mauer_num = sizeof(ep_mauer)/sizeof(int); @@ -1218,7 +1235,8 @@ void InitElementProperties() EL_DRACHE, EL_SONDE, EL_SP_SNIKSNAK, - EL_SP_ELECTRON + EL_SP_ELECTRON, + EL_BALLOON }; static int ep_can_move_num = sizeof(ep_can_move)/sizeof(int); @@ -1471,7 +1489,19 @@ void InitElementProperties() EL_SIGN_EXIT, EL_SIGN_YINYANG, EL_SIGN_OTHER, - EL_STEEL_SLANTED + EL_STEEL_SLANTED, + EL_EMC_STEEL_WALL_1, + EL_EMC_STEEL_WALL_2, + EL_EMC_STEEL_WALL_3, + EL_EMC_STEEL_WALL_4, + EL_EMC_WALL_1, + EL_EMC_WALL_2, + EL_EMC_WALL_3, + EL_EMC_WALL_4, + EL_EMC_WALL_5, + EL_EMC_WALL_6, + EL_EMC_WALL_7, + EL_EMC_WALL_8 }; static int ep_inactive_num = sizeof(ep_inactive)/sizeof(int); @@ -1523,7 +1553,8 @@ void InitElementProperties() EL_SONDE, EL_SP_ZONK, EL_SP_DISK_ORANGE, - EL_SP_DISK_YELLOW + EL_SP_DISK_YELLOW, + EL_BALLOON }; static int ep_pushable_num = sizeof(ep_pushable)/sizeof(int); diff --git a/src/main.c b/src/main.c index 266ad65c..cbaaab66 100644 --- a/src/main.c +++ b/src/main.c @@ -524,8 +524,24 @@ char *element_info[] = "time gate (closed)", "switch for time gate", "switch for time gate", - "-", - "-", + "balloon", + "send balloon to the left", + "send balloon to the right", + "send balloon up", + "send balloon down", /* 330 */ + "send balloon in any direction", + "steel wall", + "steel wall", + "steel wall", + "steel wall", + "normal wall", + "normal wall", + "normal wall", + "normal wall", + "normal wall", /* 340 */ + "normal wall", + "normal wall", + "normal wall", "-" /* diff --git a/src/main.h b/src/main.h index 1dff3be7..72109328 100644 --- a/src/main.h +++ b/src/main.h @@ -215,7 +215,7 @@ typedef unsigned char byte; #define MAX_LEVEL_NAME_LEN 32 #define MAX_LEVEL_AUTHOR_LEN 32 #define MAX_TAPELEN (1000 * 50) /* max. time * framerate */ -#define MAX_LEVDIR_ENTRIES 100 +#define MAX_LEVDIR_ENTRIES 250 /* max. level directories */ #define MAX_SCORE_ENTRIES 100 #define MAX_ELEMENTS 700 /* 500 static + 200 runtime */ #define MAX_NUM_AMOEBA 100 @@ -386,6 +386,7 @@ struct LevelDirInfo char *filename; /* level series sub-directory inside level directory */ char *name; /* level series name, as displayed on main screen */ char *name_short; /* optional short name for level selection screen */ + char *name_sorting; /* optional sorting name for correct level sorting */ char *author; /* level series author name levels without author */ char *imported_from; /* optional comment for imported level series */ int levels; /* number of levels in level series */ @@ -431,6 +432,7 @@ struct GameInfo int belt_dir[4]; int belt_dir_nr[4]; int switchgate_pos; + int balloon_dir; }; struct GlobalInfo @@ -925,6 +927,27 @@ extern char *element_info[]; #define EL_TIMEGATE_SWITCH_ON 324 #define EL_TIMEGATE_SWITCH_OFF 325 +#define EL_BALLOON 326 +#define EL_BALLOON_SEND_LEFT 327 +#define EL_BALLOON_SEND_RIGHT 328 +#define EL_BALLOON_SEND_UP 329 +#define EL_BALLOON_SEND_DOWN 330 +#define EL_BALLOON_SEND_ANY 331 + +#define EL_EMC_STEEL_WALL_1 332 +#define EL_EMC_STEEL_WALL_2 333 +#define EL_EMC_STEEL_WALL_3 334 +#define EL_EMC_STEEL_WALL_4 335 +#define EL_EMC_WALL_1 336 +#define EL_EMC_WALL_2 337 +#define EL_EMC_WALL_3 338 +#define EL_EMC_WALL_4 339 +#define EL_EMC_WALL_5 340 +#define EL_EMC_WALL_6 341 +#define EL_EMC_WALL_7 342 +#define EL_EMC_WALL_8 343 + + /* "real" (and therefore drawable) runtime elements */ #define EL_SIEB_LEER 500 #define EL_SIEB2_LEER 501 @@ -1357,6 +1380,25 @@ extern char *element_info[]; #define GFX_SWITCHGATE_OPEN (GFX_START_ROCKSDC + 5 * DC_PER_LINE + 12) #define GFX_TIMEGATE_CLOSED (GFX_START_ROCKSDC + 6 * DC_PER_LINE + 8) #define GFX_TIMEGATE_OPEN (GFX_START_ROCKSDC + 6 * DC_PER_LINE + 12) +#define GFX_BALLOON_SEND_LEFT (GFX_START_ROCKSDC + 7 * DC_PER_LINE + 8) +#define GFX_BALLOON_SEND_RIGHT (GFX_START_ROCKSDC + 7 * DC_PER_LINE + 9) +#define GFX_BALLOON_SEND_UP (GFX_START_ROCKSDC + 7 * DC_PER_LINE + 10) +#define GFX_BALLOON_SEND_DOWN (GFX_START_ROCKSDC + 7 * DC_PER_LINE + 11) +#define GFX_BALLOON (GFX_START_ROCKSDC + 7 * DC_PER_LINE + 12) +#define GFX_BALLOON_SEND_ANY (GFX_START_ROCKSDC + 0 * DC_PER_LINE + 15) + +#define GFX_EMC_STEEL_WALL_1 (GFX_START_ROCKSDC + 0 * DC_PER_LINE + 14) +#define GFX_EMC_STEEL_WALL_2 (GFX_START_ROCKSDC + 0 * DC_PER_LINE + 14) +#define GFX_EMC_STEEL_WALL_3 (GFX_START_ROCKSDC + 0 * DC_PER_LINE + 14) +#define GFX_EMC_STEEL_WALL_4 (GFX_START_ROCKSDC + 0 * DC_PER_LINE + 14) +#define GFX_EMC_WALL_1 (GFX_START_ROCKSDC + 6 * DC_PER_LINE + 13) +#define GFX_EMC_WALL_2 (GFX_START_ROCKSDC + 6 * DC_PER_LINE + 14) +#define GFX_EMC_WALL_3 (GFX_START_ROCKSDC + 6 * DC_PER_LINE + 15) +#define GFX_EMC_WALL_4 (GFX_START_ROCKSDC + 1 * DC_PER_LINE + 14) +#define GFX_EMC_WALL_5 (GFX_START_ROCKSDC + 1 * DC_PER_LINE + 15) +#define GFX_EMC_WALL_6 (GFX_START_ROCKSDC + 2 * DC_PER_LINE + 14) +#define GFX_EMC_WALL_7 (GFX_START_ROCKSDC + 2 * DC_PER_LINE + 15) +#define GFX_EMC_WALL_8 (GFX_START_ROCKSDC + 1 * DC_PER_LINE + 14) /* graphics from "RocksFont" */ #define GFX_CHAR_START (GFX_START_ROCKSFONT) @@ -1411,6 +1453,7 @@ extern char *element_info[]; #define GFX_DX_UNKNOWN_15 GFX_CHAR_FRAGE #define GFX_DX_UNKNOWN_42 GFX_CHAR_FRAGE + /* the names of the sounds */ #define SND_ALCHEMY 0 #define SND_AMOEBE 1 diff --git a/src/misc.c b/src/misc.c index 33db03d7..3da33597 100644 --- a/src/misc.c +++ b/src/misc.c @@ -347,6 +347,7 @@ char *getStringToLower(char *s) while (*s) *s_ptr++ = tolower(*s++); + *s_ptr = '\0'; return s_copy; } diff --git a/src/pcx.c b/src/pcx.c index a5fd0c92..cb8e5498 100644 --- a/src/pcx.c +++ b/src/pcx.c @@ -15,6 +15,8 @@ #include "image.h" #include "misc.h" +#define PCX_DEBUG FALSE + #define PCX_MAGIC 0x0a /* first byte in a PCX image file */ #define PCX_LAST_VERSION 5 /* last acceptable version number */ #define PCX_ENCODING 1 /* PCX encoding method */ @@ -192,6 +194,7 @@ Image *Read_PCX_to_Image(char *filename) return NULL; } +#if PCX_DEBUG if (options.verbose) { printf("%s is a %dx%d PC Paintbrush image with %d bitplanes\n", @@ -204,6 +207,7 @@ Image *Read_PCX_to_Image(char *filename) (pcx.palette_type == 1 ? "color" : pcx.palette_type == 2 ? "grayscale" : "undefined")); } +#endif /* allocate new image structure */ image = newImage(width, height, depth); @@ -245,8 +249,10 @@ Image *Read_PCX_to_Image(char *filename) if (image->rgb.color_used[i]) image->rgb.used++; +#if PCX_DEBUG if (options.verbose) printf("Read_PCX_to_Image: %d colors found\n", image->rgb.used); +#endif return image; } diff --git a/src/tools.c b/src/tools.c index fbd0ca17..f40c0475 100644 --- a/src/tools.c +++ b/src/tools.c @@ -334,6 +334,17 @@ int getFontHeight(int font_size, int font_type) FONT2_YSIZE); } +void DrawInitText(char *text, int ypos, int color) +{ + if (display && window && pix[PIX_SMALLFONT]) + { + XFillRectangle(display, window, gc, 0, ypos, WIN_XSIZE, FONT2_YSIZE); + DrawTextExt(window, gc, (WIN_XSIZE - strlen(text) * FONT2_XSIZE)/2, + ypos,text,FS_SMALL,color); + XFlush(display); + } +} + void DrawTextFCentered(int y, int font_type, char *format, ...) { char buffer[FULL_SXSIZE / FONT5_XSIZE + 10]; @@ -2568,6 +2579,24 @@ int el2gfx(int element) case EL_TIMEGATE_CLOSED: return GFX_TIMEGATE_CLOSED; case EL_TIMEGATE_SWITCH_ON: return GFX_TIMEGATE_SWITCH; case EL_TIMEGATE_SWITCH_OFF:return GFX_TIMEGATE_SWITCH; + case EL_BALLOON: return GFX_BALLOON; + case EL_BALLOON_SEND_LEFT: return GFX_BALLOON_SEND_LEFT; + case EL_BALLOON_SEND_RIGHT: return GFX_BALLOON_SEND_RIGHT; + case EL_BALLOON_SEND_UP: return GFX_BALLOON_SEND_UP; + case EL_BALLOON_SEND_DOWN: return GFX_BALLOON_SEND_DOWN; + case EL_BALLOON_SEND_ANY: return GFX_BALLOON_SEND_ANY; + case EL_EMC_STEEL_WALL_1: return GFX_EMC_STEEL_WALL_1; + case EL_EMC_STEEL_WALL_2: return GFX_EMC_STEEL_WALL_2; + case EL_EMC_STEEL_WALL_3: return GFX_EMC_STEEL_WALL_3; + case EL_EMC_STEEL_WALL_4: return GFX_EMC_STEEL_WALL_4; + case EL_EMC_WALL_1: return GFX_EMC_WALL_1; + case EL_EMC_WALL_2: return GFX_EMC_WALL_2; + case EL_EMC_WALL_3: return GFX_EMC_WALL_3; + case EL_EMC_WALL_4: return GFX_EMC_WALL_4; + case EL_EMC_WALL_5: return GFX_EMC_WALL_5; + case EL_EMC_WALL_6: return GFX_EMC_WALL_6; + case EL_EMC_WALL_7: return GFX_EMC_WALL_7; + case EL_EMC_WALL_8: return GFX_EMC_WALL_8; default: { diff --git a/src/tools.h b/src/tools.h index 6eaf88c2..18bce3b3 100644 --- a/src/tools.h +++ b/src/tools.h @@ -64,6 +64,7 @@ void FadeToFront(); void ClearWindow(); int getFontWidth(int, int); int getFontHeight(int, int); +void DrawInitText(char *, int, int); void DrawTextF(int, int, int, char *, ...); void DrawTextFCentered(int, int, char *, ...); void DrawText(int, int, char *, int, int); -- 2.34.1