From: Holger Schemel Date: Mon, 27 Jan 2003 23:45:09 +0000 (+0100) Subject: rnd-20030128-1-src X-Git-Tag: 3.0.0^2~154 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ff2510f5098b545a03965c6b95296eec6885a4fb;p=rocksndiamonds.git rnd-20030128-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 770195c4..a51b8053 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-01-27 04:33]" +#define COMPILE_DATE_STRING "[2003-01-28 00:43]" diff --git a/src/editor.c b/src/editor.c index c760e12d..540b4092 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1793,7 +1793,7 @@ static void CreateControlButtons() gd_x2 = DOOR_GFX_PAGEX6 + ED_ELEMENTLIST_XPOS; gd_y = DOOR_GFX_PAGEY1 + ED_ELEMENTLIST_YPOS; - getMiniGraphicSource(el2img(element), &deco_bitmap, &deco_x, &deco_y); + getMiniGraphicSource(el2edimg(element), &deco_bitmap, &deco_x, &deco_y); deco_xpos = (ED_ELEMENTLIST_XSIZE - MINI_TILEX) / 2; deco_ypos = (ED_ELEMENTLIST_YSIZE - MINI_TILEY) / 2; @@ -2455,13 +2455,13 @@ void DrawLevelEd() /* draw mouse button brush elements */ DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS, - el2img(new_element1)); + el2edimg(new_element1)); DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS, - el2img(new_element2)); + el2edimg(new_element2)); DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS, - el2img(new_element3)); + el2edimg(new_element3)); /* draw bigger door */ DrawSpecialEditorDoor(); @@ -2637,21 +2637,21 @@ static void PickDrawingElement(int button, int element) new_element1 = element; DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_LEFT_XPOS, DY + ED_WIN_MB_LEFT_YPOS, - el2img(new_element1)); + el2edimg(new_element1)); } else if (button == 2) { new_element2 = element; DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_MIDDLE_XPOS, DY + ED_WIN_MB_MIDDLE_YPOS, - el2img(new_element2)); + el2edimg(new_element2)); } else { new_element3 = element; DrawMiniGraphicExt(drawto, DX + ED_WIN_MB_RIGHT_XPOS, DY + ED_WIN_MB_RIGHT_YPOS, - el2img(new_element3)); + el2edimg(new_element3)); } redraw_mask |= REDRAW_DOOR_1; @@ -2965,7 +2965,7 @@ static void DrawPropertiesWindow() DrawGraphicAnimationExt(drawto, SX + xstart * MINI_TILEX, SY + ystart * MINI_TILEY + MINI_TILEY / 2, - el2img(properties_element), -1, NO_MASKING); + el2edimg(properties_element), -1, NO_MASKING); FrameCounter = 0; /* restart animation frame counter */ @@ -3752,11 +3752,11 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) DrawMiniGraphicExt(drawto, gi->x + sx * MINI_TILEX, gi->y + sy * MINI_TILEY, - el2img(new_element)); + el2edimg(new_element)); DrawMiniGraphicExt(window, gi->x + sx * MINI_TILEX, gi->y + sy * MINI_TILEY, - el2img(new_element)); + el2edimg(new_element)); if (id == GADGET_ID_AMOEBA_CONTENT) level.amoeba_content = new_element; @@ -4078,7 +4078,7 @@ static void HandleControlButtons(struct GadgetInfo *gi) int element = editor_elements[element_shift + i]; UnmapGadget(gi); - getMiniGraphicSource(el2img(element), &gd->bitmap, &gd->x, &gd->y); + getMiniGraphicSource(el2edimg(element), &gd->bitmap, &gd->x, &gd->y); ModifyGadget(gi, GDI_INFO_TEXT, getElementInfoText(element), GDI_END); MapGadget(gi); } @@ -4354,7 +4354,7 @@ void HandleLevelEditorIdle() DrawGraphicAnimationExt(drawto, SX + xpos * TILEX, SY + ypos * TILEY + MINI_TILEY / 2, - el2img(properties_element), -1, NO_MASKING); + el2edimg(properties_element), -1, NO_MASKING); MarkTileDirty(xpos, ypos); MarkTileDirty(xpos, ypos + 1); diff --git a/src/init.c b/src/init.c index 2c04d701..14acc191 100644 --- a/src/init.c +++ b/src/init.c @@ -74,6 +74,7 @@ static void InitGfxBackground(); static void InitGadgets(); static void InitElementImages(); static void InitElementGraphicInfo(); +static void InitElementEditorGraphicInfo(); static void InitElementSoundInfo(); static void InitElementProperties(); static void InitGraphicInfo(); @@ -189,12 +190,10 @@ static void InitArtworkConfig() static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1]; static char *action_suffix[NUM_ACTIONS + 1]; static char *direction_suffix[NUM_DIRECTIONS + 1]; + static char *special_suffix[NUM_SPECIAL_GFX_ARGS + 1]; static char *dummy[1] = { NULL }; int i; - for (i=0; i game graphic mapping */ + InitElementEditorGraphicInfo(); /* element => editor graphic mapping */ + InitGraphicInfo(); /* graphic => properties mapping */ InitFontInfo(bitmap_font_initial, graphic_info[IMG_FONT_BIG].bitmap, @@ -293,10 +295,10 @@ static void ReinitializeGraphics() static void ReinitializeSounds() { - InitElementSoundInfo(); /* initialize element/sound config info */ - InitSoundInfo(); /* initialize sounds info from config file */ + InitElementSoundInfo(); /* element => game sound mapping */ + InitSoundInfo(); /* sound => properties mapping */ - InitPlaySoundLevel(); /* initialize internal game sound values */ + InitPlaySoundLevel(); /* internal game sound settings */ } static void ReinitializeMusic() @@ -801,8 +803,12 @@ void InitElementGraphicInfo() int element = property_mapping[i].base_index; int action = property_mapping[i].ext1_index; int direction = property_mapping[i].ext2_index; + int special = property_mapping[i].ext3_index; int graphic = property_mapping[i].artwork_index; + if (special != -1) + continue; + if (action < 0) action = ACTION_DEFAULT; @@ -852,6 +858,45 @@ void InitElementGraphicInfo() } } +void InitElementEditorGraphicInfo() +{ + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + int i; + + /* always start with reliable default values */ + for (i=0; inum_ext2_suffixes++; + image_info->num_ext3_suffixes = 0; + for (i=0; ext3_suffixes[i] != NULL; i++) + image_info->num_ext3_suffixes++; + image_info->base_prefixes = base_prefixes; image_info->ext1_suffixes = ext1_suffixes; image_info->ext2_suffixes = ext2_suffixes; + image_info->ext3_suffixes = ext3_suffixes; image_info->num_property_mapping_entries = 0; diff --git a/src/libgame/image.h b/src/libgame/image.h index 46d06425..88e18dda 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -82,7 +82,7 @@ char *getImageConfigFilename(); int getImageListPropertyMappingSize(); struct PropertyMapping *getImageListPropertyMapping(); void InitImageList(struct ConfigInfo *, int, struct ConfigInfo *, - char **, char **, char **); + char **, char **, char **, char **); void ReloadCustomImages(); void CreateImageWithSmallImages(int); diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 32910410..b5dab8f7 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1552,9 +1552,23 @@ struct FileInfo *getFileListFromConfigList(struct ConfigInfo *config_list, for (i=0; config_list[i].token != NULL; i++) { +#if 0 + int len_config_token; + int len_config_value; + boolean is_file_entry; + + printf("%d: '%s' => '%s'\n", + i, config_list[i].token, config_list[i].value); + + len_config_token = strlen(config_list[i].token); + len_config_value = strlen(config_list[i].value); + is_file_entry = TRUE; + +#else int len_config_token = strlen(config_list[i].token); int len_config_value = strlen(config_list[i].value); boolean is_file_entry = TRUE; +#endif for (j=0; suffix_list[j].token != NULL; j++) { @@ -1616,7 +1630,7 @@ static boolean token_suffix_match(char *token, char *suffix, int start_pos) int len_suffix = strlen(suffix); #if 0 - if (IS_PARENT_PROCESS(audio.mixer_pid)) + if (IS_PARENT_PROCESS()) printf(":::::::::: check '%s' for '%s' ::::::::::\n", token, suffix); #endif @@ -1649,6 +1663,9 @@ static void read_token_parameters(struct SetupFileList *setup_file_list, char *known_token_value = KNOWN_TOKEN_VALUE; int i; + if (file_list_entry->filename != NULL) + free(file_list_entry->filename); + if (filename != NULL) { /* when file definition found, set all parameters to default values */ @@ -1695,7 +1712,7 @@ static void add_dynamic_file_list_entry(struct FileInfo **list, int parameter_array_size = num_suffix_list_entries * sizeof(int); #if 0 - if (IS_PARENT_PROCESS(audio.mixer_pid)) + if (IS_PARENT_PROCESS()) printf("===> found dynamic definition '%s'\n", token); #endif @@ -1704,6 +1721,7 @@ static void add_dynamic_file_list_entry(struct FileInfo **list, new_list_entry = &(*list)[*num_list_entries - 1]; new_list_entry->token = getStringCopy(token); + new_list_entry->filename = NULL; new_list_entry->parameter = checked_calloc(parameter_array_size); read_token_parameters(extra_file_list, suffix_list, new_list_entry); @@ -1711,7 +1729,8 @@ static void add_dynamic_file_list_entry(struct FileInfo **list, static void add_property_mapping(struct PropertyMapping **list, int *num_list_entries, - int base_index, int ext1_index,int ext2_index, + int base_index, int ext1_index, + int ext2_index, int ext3_index, int artwork_index) { struct PropertyMapping *new_list_entry; @@ -1724,6 +1743,7 @@ static void add_property_mapping(struct PropertyMapping **list, new_list_entry->base_index = base_index; new_list_entry->ext1_index = ext1_index; new_list_entry->ext2_index = ext2_index; + new_list_entry->ext3_index = ext3_index; new_list_entry->artwork_index = artwork_index; } @@ -1735,17 +1755,19 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) char **base_prefixes = artwork_info->base_prefixes; char **ext1_suffixes = artwork_info->ext1_suffixes; char **ext2_suffixes = artwork_info->ext2_suffixes; + char **ext3_suffixes = artwork_info->ext3_suffixes; int num_file_list_entries = artwork_info->num_file_list_entries; int num_suffix_list_entries = artwork_info->num_suffix_list_entries; int num_base_prefixes = artwork_info->num_base_prefixes; int num_ext1_suffixes = artwork_info->num_ext1_suffixes; int num_ext2_suffixes = artwork_info->num_ext2_suffixes; + int num_ext3_suffixes = artwork_info->num_ext3_suffixes; char *filename = getCustomArtworkConfigFilename(artwork_info->type); struct SetupFileList *setup_file_list; struct SetupFileList *extra_file_list = NULL; struct SetupFileList *list; char *known_token_value = KNOWN_TOKEN_VALUE; - int i, j, k; + int i, j, k, l; #if 0 printf("GOT CUSTOM ARTWORK CONFIG FILE '%s'\n", filename); @@ -1756,7 +1778,7 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) { if (file_list[i].filename != NULL) free(file_list[i].filename); - file_list[i].filename = NULL; + file_list[i].filename = getStringCopy(file_list[i].default_filename); for (j=0; j skipping token '%s' (parameter token)\n", token); @@ -1860,7 +1882,7 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) if (parameter_suffix_found) continue; - /* ---------- step 1: search for matching base prefix ---------- */ + /* ---------- step 0: search for matching base prefix ---------- */ start_pos = 0; for (i=0; i examining token '%s': search 1st suffix ...\n", token); #endif - /* ---------- step 2: search for matching first suffix ---------- */ + /* ---------- step 1: search for matching first suffix ---------- */ start_pos += len_base_prefix; for (j=0; j examining token '%s': search 2nd suffix ...\n", token); + if (IS_PARENT_PROCESS()) + printf("---> examining token '%s': search 2nd suffix ...\n", token); #endif - /* ---------- step 3: search for matching second suffix ---------- */ + /* ---------- step 2: search for matching second suffix ---------- */ - start_pos += len_ext1_suffix; - for (k=0; k examining token '%s': search 3rd suffix ...\n",token); +#endif + + /* ---------- step 3: search for matching third suffix ---------- */ + + for (l=0; lsizeof_artwork_list_entry); } - if (extra_file_list != NULL && - options.verbose && IS_PARENT_PROCESS(audio.mixer_pid)) + if (extra_file_list != NULL && options.verbose && IS_PARENT_PROCESS()) { boolean dynamic_tokens_found = FALSE; boolean unknown_tokens_found = FALSE; @@ -2187,14 +2272,17 @@ void ReloadCustomArtworkList(struct ArtworkListInfo *artwork_info) #if 0 printf("DEBUG: reloading %d static artwork files ...\n", num_file_list_entries); - printf("DEBUG: reloading %d dynamic artwork files ...\n", - num_dynamic_file_list_entries); #endif for(i=0; iartwork_list[i], file_list[i].filename, i); +#if 0 + printf("DEBUG: reloading %d dynamic artwork files ...\n", + num_dynamic_file_list_entries); +#endif + for(i=0; idynamic_artwork_list[i], dynamic_file_list[i].filename, i); @@ -2228,7 +2316,7 @@ void FreeCustomArtworkLists(struct ArtworkListInfo *artwork_info) #if 0 printf("%s: FREEING ARTWORK ...\n", - IS_CHILD_PROCESS(audio.mixer_pid) ? "CHILD" : "PARENT"); + IS_CHILD_PROCESS() ? "CHILD" : "PARENT"); #endif FreeCustomArtworkList(artwork_info, &artwork_info->artwork_list, @@ -2239,7 +2327,7 @@ void FreeCustomArtworkLists(struct ArtworkListInfo *artwork_info) #if 0 printf("%s: FREEING ARTWORK -- DONE\n", - IS_CHILD_PROCESS(audio.mixer_pid) ? "CHILD" : "PARENT"); + IS_CHILD_PROCESS() ? "CHILD" : "PARENT"); #endif } diff --git a/src/libgame/sound.c b/src/libgame/sound.c index ffb9925b..3f1d04e9 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -253,13 +253,15 @@ static boolean ForkAudioProcess(void) return FALSE; } + if (audio.mixer_pid == 0) /* we are the child process */ + audio.mixer_pid = getpid(); + #if 0 - printf("PID: %d [%s]\n", getpid(), - (IS_CHILD_PROCESS(audio.mixer_pid) ? "child" : "parent")); + printf("PID: %d [%s]\n", getpid(),(IS_CHILD_PROCESS() ? "child" : "parent")); Delay(10000 * 0); #endif - if (IS_CHILD_PROCESS(audio.mixer_pid)) + if (IS_CHILD_PROCESS()) Mixer_Main(); /* this function never returns */ else close(audio.mixer_pipe[0]); /* no reading from pipe needed */ @@ -290,7 +292,7 @@ void UnixCloseAudio(void) if (audio.device_fd) close(audio.device_fd); - if (IS_PARENT_PROCESS(audio.mixer_pid)) + if (IS_PARENT_PROCESS()) kill(audio.mixer_pid, SIGTERM); } @@ -457,7 +459,7 @@ static void InitAudioDevice(struct AudioFormatInfo *afmt) static void SendSoundControlToMixerProcess(SoundControl *snd_ctrl) { - if (IS_CHILD_PROCESS(audio.mixer_pid)) + if (IS_CHILD_PROCESS()) return; if (write(audio.mixer_pipe[1], snd_ctrl, sizeof(SoundControl)) < 0) @@ -470,7 +472,7 @@ static void SendSoundControlToMixerProcess(SoundControl *snd_ctrl) static void ReadSoundControlFromMainProcess(SoundControl *snd_ctrl) { - if (IS_PARENT_PROCESS(audio.mixer_pid)) + if (IS_PARENT_PROCESS()) return; if (read(audio.mixer_pipe[0], snd_ctrl, sizeof(SoundControl)) @@ -492,7 +494,7 @@ static void WriteReloadInfoToPipe(char *set_identifier, int type) setup.override_level_sounds : setup.override_level_music); - if (IS_CHILD_PROCESS(audio.mixer_pid)) + if (IS_CHILD_PROCESS()) return; if (leveldir_current == NULL) /* should never happen */ @@ -1012,7 +1014,7 @@ static void HandleSoundRequest(SoundControl snd_ctrl) int i; #if defined(AUDIO_UNIX_NATIVE) - if (IS_PARENT_PROCESS(audio.mixer_pid)) + if (IS_PARENT_PROCESS()) { SendSoundControlToMixerProcess(&snd_ctrl); return; @@ -1794,7 +1796,8 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, struct ConfigInfo *config_suffix_list, char **base_prefixes, char **ext1_suffixes, - char **ext2_suffixes) + char **ext2_suffixes, + char **ext3_suffixes) { int i; @@ -1831,9 +1834,14 @@ void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries, for (i=0; ext2_suffixes[i] != NULL; i++) sound_info->num_ext2_suffixes++; + sound_info->num_ext3_suffixes = 0; + for (i=0; ext3_suffixes[i] != NULL; i++) + sound_info->num_ext3_suffixes++; + sound_info->base_prefixes = base_prefixes; sound_info->ext1_suffixes = ext1_suffixes; sound_info->ext2_suffixes = ext2_suffixes; + sound_info->ext3_suffixes = ext3_suffixes; sound_info->num_property_mapping_entries = 0; diff --git a/src/libgame/sound.h b/src/libgame/sound.h index 81d938f1..6bebb5dc 100644 --- a/src/libgame/sound.h +++ b/src/libgame/sound.h @@ -148,7 +148,7 @@ struct FileInfo *getSoundListEntry(int); int getSoundListPropertyMappingSize(); struct PropertyMapping *getSoundListPropertyMapping(); void InitSoundList(struct ConfigInfo *, int, struct ConfigInfo *, - char **, char **, char **); + char **, char **, char **, char **); void InitReloadCustomSounds(char *); void InitReloadCustomMusic(char *); void FreeAllSounds(void); diff --git a/src/libgame/system.c b/src/libgame/system.c index 7ec7d7df..a075e6d1 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -937,7 +937,7 @@ inline void OpenAudio(void) audio.sound_deactivated = FALSE; audio.mixer_pipe[0] = audio.mixer_pipe[1] = 0; - audio.mixer_pid = -1; + audio.mixer_pid = 0; audio.device_name = NULL; audio.device_fd = -1; diff --git a/src/libgame/system.h b/src/libgame/system.h index 655d00b1..89945cb9 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -206,8 +206,8 @@ #define VERSION_PATCH(x) ((x) % 100) /* functions for parent/child process identification */ -#define IS_PARENT_PROCESS(pid) ((pid) > 0 || (pid) == -1) -#define IS_CHILD_PROCESS(pid) ((pid) == 0) +#define IS_PARENT_PROCESS() (audio.mixer_pid != getpid()) +#define IS_CHILD_PROCESS() (audio.mixer_pid == getpid()) /* type definitions */ @@ -521,6 +521,7 @@ struct PropertyMapping int base_index; int ext1_index; int ext2_index; + int ext3_index; int artwork_index; }; @@ -542,10 +543,12 @@ struct ArtworkListInfo int num_base_prefixes; int num_ext1_suffixes; int num_ext2_suffixes; + int num_ext3_suffixes; char **base_prefixes; /* base token prefixes array */ char **ext1_suffixes; /* property suffixes array 1 */ char **ext2_suffixes; /* property suffixes array 2 */ + char **ext3_suffixes; /* property suffixes array 3 */ int num_property_mapping_entries; diff --git a/src/main.c b/src/main.c index f32e6f35..a6a970f9 100644 --- a/src/main.c +++ b/src/main.c @@ -2798,7 +2798,7 @@ struct ElementActionInfo element_action_info[] = { ".active", ACTION_ACTIVE, TRUE }, { ".other", ACTION_OTHER, FALSE }, - { NULL, 0, 0 }, + { NULL, 0, 0 } }; struct ElementDirectionInfo element_direction_info[] = @@ -2808,7 +2808,14 @@ struct ElementDirectionInfo element_direction_info[] = { ".up", MV_BIT_UP }, { ".down", MV_BIT_DOWN }, - { NULL, 0 }, + { NULL, 0 } +}; + +struct SpecialSuffixInfo special_suffix_info[] = +{ + { ".EDITOR", 0, }, + + { NULL, 0, } }; diff --git a/src/main.h b/src/main.h index 040412fd..31264e03 100644 --- a/src/main.h +++ b/src/main.h @@ -798,6 +798,11 @@ #define NUM_ACTIONS 21 +/* values for special image configuration suffixes */ +#define GFX_SPECIAL_ARG_EDITOR 0 + +#define NUM_SPECIAL_GFX_ARGS 1 + /* values for image configuration suffixes */ #define GFX_ARG_XPOS 0 @@ -1050,6 +1055,8 @@ struct ElementInfo /* special graphics for left/right/up/down */ int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS]; + int editor_graphic; /* graphic displayed in level editor */ + int sound[NUM_ACTIONS]; /* default sounds for several actions */ }; @@ -1088,6 +1095,12 @@ struct ElementDirectionInfo int value; }; +struct SpecialSuffixInfo +{ + char *suffix; + int value; +}; + #if 0 extern GC tile_clip_gc; @@ -1164,6 +1177,7 @@ extern struct GlobalInfo global; extern struct ElementInfo element_info[]; extern struct ElementActionInfo element_action_info[]; extern struct ElementDirectionInfo element_direction_info[]; +extern struct SpecialSuffixInfo special_suffix_info[]; extern struct GraphicInfo *graphic_info; extern struct SoundInfo *sound_info; extern struct ConfigInfo image_config[], sound_config[]; diff --git a/src/tools.c b/src/tools.c index 1036ff89..5722e252 100644 --- a/src/tools.c +++ b/src/tools.c @@ -1465,7 +1465,7 @@ void DrawMiniElement(int x, int y, int element) { int graphic; - graphic = el2img(element); + graphic = el2edimg(element); DrawMiniGraphic(x, y, graphic); } @@ -2450,3 +2450,8 @@ int el2img(int element) { return element_info[element].graphic[ACTION_DEFAULT]; } + +int el2edimg(int element) +{ + return element_info[element].editor_graphic; +} diff --git a/src/tools.h b/src/tools.h index 638d58e9..a7415f02 100644 --- a/src/tools.h +++ b/src/tools.h @@ -137,5 +137,6 @@ int el_act_dir2img(int, int, int); int el_act2img(int, int); int el_dir2img(int, int); int el2img(int); +int el2edimg(int); #endif /* TOOLS_H */