From: Holger Schemel Date: Sun, 7 Apr 2002 11:16:10 +0000 (+0200) Subject: rnd-20020407-1-src X-Git-Tag: 2.1.0^2~63 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=dfe0a71a9939e0c55bb54dcc92db1749e8e21747;p=rocksndiamonds.git rnd-20020407-1-src --- diff --git a/src/files.c b/src/files.c index e39ba567..b0a6dd7f 100644 --- a/src/files.c +++ b/src/files.c @@ -1181,9 +1181,9 @@ void SaveScore(int level_nr) #define SETUP_TOKEN_TIME_LIMIT 13 #define SETUP_TOKEN_FULLSCREEN 14 #define SETUP_TOKEN_ASK_ON_ESCAPE 15 -#define SETUP_TOKEN_GRAPHICS_DIR 16 -#define SETUP_TOKEN_SOUNDS_DIR 17 -#define SETUP_TOKEN_MUSIC_DIR 18 +#define SETUP_TOKEN_GRAPHICS_SET 16 +#define SETUP_TOKEN_SOUNDS_SET 17 +#define SETUP_TOKEN_MUSIC_SET 18 #define NUM_GLOBAL_SETUP_TOKENS 19 @@ -1236,9 +1236,9 @@ static struct TokenInfo global_setup_tokens[] = { TYPE_SWITCH, &si.time_limit, "time_limit" }, { TYPE_SWITCH, &si.fullscreen, "fullscreen" }, { TYPE_SWITCH, &si.ask_on_escape, "ask_on_escape" }, - { TYPE_STRING, &si.graphics_dir, "graphics_dir" }, - { TYPE_STRING, &si.sounds_dir, "sounds_dir" }, - { TYPE_STRING, &si.music_dir, "music_dir" }, + { TYPE_STRING, &si.graphics_set, "graphics_set" }, + { TYPE_STRING, &si.sounds_set, "sounds_set" }, + { TYPE_STRING, &si.music_set, "music_set" }, }; static struct TokenInfo shortcut_setup_tokens[] = @@ -1293,9 +1293,9 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->fullscreen = FALSE; si->ask_on_escape = TRUE; - si->graphics_dir = getStringCopy(GRAPHICS_DIRECTORY); - si->sounds_dir = getStringCopy(SOUNDS_DIRECTORY); - si->music_dir = getStringCopy(MUSIC_DIRECTORY); + si->graphics_set = getStringCopy(GRAPHICS_SUBDIR); + si->sounds_set = getStringCopy(SOUNDS_SUBDIR); + si->music_set = getStringCopy(MUSIC_SUBDIR); si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; @@ -1422,7 +1422,7 @@ void SaveSetup() fprintf(file, "%s\n", getSetupLine(global_setup_tokens, "", i)); /* just to make things nicer :) */ - if (i == SETUP_TOKEN_PLAYER_NAME || i == SETUP_TOKEN_GRAPHICS_DIR - 1) + if (i == SETUP_TOKEN_PLAYER_NAME || i == SETUP_TOKEN_GRAPHICS_SET - 1) fprintf(file, "\n"); } diff --git a/src/init.c b/src/init.c index b45aa038..3118aa35 100644 --- a/src/init.c +++ b/src/init.c @@ -366,6 +366,36 @@ void InitGfxBackground() redraw_mask = REDRAW_ALL; } +void ReloadCustomArtwork() +{ + if (artwork.graphics_set_current != artwork.gfx_current->name) + { + int i; + + for(i=0; iname; + } + + if (artwork.sounds_set_current != artwork.snd_current->name) + { + printf("reload sounds ...\n"); + + artwork.sounds_set_current = artwork.snd_current->name; + } + + if (artwork.music_set_current != artwork.mus_current->name) + { + printf("reload music ...\n"); + + artwork.music_set_current = artwork.mus_current->name; + } +} + void InitGadgets() { CreateLevelEditorGadgets(); diff --git a/src/init.h b/src/init.h index f7f447c1..ec3a1eb8 100644 --- a/src/init.h +++ b/src/init.h @@ -17,6 +17,7 @@ #include "main.h" void OpenAll(void); +void ReloadCustomArtwork(); void CloseAllAndExit(int); #endif diff --git a/src/libgame/msdos.c b/src/libgame/msdos.c index 5ca9768d..4c84010f 100644 --- a/src/libgame/msdos.c +++ b/src/libgame/msdos.c @@ -19,6 +19,7 @@ #include "sound.h" #include "joystick.h" #include "misc.h" +#include "setup.h" #include "pcx.h" #define AllegroDefaultScreen() (display->screens[display->default_screen]) @@ -302,9 +303,9 @@ Display *XOpenDisplay(char *display_name) Screen *screen; Display *display; BITMAP *mouse_bitmap = NULL; + char *mouse_filename =getCustomImageFilename(program.msdos_pointer_filename); - mouse_bitmap = Read_PCX_to_AllegroBitmap(program.msdos_pointer_filename); - if (mouse_bitmap == NULL) + if ((mouse_bitmap = Read_PCX_to_AllegroBitmap(mouse_filename)) == NULL) return NULL; screen = malloc(sizeof(Screen)); diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index c4e15425..ef68a08e 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -853,6 +853,9 @@ Bitmap *SDLLoadImage(char *filename) /* free temporary surface */ SDL_FreeSurface(sdl_image_tmp); + new_bitmap->width = new_bitmap->surface->w; + new_bitmap->height = new_bitmap->surface->h; + return new_bitmap; } diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 543e90ab..85073986 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -61,6 +61,7 @@ typedef int Colormap; struct SDLSurfaceInfo { char *source_filename; + int width, height; SDL_Surface *surface; SDL_Surface *surface_masked; GC gc; diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 0f0221aa..a5e2e061 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -375,7 +375,7 @@ char *getCustomImageFilename(char *basename) return filename; /* 4th try: look for default artwork in new default artwork directory */ - filename = getPath2(getDefaultGraphicsDir("gfx_classic"), basename); + filename = getPath2(getDefaultGraphicsDir(GRAPHICS_SUBDIR), basename); if (fileExists(filename)) return filename; @@ -499,23 +499,23 @@ boolean validLevelSeries(TreeInfo *node) return (node != NULL && !node->node_group && !node->parent_link); } -TreeInfo *getFirstValidLevelSeries(TreeInfo *node) +TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *node) { if (node == NULL) { - if (leveldir_first) /* start with first level directory entry */ - return getFirstValidLevelSeries(leveldir_first); + if (node->node_top) /* start with first tree entry */ + return getFirstValidTreeInfoEntry(*node->node_top); else return NULL; } else if (node->node_group) /* enter level group (step down into tree) */ - return getFirstValidLevelSeries(node->node_group); + return getFirstValidTreeInfoEntry(node->node_group); else if (node->parent_link) /* skip start entry of level group */ { if (node->next) /* get first real level series entry */ - return getFirstValidLevelSeries(node->next); + return getFirstValidTreeInfoEntry(node->next); else /* leave empty level group and go on */ - return getFirstValidLevelSeries(node->node_parent->next); + return getFirstValidTreeInfoEntry(node->node_parent->next); } else /* this seems to be a regular level series */ return node; @@ -1478,7 +1478,8 @@ void LoadLevelInfo() LoadLevelInfoFromLevelDir(&leveldir_first, NULL, options.level_directory); LoadLevelInfoFromLevelDir(&leveldir_first, NULL, getUserLevelDir(NULL)); - leveldir_current = getFirstValidLevelSeries(leveldir_first); + /* before sorting, the first entries will be from the user directory */ + leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); if (leveldir_first == NULL) Error(ERR_EXIT, "cannot find any valid level series in any directory"); @@ -1506,7 +1507,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, char *check_dir = NULL; int i; - if (access(getUserLevelDir(filename), F_OK) == 0) /* file exists */ + if (access(filename, F_OK) == 0) /* file exists */ loadSetupFileList(filename); if (setup_file_list == NULL) /* no config file -- look for artwork files */ @@ -1515,7 +1516,7 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, struct dirent *dir_entry; boolean valid_file_found = FALSE; - if ((dir = opendir(base_directory)) != NULL) + if ((dir = opendir(directory_path)) != NULL) { while ((dir_entry = readdir(dir)) != NULL) { @@ -1535,7 +1536,8 @@ static boolean LoadArtworkInfoFromArtworkConf(TreeInfo **node_first, if (!valid_file_found) { - Error(ERR_WARN, "ignoring artwork directory '%s'", base_directory); + if (options.debug) + Error(ERR_WARN, "ignoring artwork directory '%s'", base_directory); free(directory_path); free(filename); @@ -1712,9 +1714,24 @@ void LoadArtworkInfo() TREE_TYPE_MUSIC_DIR); /* before sorting, the first entries will be from the user directory */ - artwork.gfx_current = artwork.gfx_first; - artwork.snd_current = artwork.snd_first; - artwork.mus_current = artwork.mus_first; + artwork.gfx_current = + getTreeInfoFromFilename(artwork.gfx_first, setup.graphics_set); + if (artwork.gfx_current == NULL) + artwork.gfx_current = getFirstValidTreeInfoEntry(artwork.gfx_first); + + artwork.snd_current = + getTreeInfoFromFilename(artwork.snd_first, setup.sounds_set); + if (artwork.snd_current == NULL) + artwork.snd_current = getFirstValidTreeInfoEntry(artwork.snd_first); + + artwork.mus_current = + getTreeInfoFromFilename(artwork.mus_first, setup.music_set); + if (artwork.mus_current == NULL) + artwork.mus_current = getFirstValidTreeInfoEntry(artwork.mus_first); + + artwork.graphics_set_current = artwork.gfx_current->name; + artwork.sounds_set_current = artwork.snd_current->name; + artwork.music_set_current = artwork.mus_current->name; sortTreeInfo(&artwork.gfx_first, compareTreeInfoEntries); sortTreeInfo(&artwork.snd_first, compareTreeInfoEntries); @@ -1852,7 +1869,7 @@ void LoadLevelSetup_LastSeries() struct SetupFileList *level_setup_list = NULL; /* always start with reliable default values */ - leveldir_current = getFirstValidLevelSeries(leveldir_first); + leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); /* ----------------------------------------------------------------------- */ /* ~/./levelsetup.conf */ @@ -1868,7 +1885,7 @@ void LoadLevelSetup_LastSeries() leveldir_current = getTreeInfoFromFilename(leveldir_first, last_level_series); if (leveldir_current == NULL) - leveldir_current = leveldir_first; + leveldir_current = getFirstValidTreeInfoEntry(leveldir_first); checkSetupFileListIdentifier(level_setup_list, getCookie("LEVELSETUP")); diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 66432a77..9837b9e2 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -154,7 +154,7 @@ TreeInfo *newTreeInfo(); void pushTreeInfo(TreeInfo **, TreeInfo *); int numTreeInfo(TreeInfo *); boolean validLevelSeries(TreeInfo *); -TreeInfo *getFirstValidLevelSeries(TreeInfo *); +TreeInfo *getFirstValidTreeInfoEntry(TreeInfo *); TreeInfo *getTreeInfoFirstGroupEntry(TreeInfo *); int numTreeInfoInGroup(TreeInfo *); int posTreeInfo(TreeInfo *); diff --git a/src/libgame/system.c b/src/libgame/system.c index 0e221548..7eaadf68 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -112,18 +112,11 @@ void ClosePlatformDependantStuff(void) void InitProgramInfo(char *unix_userdata_directory, char *program_title, char *window_title, char *icon_title, - char *x11_icon_basename, char *x11_iconmask_basename, - char *msdos_pointer_basename, + char *x11_icon_filename, char *x11_iconmask_filename, + char *msdos_pointer_filename, char *cookie_prefix, char *filename_prefix, int program_version) { - char *x11_icon_filename = - getPath2(options.graphics_directory, x11_icon_basename); - char *x11_iconmask_filename = - getPath2(options.graphics_directory, x11_iconmask_basename); - char *msdos_pointer_filename = - getPath2(options.graphics_directory, msdos_pointer_basename); - #if defined(PLATFORM_UNIX) program.userdata_directory = unix_userdata_directory; #else @@ -635,6 +628,8 @@ Bitmap *LoadImage(char *filename) new_bitmap = X11LoadImage(filename); #endif + new_bitmap->source_filename = getStringCopy(filename); + return new_bitmap; } @@ -649,11 +644,55 @@ Bitmap *LoadCustomImage(char *basename) if ((new_bitmap = LoadImage(filename)) == NULL) Error(ERR_EXIT, "LoadImage() failed: %s", GetError()); - new_bitmap->source_filename = getStringCopy(filename); - return new_bitmap; } +void ReloadCustomImage(Bitmap **bitmap, char *basename) +{ + char *filename = getCustomImageFilename(basename); + Bitmap *old_bitmap = *bitmap; + Bitmap *new_bitmap; + + if (filename == NULL) /* (should never happen) */ + { + Error(ERR_WARN, "ReloadCustomImage(): cannot find file '%s'", basename); + return; + } + + if (strcmp(filename, old_bitmap->source_filename) == 0) + { + /* The old and new image are the same (have the same filename and path). + This usually means that this image does not exist in this graphic set + and a fallback to the existing image is done. */ + + return; + } + + if ((new_bitmap = LoadImage(filename)) == NULL) + { + Error(ERR_WARN, "LoadImage() failed: %s", GetError()); + return; + } + + if (old_bitmap->width != new_bitmap->width || + old_bitmap->height != new_bitmap->height) + { + Error(ERR_WARN, "ReloadCustomImage: new image has wrong dimensions"); + FreeBitmap(new_bitmap); + return; + } + + /* copy filename for new image */ + free(old_bitmap->source_filename); + old_bitmap->source_filename = getStringCopy(filename); + + /* copy bitmap data for new image */ + BlitBitmap(new_bitmap, old_bitmap, 0,0, + old_bitmap->width, old_bitmap->height, 0,0); + + FreeBitmap(new_bitmap); +} + /* ========================================================================= */ /* audio functions */ diff --git a/src/libgame/system.h b/src/libgame/system.h index 5f630fa3..145bac1d 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -125,12 +125,22 @@ #define RW_BASE_PATH RW_GAME_DIR #define GRAPHICS_DIRECTORY "graphics" -#define MUSIC_DIRECTORY "music" #define SOUNDS_DIRECTORY "sounds" +#define MUSIC_DIRECTORY "music" #define LEVELS_DIRECTORY "levels" #define TAPES_DIRECTORY "tapes" #define SCORES_DIRECTORY "scores" +#if !defined(PLATFORM_MSDOS) +#define GRAPHICS_SUBDIR "gfx_classic" +#define SOUNDS_SUBDIR "snd_classic" +#define MUSIC_SUBDIR "mus_classic" +#else +#define GRAPHICS_SUBDIR "gfx_orig" +#define SOUNDS_SUBDIR "snd_orig" +#define MUSIC_SUBDIR "mus_orig" +#endif + /* areas in bitmap PIX_DOOR */ /* meaning in PIX_DB_DOOR: (3 PAGEs) PAGEX1: 1. buffer for DOOR_1 @@ -307,9 +317,9 @@ struct SetupInfo boolean fullscreen; boolean ask_on_escape; - char *graphics_dir; - char *sounds_dir; - char *music_dir; + char *graphics_set; + char *sounds_set; + char *music_set; struct SetupShortcutInfo shortcut; struct SetupInputInfo input[MAX_PLAYERS]; @@ -370,6 +380,10 @@ struct ArtworkInfo SoundsDirTree *snd_current; MusicDirTree *mus_first; MusicDirTree *mus_current; + + char *graphics_set_current; + char *sounds_set_current; + char *music_set_current; }; @@ -451,6 +465,7 @@ inline boolean ChangeVideoModeIfNeeded(boolean); Bitmap *LoadImage(char *); Bitmap *LoadCustomImage(char *); +void ReloadCustomImage(Bitmap **, char *); inline void OpenAudio(void); inline void CloseAudio(void); diff --git a/src/libgame/x11.c b/src/libgame/x11.c index fd1d8b80..cfa0ce78 100644 --- a/src/libgame/x11.c +++ b/src/libgame/x11.c @@ -14,6 +14,7 @@ #include "system.h" #include "pcx.h" #include "misc.h" +#include "setup.h" #if defined(TARGET_X11) @@ -144,7 +145,7 @@ static DrawWindow *X11InitWindow() icon_pic.picture_filename); #endif if (XReadBitmapFile(display, new_window->drawable, - program.x11_icon_filename, + getCustomImageFilename(program.x11_icon_filename), &icon_width, &icon_height, &icon_pixmap, &icon_hot_x, &icon_hot_y) != BitmapSuccess) Error(ERR_EXIT, "cannot read icon bitmap file '%s'", @@ -155,7 +156,7 @@ static DrawWindow *X11InitWindow() icon_pic.picturemask_filename); #endif if (XReadBitmapFile(display, new_window->drawable, - program.x11_iconmask_filename, + getCustomImageFilename(program.x11_iconmask_filename), &icon_width, &icon_height, &iconmask_pixmap, &icon_hot_x, &icon_hot_y) != BitmapSuccess) Error(ERR_EXIT, "cannot read icon bitmap file '%s'", @@ -231,6 +232,16 @@ static DrawWindow *X11InitWindow() return new_window; } +static void SetImageDimensions(Bitmap *bitmap) +{ + Window root; + int x, y; + unsigned int border_width, depth; + + XGetGeometry(display, bitmap->drawable, &root, &x, &y, + &bitmap->width, &bitmap->height, &border_width, &depth); +} + Bitmap *X11LoadImage(char *filename) { Bitmap *new_bitmap = CreateBitmapStruct(); @@ -285,6 +296,9 @@ Bitmap *X11LoadImage(char *filename) /* set GraphicContext inheritated from Window */ new_bitmap->gc = window->gc; + /* set image width and height */ + SetImageDimensions(new_bitmap); + return new_bitmap; } diff --git a/src/libgame/x11.h b/src/libgame/x11.h index 76c34d8a..43013b93 100644 --- a/src/libgame/x11.h +++ b/src/libgame/x11.h @@ -60,6 +60,7 @@ typedef XClientMessageEvent ClientMessageEvent; struct X11DrawableInfo { char *source_filename; + int width, height; Drawable drawable; Drawable clip_mask; GC gc; /* GC for normal drawing (inheritated from 'window') */ diff --git a/src/screens.c b/src/screens.c index 46324314..e6556da2 100644 --- a/src/screens.c +++ b/src/screens.c @@ -152,6 +152,9 @@ void DrawMainMenu() /* needed if last screen was the setup screen and fullscreen state changed */ ToggleFullscreenIfNeeded(); + /* needed if last screen (setup/level) changed graphics, sounds or music */ + ReloadCustomArtwork(); + #ifdef TARGET_SDL SetDrawtoField(DRAW_BACKBUFFER); #endif @@ -161,7 +164,7 @@ void DrawMainMenu() /* leveldir_current may be invalid (level group, parent link) */ if (!validLevelSeries(leveldir_current)) - leveldir_current = getFirstValidLevelSeries(leveldir_last_valid); + leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); /* store valid level series information */ leveldir_last_valid = leveldir_current; @@ -1350,7 +1353,6 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) static struct TokenInfo *setup_info; static int num_setup_info; -static char *custom_graphics, *custom_sounds, *custom_music; static void execSetupMain() { @@ -1360,7 +1362,7 @@ static void execSetupMain() static void execSetupGraphics() { - custom_graphics = artwork.gfx_current->name; + setup.graphics_set = artwork.gfx_current->name; setup_mode = SETUP_MODE_GRAPHICS; DrawSetupScreen(); @@ -1368,8 +1370,8 @@ static void execSetupGraphics() static void execSetupSound() { - custom_sounds = artwork.snd_current->name; - custom_music = artwork.mus_current->name; + setup.sounds_set = artwork.snd_current->name; + setup.music_set = artwork.mus_current->name; setup_mode = SETUP_MODE_SOUND; DrawSetupScreen(); @@ -1452,7 +1454,7 @@ static struct TokenInfo setup_info_main[] = static struct TokenInfo setup_info_graphics[] = { { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" }, - { TYPE_STRING, &custom_graphics, "" }, + { TYPE_STRING, &setup.graphics_set, "" }, { TYPE_EMPTY, NULL, "" }, { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" }, { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" }, @@ -1471,9 +1473,9 @@ static struct TokenInfo setup_info_sound[] = { TYPE_SWITCH, &setup.sound_music, "Game Music:" }, { TYPE_EMPTY, NULL, "" }, { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" }, - { TYPE_STRING, &custom_sounds, "" }, + { TYPE_STRING, &setup.sounds_set, "" }, { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" }, - { TYPE_STRING, &custom_music, "" }, + { TYPE_STRING, &setup.music_set, "" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Exit" }, { 0, NULL, NULL } @@ -1541,7 +1543,8 @@ static void drawSetupValue(int pos) { int xpos = MENU_SCREEN_VALUE_XPOS; int ypos = MENU_SCREEN_START_YPOS + pos; - int value_color = FC_YELLOW; + int font_size = FS_BIG; + int font_color = FC_YELLOW; char *value_string = getSetupValue(setup_info[pos].type & ~TYPE_GHOSTED, setup_info[pos].value); @@ -1552,23 +1555,26 @@ static void drawSetupValue(int pos) if (setup_info[pos].type & TYPE_QUERY) { value_string = ""; - value_color = FC_RED; + font_color = FC_RED; } } else if (setup_info[pos].type & TYPE_STRING) { - xpos = 3; + int max_value_len = (SCR_FIELDX - 2) * 2; + + xpos = 1; + font_size = FS_MEDIUM; - if (strlen(value_string) > 14) - value_string[14] = '\0'; + if (strlen(value_string) > max_value_len) + value_string[max_value_len] = '\0'; } else if (setup_info[pos].type & TYPE_BOOLEAN_STYLE && !*(boolean *)(setup_info[pos].value)) - value_color = FC_BLUE; + font_color = FC_BLUE; DrawText(SX + xpos * 32, SY + ypos * 32, (xpos == 3 ? " " : " "), FS_BIG, FC_YELLOW); - DrawText(SX + xpos * 32, SY + ypos * 32, value_string, FS_BIG, value_color); + DrawText(SX + xpos * 32, SY + ypos * 32, value_string, font_size,font_color); } static void changeSetupValue(int pos) diff --git a/src/timestamp.h b/src/timestamp.h index bc9167ac..078b3c9b 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-04-06 14:21]" +#define COMPILE_DATE_STRING "[2002-04-07 13:13]" diff --git a/src/tools.c b/src/tools.c index 98292409..b0ffdcf7 100644 --- a/src/tools.c +++ b/src/tools.c @@ -2054,7 +2054,12 @@ unsigned int CloseDoor(unsigned int door_state) unsigned int GetDoorState() { - return(MoveDoor(DOOR_GET_STATE)); + return MoveDoor(DOOR_GET_STATE); +} + +unsigned int SetDoorState(unsigned int door_state) +{ + return MoveDoor(door_state | DOOR_SET_STATE); } unsigned int MoveDoor(unsigned int door_state) @@ -2068,6 +2073,16 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state == DOOR_GET_STATE) return(door1 | door2); + if (door_state & DOOR_SET_STATE) + { + if (door_state & DOOR_ACTION_1) + door1 = door_state & DOOR_ACTION_1; + if (door_state & DOOR_ACTION_2) + door2 = door_state & DOOR_ACTION_2; + + return(door1 | door2); + } + if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) door_state &= ~DOOR_OPEN_1; else if (door1 == DOOR_CLOSE_1 && door_state & DOOR_CLOSE_1) diff --git a/src/tools.h b/src/tools.h index 634bed9b..f6a05abb 100644 --- a/src/tools.h +++ b/src/tools.h @@ -45,6 +45,7 @@ #define DOOR_COPY_BACK (1 << 4) #define DOOR_NO_DELAY (1 << 5) #define DOOR_GET_STATE (1 << 6) +#define DOOR_SET_STATE (1 << 7) /* for Request */ #define REQ_ASK (1 << 0) @@ -104,6 +105,7 @@ boolean Request(char *, unsigned int); unsigned int OpenDoor(unsigned int); unsigned int CloseDoor(unsigned int); unsigned int GetDoorState(void); +unsigned int SetDoorState(unsigned int); unsigned int MoveDoor(unsigned int); void DrawSpecialEditorDoor(); void UndrawSpecialEditorDoor();