From 4cd4b47d80c7ec1843018bcdf8a677622ed9c378 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Mon, 27 May 2002 00:03:04 +0200 Subject: [PATCH] rnd-20020527-1-src --- src/game.c | 179 +++++++++++++++++++++++++++++++++++------------- src/game.h | 1 + src/init.c | 2 + src/timestamp.h | 2 +- 4 files changed, 135 insertions(+), 49 deletions(-) diff --git a/src/game.c b/src/game.c index 38650b36..aa2d2464 100644 --- a/src/game.c +++ b/src/game.c @@ -108,23 +108,44 @@ static void HandleGameButtons(struct GadgetInfo *); static struct GadgetInfo *game_gadget[NUM_GAME_BUTTONS]; -static char *loop_sound_actions[] = +#define SND_ACTION_UNKNOWN 0 +#define SND_ACTION_WAITING 1 +#define SND_ACTION_MOVING 2 +#define SND_ACTION_COLLECTING 3 +#define SND_ACTION_IMPACT 4 +#define SND_ACTION_PUSHING 5 +#define SND_ACTION_ACTIVATING 6 + +#define NUM_SND_ACTIONS 7 + +static struct { - ".waiting", - ".moving", - ".running", - ".burning", - ".growing", - ".attacking" + char *text; + int value; + boolean is_loop; +} sound_action_properties[] = +{ + /* insert _all_ loop sound actions here */ + { ".waiting", SND_ACTION_WAITING, TRUE }, + { ".moving", SND_ACTION_MOVING, TRUE }, /* continuos moving */ + { ".running", SND_ACTION_UNKNOWN, TRUE }, + { ".burning", SND_ACTION_UNKNOWN, TRUE }, + { ".growing", SND_ACTION_UNKNOWN, TRUE }, + { ".attacking", SND_ACTION_UNKNOWN, TRUE }, + + /* other (non-loop) sound actions are optional */ + { ".stepping", SND_ACTION_MOVING, FALSE }, /* discrete moving */ + { ".collecting", SND_ACTION_COLLECTING, FALSE }, + { ".impact", SND_ACTION_IMPACT, FALSE }, + { ".pushing", SND_ACTION_PUSHING, FALSE }, + { ".activating", SND_ACTION_ACTIVATING, FALSE }, + { NULL, 0, 0 }, }; +static int element_action_sound[NUM_LEVEL_ELEMENTS][NUM_SND_ACTIONS]; static boolean is_loop_sound[NUM_SOUND_EFFECTS]; -static boolean sound_info_initialized = FALSE; #define IS_LOOP_SOUND(x) (is_loop_sound[x]) -#define SND_MOVING 1 -#define SND_WAITING 2 - #ifdef DEBUG #if 0 @@ -464,6 +485,89 @@ void DrawGameDoorValues() int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); } +void InitGameEngine() +{ + static int sound_effect_properties[NUM_SOUND_EFFECTS]; + int i, j; + +#if 0 + debug_print_timestamp(0, NULL); +#endif + + for (i=0; i len_action_text && - strcmp(&sound_effects[i].text[len_effect_text - len_action_text], - loop_sound_actions[j]) == 0) - is_loop_sound[i] = TRUE; - } - } - - for (i=0; i= 0) PlaySoundLevel(x, y, sound); +#endif } } @@ -2863,7 +2940,7 @@ void StartMoving(int x, int y) if (MovDelay[x][y]) /* element still has to wait some time */ { - PlaySoundLevelAction(x, y, SND_WAITING); + PlaySoundLevelAction(x, y, SND_ACTION_WAITING); return; } @@ -3080,14 +3157,14 @@ void StartMoving(int x, int y) if (DONT_TOUCH(element)) TestIfBadThingTouchesHero(x, y); - PlaySoundLevelAction(x, y, SND_WAITING); + PlaySoundLevelAction(x, y, SND_ACTION_WAITING); return; } InitMovingField(x, y, MovDir[x][y]); - PlaySoundLevelAction(x, y, SND_MOVING); + PlaySoundLevelAction(x, y, SND_ACTION_MOVING); } if (MovDir[x][y]) @@ -6496,11 +6573,16 @@ void PlaySoundLevel(int x, int y, int nr) PlaySoundExt(nr, volume, stereo_position, type); } -void PlaySoundLevelAction(int x, int y, int action) +void PlaySoundLevelAction(int x, int y, int sound_action) { int element = Feld[x][y]; + int sound_effect = element_action_sound[element][sound_action]; - if (action == SND_MOVING) +#if 1 + if (sound_effect != -1) + PlaySoundLevel(x, y, sound_effect); +#else + if (sound_action == SND_ACTION_MOVING) { if (element == EL_KAEFER) PlaySoundLevel(x, y, SND_BUG_MOVING); @@ -6537,7 +6619,7 @@ void PlaySoundLevelAction(int x, int y, int action) else if (element == EL_ROBOT) PlaySoundLevel(x, y, SND_ROBOT_STEPPING); } - else if (action == SND_WAITING) + else if (sound_action == SND_ACTION_WAITING) { if (element == EL_KAEFER) PlaySoundLevel(x, y, SND_BUG_WAITING); @@ -6572,6 +6654,7 @@ void PlaySoundLevelAction(int x, int y, int action) else if (element == EL_ROBOT) PlaySoundLevel(x, y, SND_ROBOT_WAITING); } +#endif } void RaiseScore(int value) diff --git a/src/game.h b/src/game.h index 11167b9c..93e71fbc 100644 --- a/src/game.h +++ b/src/game.h @@ -31,6 +31,7 @@ void GetPlayerConfig(void); void DrawGameDoorValues(void); +void InitGameEngine(); void InitGame(void); void InitMovDir(int, int); void InitAmoebaNr(int, int); diff --git a/src/init.c b/src/init.c index 8393c629..b6fc2725 100644 --- a/src/init.c +++ b/src/init.c @@ -103,6 +103,8 @@ void OpenAll(void) InitGfxBackground(); InitToons(); + InitGameEngine(); + DrawMainMenu(); InitNetworkServer(); diff --git a/src/timestamp.h b/src/timestamp.h index 5f5a2fae..adc41c61 100644 --- a/src/timestamp.h +++ b/src/timestamp.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2002-05-26 22:32]" +#define COMPILE_DATE_STRING "[2002-05-27 00:01]" -- 2.34.1