projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20020330-1-src
[rocksndiamonds.git]
/
src
/
game.c
diff --git
a/src/game.c
b/src/game.c
index ef2fa469b19eefff66f64d85bb2b3a48ca13d678..c0d43b8bf432636e9960977340fedff96188d52f 100644
(file)
--- a/
src/game.c
+++ b/
src/game.c
@@
-19,12
+19,14
@@
#include "init.h"
#include "files.h"
#include "tape.h"
#include "init.h"
#include "files.h"
#include "tape.h"
-#include "joystick.h"
#include "network.h"
/* this switch controls how rocks move horizontally */
#define OLD_GAME_BEHAVIOUR FALSE
#include "network.h"
/* this switch controls how rocks move horizontally */
#define OLD_GAME_BEHAVIOUR FALSE
+/* EXPERIMENTAL STUFF */
+#define USE_NEW_AMOEBA_CODE FALSE
+
/* for DigField() */
#define DF_NO_PUSH 0
#define DF_DIG 1
/* for DigField() */
#define DF_NO_PUSH 0
#define DF_DIG 1
@@
-171,10
+173,10
@@
void GetPlayerConfig()
setup.sound = FALSE;
if (!audio.loops_available)
setup.sound = FALSE;
if (!audio.loops_available)
- {
setup.sound_loops = FALSE;
setup.sound_loops = FALSE;
+
+ if (!audio.music_available)
setup.sound_music = FALSE;
setup.sound_music = FALSE;
- }
if (!video.fullscreen_available)
setup.fullscreen = FALSE;
if (!video.fullscreen_available)
setup.fullscreen = FALSE;
@@
-268,7
+270,7
@@
static void InitField(int x, int y, boolean init_game)
StorePlayer[x][y] = Feld[x][y];
StorePlayer[x][y] = Feld[x][y];
- if (options.
verbose
)
+ if (options.
debug
)
{
printf("Player %d activated.\n", player->element_nr);
printf("[Local player is %d and currently %s.]\n",
{
printf("Player %d activated.\n", player->element_nr);
printf("[Local player is %d and currently %s.]\n",
@@
-437,6
+439,14
@@
void InitGame()
boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */
boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */
boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */
boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */
+#if DEBUG
+#if USE_NEW_AMOEBA_CODE
+ printf("Using new amoeba code.\n");
+#else
+ printf("Using old amoeba code.\n");
+#endif
+#endif
+
/* don't play tapes over network */
network_playing = (options.network && !tape.playing);
/* don't play tapes over network */
network_playing = (options.network && !tape.playing);
@@
-659,7
+669,7
@@
void InitGame()
tape.player_participates[i] = TRUE;
}
tape.player_participates[i] = TRUE;
}
- if (options.
verbose
)
+ if (options.
debug
)
{
for (i=0; i<MAX_PLAYERS; i++)
{
{
for (i=0; i<MAX_PLAYERS; i++)
{
@@
-682,7
+692,7
@@
void InitGame()
/* dynamically adjust element properties according to game engine version */
{
/* dynamically adjust element properties according to game engine version */
{
- static int ep_
slippery
[] =
+ static int ep_
em_slippery_wall
[] =
{
EL_BETON,
EL_MAUERWERK,
{
EL_BETON,
EL_MAUERWERK,
@@
-691,14
+701,30
@@
void InitGame()
EL_MAUER_Y,
EL_MAUER_XY
};
EL_MAUER_Y,
EL_MAUER_XY
};
- static int ep_slippery_num = sizeof(ep_slippery)/sizeof(int);
+#if 1
+ static int ep_em_slippery_wall_num = SIZEOF_ARRAY_INT(ep_em_slippery_wall);
+#else
+ static int ep_em_slippery_wall_num =
+ sizeof(ep_em_slippery_wall) / sizeof(int);
+#endif
- for (i=0; i<ep_slippery_num; i++)
+ /*
+ printf("level %d: game.version == %06d\n", level_nr, level.game_version);
+ printf(" file_version == %06d\n", level.file_version);
+ */
+
+ for (i=0; i<ep_em_slippery_wall_num; i++)
{
{
+#if 1
+ if (level.em_slippery_gems) /* special EM style gems behaviour */
+#else
if (game.version >= GAME_VERSION_2_0)
if (game.version >= GAME_VERSION_2_0)
- Elementeigenschaften2[ep_slippery[i]] |= EP_BIT_SLIPPERY_GEMS;
+#endif
+ Elementeigenschaften2[ep_em_slippery_wall[i]] |=
+ EP_BIT_EM_SLIPPERY_WALL;
else
else
- Elementeigenschaften2[ep_slippery[i]] &= ~EP_BIT_SLIPPERY_GEMS;
+ Elementeigenschaften2[ep_em_slippery_wall[i]] &=
+ ~EP_BIT_EM_SLIPPERY_WALL;
}
}
}
}
@@
-793,7
+819,7
@@
void InitGame()
KeyboardAutoRepeatOff();
KeyboardAutoRepeatOff();
- if (options.
verbose
)
+ if (options.
debug
)
{
for (i=0; i<4; i++)
printf("Player %d %sactive.\n",
{
for (i=0; i<4; i++)
printf("Player %d %sactive.\n",
@@
-942,12
+968,12
@@
void GameWon()
if (TimeLeft)
{
if (TimeLeft)
{
- if (setup.sound_loops)
+ if (
!tape.playing &&
setup.sound_loops)
PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
while(TimeLeft > 0)
{
PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
while(TimeLeft > 0)
{
- if (!setup.sound_loops)
+ if (!
tape.playing && !
setup.sound_loops)
PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
if (TimeLeft > 0 && !(TimeLeft % 10))
RaiseScore(level.score[SC_ZEITBONUS]);
PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
if (TimeLeft > 0 && !(TimeLeft % 10))
RaiseScore(level.score[SC_ZEITBONUS]);
@@
-957,20
+983,22
@@
void GameWon()
TimeLeft--;
DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW);
BackToFront();
TimeLeft--;
DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW);
BackToFront();
- Delay(10);
+
+ if (!tape.playing)
+ Delay(10);
}
}
- if (setup.sound_loops)
+ if (
!tape.playing &&
setup.sound_loops)
StopSound(SND_SIRR);
}
else if (level.time == 0) /* level without time limit */
{
StopSound(SND_SIRR);
}
else if (level.time == 0) /* level without time limit */
{
- if (setup.sound_loops)
+ if (
!tape.playing &&
setup.sound_loops)
PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
while(TimePlayed < 999)
{
PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP);
while(TimePlayed < 999)
{
- if (!setup.sound_loops)
+ if (!
tape.playing && !
setup.sound_loops)
PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
if (TimePlayed < 999 && !(TimePlayed % 10))
RaiseScore(level.score[SC_ZEITBONUS]);
PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT);
if (TimePlayed < 999 && !(TimePlayed % 10))
RaiseScore(level.score[SC_ZEITBONUS]);
@@
-980,10
+1008,12
@@
void GameWon()
TimePlayed++;
DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW);
BackToFront();
TimePlayed++;
DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW);
BackToFront();
- Delay(10);
+
+ if (!tape.playing)
+ Delay(10);
}
}
- if (setup.sound_loops)
+ if (
!tape.playing &&
setup.sound_loops)
StopSound(SND_SIRR);
}
StopSound(SND_SIRR);
}
@@
-1022,13
+1052,19
@@
void GameWon()
game_status = HALLOFFAME;
DrawHallOfFame(hi_pos);
if (raise_level)
game_status = HALLOFFAME;
DrawHallOfFame(hi_pos);
if (raise_level)
+ {
level_nr++;
level_nr++;
+ TapeErase();
+ }
}
else
{
game_status = MAINMENU;
if (raise_level)
}
else
{
game_status = MAINMENU;
if (raise_level)
+ {
level_nr++;
level_nr++;
+ TapeErase();
+ }
DrawMainMenu();
}
DrawMainMenu();
}
@@
-2605,7
+2641,7
@@
void StartMoving(int x, int y)
#endif
#else
else if ((IS_SLIPPERY(Feld[x][y+1]) ||
#endif
#else
else if ((IS_SLIPPERY(Feld[x][y+1]) ||
- (IS_
SLIPPERY_GEMS
(Feld[x][y+1]) && IS_GEM(element))) &&
+ (IS_
EM_SLIPPERY_WALL
(Feld[x][y+1]) && IS_GEM(element))) &&
!IS_FALLING(x, y+1) && !JustStopped[x][y+1] &&
element != EL_DX_SUPABOMB && element != EL_SP_DISK_ORANGE)
#endif
!IS_FALLING(x, y+1) && !JustStopped[x][y+1] &&
element != EL_DX_SUPABOMB && element != EL_SP_DISK_ORANGE)
#endif
@@
-4201,9
+4237,10
@@
static void PlayerActions(struct PlayerInfo *player, byte player_action)
{
static byte stored_player_action[MAX_PLAYERS];
static int num_stored_actions = 0;
{
static byte stored_player_action[MAX_PLAYERS];
static int num_stored_actions = 0;
+#if 0
static boolean save_tape_entry = FALSE;
static boolean save_tape_entry = FALSE;
+#endif
boolean moved = FALSE, snapped = FALSE, bombed = FALSE;
boolean moved = FALSE, snapped = FALSE, bombed = FALSE;
- int jx = player->jx, jy = player->jy;
int left = player_action & JOY_LEFT;
int right = player_action & JOY_RIGHT;
int up = player_action & JOY_UP;
int left = player_action & JOY_LEFT;
int right = player_action & JOY_RIGHT;
int up = player_action & JOY_UP;
@@
-4221,7
+4258,9
@@
static void PlayerActions(struct PlayerInfo *player, byte player_action)
if (player_action)
{
if (player_action)
{
+#if 0
save_tape_entry = TRUE;
save_tape_entry = TRUE;
+#endif
player->frame_reset_delay = 0;
if (button1)
player->frame_reset_delay = 0;
if (button1)
@@
-4233,15
+4272,20
@@
static void PlayerActions(struct PlayerInfo *player, byte player_action)
moved = MoveFigure(player, dx, dy);
}
moved = MoveFigure(player, dx, dy);
}
+#if 0
if (tape.recording && (moved || snapped || bombed))
{
if (bombed && !moved)
player_action &= JOY_BUTTON;
stored_player_action[player->index_nr] = player_action;
if (tape.recording && (moved || snapped || bombed))
{
if (bombed && !moved)
player_action &= JOY_BUTTON;
stored_player_action[player->index_nr] = player_action;
+ save_tape_entry = TRUE;
}
else if (tape.playing && snapped)
SnapField(player, 0, 0); /* stop snapping */
}
else if (tape.playing && snapped)
SnapField(player, 0, 0); /* stop snapping */
+#else
+ stored_player_action[player->index_nr] = player_action;
+#endif
}
else
{
}
else
{
@@
-4274,16
+4318,26
@@
static void PlayerActions(struct PlayerInfo *player, byte player_action)
player->Frame = 0;
}
player->Frame = 0;
}
+#if 0
if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry)
{
TapeRecordAction(stored_player_action);
num_stored_actions = 0;
save_tape_entry = FALSE;
}
if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry)
{
TapeRecordAction(stored_player_action);
num_stored_actions = 0;
save_tape_entry = FALSE;
}
+#else
+ if (tape.recording && num_stored_actions >= MAX_PLAYERS)
+ {
+ TapeRecordAction(stored_player_action);
+ num_stored_actions = 0;
+ }
+#endif
+#if 0
if (tape.playing && !tape.pausing && !player_action &&
tape.counter < tape.length)
{
if (tape.playing && !tape.pausing && !player_action &&
tape.counter < tape.length)
{
+ int jx = player->jx, jy = player->jy;
int next_joy =
tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
int next_joy =
tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT);
@@
-4307,6
+4361,7
@@
static void PlayerActions(struct PlayerInfo *player, byte player_action)
}
}
}
}
}
}
+#endif
}
void GameActions()
}
void GameActions()
@@
-4474,10
+4529,12
@@
void GameActions()
AmoebeWaechst(x, y);
else if (element == EL_DEAMOEBING)
AmoebeSchrumpft(x, y);
AmoebeWaechst(x, y);
else if (element == EL_DEAMOEBING)
AmoebeSchrumpft(x, y);
-#if 0
+
+#if !USE_NEW_AMOEBA_CODE
else if (IS_AMOEBALIVE(element))
AmoebeAbleger(x, y);
#endif
else if (IS_AMOEBALIVE(element))
AmoebeAbleger(x, y);
#endif
+
else if (element == EL_LIFE || element == EL_LIFE_ASYNC)
Life(x, y);
else if (element == EL_ABLENK_EIN)
else if (element == EL_LIFE || element == EL_LIFE_ASYNC)
Life(x, y);
else if (element == EL_ABLENK_EIN)
@@
-4561,8
+4618,8
@@
void GameActions()
}
}
}
}
-#if
1
- /* new experimental amoeba growth stuff*/
+#if
USE_NEW_AMOEBA_CODE
+ /* new experimental amoeba growth stuff
*/
#if 1
if (!(FrameCounter % 8))
#endif
#if 1
if (!(FrameCounter % 8))
#endif
@@
-4909,9
+4966,15
@@
boolean MoveFigure(struct PlayerInfo *player, int dx, int dy)
if (!player->active || (!dx && !dy))
return FALSE;
if (!player->active || (!dx && !dy))
return FALSE;
+#if 0
if (!FrameReached(&player->move_delay, player->move_delay_value) &&
!tape.playing)
return FALSE;
if (!FrameReached(&player->move_delay, player->move_delay_value) &&
!tape.playing)
return FALSE;
+#else
+ if (!FrameReached(&player->move_delay, player->move_delay_value) &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0))
+ return FALSE;
+#endif
/* remove the last programmed player action */
player->programmed_action = 0;
/* remove the last programmed player action */
player->programmed_action = 0;
@@
-5761,9
+5824,16
@@
int DigField(struct PlayerInfo *player,
if (player->push_delay == 0)
player->push_delay = FrameCounter;
if (player->push_delay == 0)
player->push_delay = FrameCounter;
+#if 0
if (!FrameReached(&player->push_delay, player->push_delay_value) &&
!tape.playing && element != EL_SPRING)
return MF_NO_ACTION;
if (!FrameReached(&player->push_delay, player->push_delay_value) &&
!tape.playing && element != EL_SPRING)
return MF_NO_ACTION;
+#else
+ if (!FrameReached(&player->push_delay, player->push_delay_value) &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+ element != EL_SPRING)
+ return MF_NO_ACTION;
+#endif
RemoveField(x, y);
Feld[x+dx][y+dy] = element;
RemoveField(x, y);
Feld[x+dx][y+dy] = element;
@@
-5996,9
+6066,16
@@
int DigField(struct PlayerInfo *player,
if (player->push_delay == 0)
player->push_delay = FrameCounter;
if (player->push_delay == 0)
player->push_delay = FrameCounter;
+#if 0
if (!FrameReached(&player->push_delay, player->push_delay_value) &&
!tape.playing && element != EL_BALLOON)
return MF_NO_ACTION;
if (!FrameReached(&player->push_delay, player->push_delay_value) &&
!tape.playing && element != EL_BALLOON)
return MF_NO_ACTION;
+#else
+ if (!FrameReached(&player->push_delay, player->push_delay_value) &&
+ !(tape.playing && tape.file_version < FILE_VERSION_2_0) &&
+ element != EL_BALLOON)
+ return MF_NO_ACTION;
+#endif
if (IS_SB_ELEMENT(element))
{
if (IS_SB_ELEMENT(element))
{
@@
-6438,7
+6515,7
@@
static void HandleGameButtons(struct GadgetInfo *gi)
setup.sound_music = FALSE;
FadeMusic();
}
setup.sound_music = FALSE;
FadeMusic();
}
- else if (audio.
loops
_available)
+ else if (audio.
music
_available)
{
setup.sound = setup.sound_music = TRUE;
if (num_bg_loops)
{
setup.sound = setup.sound_music = TRUE;
if (num_bg_loops)