-#define COMPILE_DATE_STRING "[2005-11-22 02:31]"
+#define COMPILE_DATE_STRING "[2005-11-22 23:49]"
DrawCompleteVideoDisplay();
+ level_editor_test_game = TRUE;
+
+#if 1
+ StartGameActions(FALSE, setup.autorecord, NEW_RANDOMIZE);
+#else
if (setup.autorecord)
TapeStartRecording();
- level_editor_test_game = TRUE;
game_status = GAME_MODE_PLAYING;
InitGame();
+#endif
}
break;
if (game_status == GAME_MODE_MAIN && key == setup.shortcut.toggle_pause)
{
+#if 1
+ StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+#else
if (setup.autorecord)
TapeStartRecording();
StopAnimation();
InitGame();
}
+#endif
return;
}
#endif
}
- CloseDoor(DOOR_CLOSE_1);
+ if (!game.restart_level)
+ CloseDoor(DOOR_CLOSE_1);
/* !!! FIX THIS (START) !!! */
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
}
/* !!! FIX THIS (END) !!! */
- /* copy default game door content to main double buffer */
- BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
- DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
+ if (!game.restart_level)
+ {
+ /* copy default game door content to main double buffer */
+ BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, drawto,
+ DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, DX, DY);
+ }
DrawGameDoorValues();
- UnmapGameButtons();
- UnmapTapeButtons();
- game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music;
- game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops;
- game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple;
- MapGameButtons();
- MapTapeButtons();
+ if (!game.restart_level)
+ {
+ UnmapGameButtons();
+ UnmapTapeButtons();
+ game_gadget[SOUND_CTRL_ID_MUSIC]->checked = setup.sound_music;
+ game_gadget[SOUND_CTRL_ID_LOOPS]->checked = setup.sound_loops;
+ game_gadget[SOUND_CTRL_ID_SIMPLE]->checked = setup.sound_simple;
+ MapGameButtons();
+ MapTapeButtons();
- /* copy actual game door content to door double buffer for OpenDoor() */
- BlitBitmap(drawto, bitmap_db_door,
- DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
+ /* copy actual game door content to door double buffer for OpenDoor() */
+ BlitBitmap(drawto, bitmap_db_door,
+ DX, DY, DXSIZE, DYSIZE, DOOR_GFX_PAGEX1, DOOR_GFX_PAGEY1);
- OpenDoor(DOOR_OPEN_ALL);
+ OpenDoor(DOOR_OPEN_ALL);
- PlaySoundStereo(SND_GAME_STARTING, SOUND_MIDDLE);
+ PlaySoundStereo(SND_GAME_STARTING, SOUND_MIDDLE);
- if (setup.sound_music)
- PlayLevelMusic();
+ if (setup.sound_music)
+ PlayLevelMusic();
- KeyboardAutoRepeatOffUnlessAutoplay();
+ KeyboardAutoRepeatOffUnlessAutoplay();
- if (options.debug)
- {
- for (i = 0; i < MAX_PLAYERS; i++)
- printf("Player %d %sactive.\n",
- i + 1, (stored_player[i].active ? "" : "not "));
+ if (options.debug)
+ {
+ for (i = 0; i < MAX_PLAYERS; i++)
+ printf("Player %d %sactive.\n",
+ i + 1, (stored_player[i].active ? "" : "not "));
+ }
}
+ game.restart_level = FALSE;
+
#if 0
printf("::: starting game [%d]\n", FrameCounter);
#endif
value_new);
}
-static void ExecuteCustomElementAction(int x, int y, int element, int page)
+static void ExecuteCustomElementAction(int element, int page)
{
struct ElementInfo *ei = &element_info[element];
struct ElementChangeInfo *change = &ei->change_page[page];
case CA_RESTART_LEVEL:
{
- printf("::: CA_RESTART_LEVEL -- not yet implemented\n");
+ game.restart_level = TRUE;
break;
}
#if 1
if (change->use_action)
- ExecuteCustomElementAction(x, y, element, page);
+ ExecuteCustomElementAction(element, page);
#endif
if (ChangeElementNow(x, y, element, page))
if (element_info[i].change_page[j].can_change)
SET_PROPERTY(i, EP_CAN_CHANGE, TRUE);
+ /* ---------- HAS_ACTION ----------------------------------------------- */
+ SET_PROPERTY(i, EP_HAS_ACTION, FALSE); /* default: has no action */
+ for (j = 0; j < element_info[i].num_change_pages; j++)
+ if (element_info[i].change_page[j].use_action)
+ SET_PROPERTY(i, EP_HAS_ACTION, TRUE);
+
/* ---------- GFX_CRUMBLED --------------------------------------------- */
#if 1
SET_PROPERTY(i, EP_GFX_CRUMBLED,
options.verbose = TRUE;
}
+static void InitGameInfo()
+{
+ game.restart_level = FALSE;
+}
+
static void InitPlayerInfo()
{
int i;
InitSetup();
+ InitGameInfo();
InitPlayerInfo();
InitArtworkInfo(); /* needed before loading gfx, sound & music */
InitArtworkConfig(); /* needed before forking sound child process */
#define EP_WALK_TO_OBJECT 81
#define EP_DEADLY 82
-#define NUM_ELEMENT_PROPERTIES 83
+/* values for internal purpose only (game engine) */
+#define EP_HAS_ACTION 83
+
+#define NUM_ELEMENT_PROPERTIES 84
#define NUM_EP_BITFIELDS ((NUM_ELEMENT_PROPERTIES + 31) / 32)
#define EP_BITFIELD_BASE 0
HAS_PROPERTY(e, EP_CAN_EXPLODE_BY_EXPLOSION)
#define COULD_MOVE_INTO_ACID(e) HAS_PROPERTY(e, EP_COULD_MOVE_INTO_ACID)
#define MAYBE_DONT_COLLIDE_WITH(e) HAS_PROPERTY(e, EP_MAYBE_DONT_COLLIDE_WITH)
+#define HAS_ACTION(e) HAS_PROPERTY(e, EP_HAS_ACTION)
/* special macros used in game engine */
#define IS_CUSTOM_ELEMENT(e) ((e) >= EL_CUSTOM_START && \
int player_boring_delay_random;
int player_sleeping_delay_fixed;
int player_sleeping_delay_random;
+
+ /* values for special game initialization control */
+ boolean restart_level;
};
struct GlobalInfo
{
LevelDirTree *new_leveldir;
int new_level_nr;
- int dummy; /* !!! HAS NO MEANING ANYMORE !!! */
+ int dummy;
unsigned long new_random_seed;
char *new_leveldir_identifier;
new_level_nr = (buffer[2] << 8) + buffer[3];
- dummy = (buffer[4] << 8) + buffer[5];
+ dummy = (buffer[4] << 8) + buffer[5]; /* (obsolete) */
new_random_seed =
(buffer[6] << 24) | (buffer[7] << 16) | (buffer[8] << 8) | (buffer[9]);
new_leveldir_identifier = (char *)&buffer[10];
LoadTape(level_nr);
LoadLevel(level_nr);
+#if 1
+ StartGameActions(FALSE, setup.autorecord, new_random_seed);
+#else
if (setup.autorecord)
TapeStartRecording();
game_status = GAME_MODE_PLAYING;
InitGame();
+#endif
}
static void Handle_OP_PAUSE_PLAYING()
}
else if (y == 5)
{
+#if 1
+ StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+#else
if (setup.autorecord)
TapeStartRecording();
StopAnimation();
InitGame();
}
+#endif
}
else if (y == 6)
{
}
else
{
+ if (game.restart_level)
+ StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+
if (local_player->LevelSolved)
GameWon();
}
}
+void StartGameActions(boolean init_network_game, boolean record_tape,
+ long random_seed)
+{
+ if (record_tape)
+ TapeStartRecording(random_seed);
+
+#if defined(NETWORK_AVALIABLE)
+ if (init_network_game)
+ {
+ SendToServer_StartPlaying();
+
+ return;
+ }
+#endif
+
+ StopAnimation();
+
+ game_status = GAME_MODE_PLAYING;
+
+ InitRND(random_seed);
+
+ InitGame();
+}
+
/* ---------- new screen button stuff -------------------------------------- */
/* graphic position and size values for buttons and scrollbars */
void HandleTypeName(int, Key);
void HandleGameActions(void);
+void StartGameActions(boolean, boolean, long);
+
void CreateScreenGadgets();
void FreeScreenGadgets();
InitRND(tape.random_seed);
}
-void TapeStartRecording()
+static void TapeSetRandomSeed(long random_seed)
+{
+ tape.random_seed = InitRND(random_seed);
+}
+
+void TapeStartRecording(long random_seed)
{
if (!TAPE_IS_STOPPED(tape))
TapeStop();
TapeErase();
TapeRewind();
+ TapeSetRandomSeed(random_seed);
tape.recording = TRUE;
static void TapeStartGameRecording()
{
- TapeStartRecording();
+ TapeStartRecording(NEW_RANDOMIZE);
#if defined(NETWORK_AVALIABLE)
if (options.network)
void TapeDeactivateDisplayOn();
void TapeDeactivateDisplayOff(boolean);
-void TapeStartRecording(void);
+void TapeStartRecording(long);
void TapeHaltRecording(void);
void TapeStopRecording(void);
void TapeRecordAction(byte *);