From: Holger Schemel Date: Sat, 21 Sep 2002 21:10:45 +0000 (+0200) Subject: rnd-20020921-8-src X-Git-Tag: 3.0.0^2~230 X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=commitdiff_plain;h=7db0a9ae54a91806b66eb918f28309bb875e3b69 rnd-20020921-8-src --- diff --git a/src/conf_e2g.c b/src/conf_e2g.c index 1336e543..332a0a00 100644 --- a/src/conf_e2g.c +++ b/src/conf_e2g.c @@ -21,6 +21,9 @@ static struct { int element; + int direction; + int action; + int graphic; } element_to_graphic[] = diff --git a/src/conftime.h b/src/conftime.h index b2898efc..23b21eca 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-09-21 21:53]" +#define COMPILE_DATE_STRING "[2002-09-21 23:08]" diff --git a/src/init.c b/src/init.c index db21b860..54a6436e 100644 --- a/src/init.c +++ b/src/init.c @@ -26,6 +26,9 @@ #include "cartoons.h" #include "config.h" +#include "conf_e2g.c" /* include auto-generated data structure definitions */ + + static char *image_filename[NUM_PICTURES] = { "RocksScreen.pcx", @@ -556,8 +559,7 @@ void InitGadgets() void InitElementInfo() { - int i, j; - +#if 0 static struct { int element; @@ -919,13 +921,19 @@ void InitElementInfo() -1, -1 } }; +#endif + + int i, j, k; /* always start with reliable default values */ for(i=0; i -1) @@ -975,6 +984,33 @@ void InitElementInfo() element_info[element].has_direction_graphic[GFX_ACTION_DEFAULT] = TRUE; i++; } +#else + i = 0; + while (element_to_graphic[i].element > -1) + { + int element = element_to_graphic[i].element; + int direction = element_to_graphic[i].direction; + int action = element_to_graphic[i].action; + int graphic = element_to_graphic[i].graphic; + + if (action > -1) + action = graphics_action_mapping[action]; + else + action = GFX_ACTION_DEFAULT; + + if (direction > -1) + { + direction = MV_DIR_BIT(direction); + + element_info[element].direction_graphic[action][direction] = graphic; + element_info[element].has_direction_graphic[action] = TRUE; + } + else + element_info[element].graphic[action] = graphic; + + i++; + } +#endif } static void InitGraphicInfo() diff --git a/src/libgame/system.h b/src/libgame/system.h index 5072584e..463d76fc 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -71,6 +71,7 @@ #define MV_BIT_RIGHT 1 #define MV_BIT_UP 2 #define MV_BIT_DOWN 3 +#define NUM_MV_DIRECTIONS 4 #define MV_NO_MOVING 0 #define MV_LEFT (1 << MV_BIT_LEFT) @@ -83,7 +84,7 @@ #define KEY_BUTTON (KEY_BUTTON_1 | KEY_BUTTON_2) #define KEY_ACTION (KEY_MOTION | KEY_BUTTON) -#define LOG_MV_DIR(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \ +#define MV_DIR_BIT(x) ((x) == MV_LEFT ? MV_BIT_LEFT : \ (x) == MV_RIGHT ? MV_BIT_RIGHT : \ (x) == MV_UP ? MV_BIT_UP : MV_BIT_DOWN) diff --git a/src/main.c b/src/main.c index 1d202e3a..da3239df 100644 --- a/src/main.c +++ b/src/main.c @@ -137,7 +137,7 @@ char *sound_name[NUM_SOUNDS] = }; /* this is used to reduce memory usage of the different animation types */ -int anim_action_mapping[] = +int graphics_action_mapping[] = { 0, /* GFX_ACTION_UNKNOWN (0) */ 0, /* GFX_ACTION_DEFAULT (1) */ diff --git a/src/main.h b/src/main.h index a6db0911..edac5c48 100644 --- a/src/main.h +++ b/src/main.h @@ -1567,7 +1567,7 @@ struct ElementInfo int graphic[NUM_GFX_ACTIONS_MAPPED]; /* special graphics for left/right/up/down */ - int direction_graphic[NUM_GFX_ACTIONS_MAPPED][4]; + int direction_graphic[NUM_GFX_ACTIONS_MAPPED][NUM_MV_DIRECTIONS]; boolean has_direction_graphic[NUM_GFX_ACTIONS_MAPPED]; }; @@ -1639,6 +1639,8 @@ extern int SiebCount; extern boolean network_player_action_received; +extern int graphics_action_mapping[]; + extern struct LevelInfo level; extern struct PlayerInfo stored_player[], *local_player; extern struct HiScore highscore[]; diff --git a/src/tools.c b/src/tools.c index 110837f4..74d003cd 100644 --- a/src/tools.c +++ b/src/tools.c @@ -3314,6 +3314,12 @@ int el2gfx_OLD(int element) int el2gfx(int element) { +#if 1 + int graphic_OLD = el2gfx_OLD(element); + + return graphic_OLD; +#else + int graphic_NEW = element_info[element].graphic[GFX_ACTION_DEFAULT]; #if DEBUG @@ -3332,10 +3338,17 @@ int el2gfx(int element) #endif return graphic_NEW; +#endif } int el2img(int element) { +#if 1 + int graphic_NEW = element_info[element].graphic[GFX_ACTION_DEFAULT]; + + return graphic_NEW; +#else + switch(element) { case EL_BD_BUTTERFLY: return IMG_BD_BUTTERFLY; @@ -3347,16 +3360,31 @@ int el2img(int element) } return IMG_EMPTY_SPACE; +#endif } int el_dir2img(int element, int direction) { - if (element_info[element].has_direction_graphic[GFX_ACTION_DEFAULT]) + int action = GFX_ACTION_DEFAULT; + + if (element_info[element].has_direction_graphic[action]) { - int i = LOG_MV_DIR(direction); + int direction = MV_DIR_BIT(direction); - return element_info[element].direction_graphic[GFX_ACTION_DEFAULT][i]; + return element_info[element].direction_graphic[action][direction]; } else return el2img(element); } + +int el_dir_act2img(int element, int direction, int action) +{ + if (element_info[element].has_direction_graphic[action]) + { + int direction = MV_DIR_BIT(direction); + + return element_info[element].direction_graphic[action][direction]; + } + else + return el_dir2img(element, direction); +} diff --git a/src/tools.h b/src/tools.h index abe5a402..eb55e5ee 100644 --- a/src/tools.h +++ b/src/tools.h @@ -135,5 +135,6 @@ int get_next_element(int); int el2gfx(int); int el2img(int); int el_dir2img(int, int); +int el_dir_act2img(int, int, int); #endif /* TOOLS_H */