static int check[4][2] = { {-1,0}, {0,-1}, {1,0}, {0,1} };
static int safety = 0;
+ /* check if starting field still has the desired content */
+ if (Feld[from_x][from_y] == fill_element)
+ return;
+
safety++;
- if (safety>lev_fieldx*lev_fieldy)
- {
- fprintf(stderr,"Something went wrong in 'FloodFill()'. Please debug.\n");
- exit(-1);
- }
+ if (safety > lev_fieldx*lev_fieldy)
+ Error(ERR_EXIT, "Something went wrong in 'FloodFill()'. Please debug.");
old_element = Feld[from_x][from_y];
Feld[from_x][from_y] = fill_element;
for(i=0;i<4;i++)
{
- x = from_x+check[i][0];
- y = from_y+check[i][1];
+ x = from_x + check[i][0];
+ y = from_y + check[i][1];
- if (IN_LEV_FIELD(x,y) && Feld[x][y]==old_element)
- FloodFill(x,y,fill_element);
+ if (IN_LEV_FIELD(x,y) && Feld[x][y] == old_element)
+ FloodFill(x, y, fill_element);
}
safety--;
return;
}
- HandleNetworking();
+ if (network)
+ HandleNetworking();
switch(game_status)
{
/* initial null action */
- SendToServer_MovePlayer(MV_NO_MOVING);
+ if (network)
+ SendToServer_MovePlayer(MV_NO_MOVING);
/* main game synchronization point */
WaitUntilDelayReached(&action_delay, action_delay_value);
- if (!standalone && !network_player_action_received)
+ if (network && !network_player_action_received)
{
/*
#ifdef DEBUG
else
recorded_player_action = NULL;
- if (!standalone)
+ if (network)
SendToServer_MovePlayer(player_action);
for(i=0; i<MAX_PLAYERS; i++)
{
int actual_player_action =
- (standalone ? player_action : network_player_action[i]);
+ (network ? network_player_action[i] : player_action);
/*
int actual_player_action = network_player_action[i];
actual_player_action = 0;
*/
- if (standalone && i != TestPlayer)
+ if (!network && i != TestPlayer)
actual_player_action = 0;
/* TEST TEST TEST */
if (!IN_LEV_FIELD(new_jx,new_jy))
return(MF_NO_ACTION);
- if (standalone && !AllPlayersInSight(player, new_jx,new_jy))
+ if (!network && !AllPlayersInSight(player, new_jx,new_jy))
return(MF_NO_ACTION);
element = MovingOrBlocked2Element(new_jx,new_jy);
*/
if (moved & MF_MOVING && !ScreenMovPos &&
- (player == local_player || standalone))
+ (player == local_player || !network))
{
int old_scroll_x = scroll_x, old_scroll_y = scroll_y;
int offset = (scroll_delay_on ? 3 : 0);
if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
{
- if (standalone && !AllPlayersInVisibleScreen())
+ if (!network && !AllPlayersInVisibleScreen())
{
scroll_x = old_scroll_x;
scroll_y = old_scroll_y;
{
int nr_wanted;
- if (standalone)
+ if (!network)
return;
nr_wanted = Request("Choose player", REQ_PLAYER | REQ_STAY_CLOSED);
char *server_host = NULL;
int server_port = 0;
int serveronly = FALSE;
-int standalone = TRUE;
+int network = FALSE;
int verbose = FALSE;
int game_status = MAINMENU;
extern char *server_host;
extern int server_port;
extern int serveronly;
-extern int standalone;
+extern int network;
extern int verbose;
extern int game_status;
{
printf("--network\n");
- standalone = FALSE;
+ network = TRUE;
}
else if (strncmp(option, "-serveronly", option_len) == 0)
{
static void sendbuf(int len)
{
- if (!standalone)
+ if (network)
{
realbuf[0] = realbuf[1] = realbuf[2] = 0;
realbuf[3] = (unsigned char)len;
case -1:
Error(ERR_RETURN,
"cannot create network server process - no network games");
- standalone = TRUE;
+ network = FALSE;
return;
default:
fd_set rfds;
int r = 0;
- if (standalone)
- return;
-
flushbuf();
FD_ZERO(&rfds);
if (autorecord_on)
TapeStartRecording();
- if (standalone)
+ if (network)
+ SendToServer_StartPlaying();
+ else
{
game_status = PLAYING;
InitGame();
}
- else
- SendToServer_StartPlaying();
}
else if (y==9)
{
}
DrawCompleteVideoDisplay();
break;
+
case BUTTON_VIDEO_STOP:
TapeStop();
break;
+
case BUTTON_VIDEO_PAUSE:
TapeTogglePause();
break;
+
case BUTTON_VIDEO_REC:
if (TAPE_IS_STOPPED(tape))
{
TapeStartRecording();
- if (standalone)
+ if (network)
+ SendToServer_StartPlaying();
+ else
{
game_status = PLAYING;
InitGame();
}
- else
- SendToServer_StartPlaying();
}
else if (tape.pausing)
{
TapeTogglePause();
}
break;
+
case BUTTON_VIDEO_PLAY:
if (TAPE_IS_EMPTY(tape))
break;
{
TapeStartPlaying();
- if (standalone)
- {
- game_status = PLAYING;
- InitGame();
- }
- else
- SendToServer_StartPlaying();
+ game_status = PLAYING;
+ InitGame();
}
else if (tape.playing)
{
}
}
break;
+
default:
break;
}
else
DrawSoundDisplay(BUTTON_SOUND_MUSIC_OFF);
break;
+
case BUTTON_SOUND_LOOPS:
if (sound_loops_on)
{
else
DrawSoundDisplay(BUTTON_SOUND_LOOPS_OFF);
break;
+
case BUTTON_SOUND_SIMPLE:
if (sound_simple_on)
{
else
DrawSoundDisplay(BUTTON_SOUND_SIMPLE_OFF);
break;
+
default:
break;
}
if (Request("Do you really want to quit the game ?",
REQ_ASK | REQ_STAY_CLOSED))
{
- if (standalone)
+ if (network)
+ SendToServer_StopPlaying();
+ else
{
game_status = MAINMENU;
DrawMainMenu();
}
- else
- SendToServer_StopPlaying();
}
else
OpenDoor(DOOR_OPEN_1 | DOOR_COPY_BACK);
break;
+
case BUTTON_GAME_PAUSE:
+ if (network)
+ {
+ if (tape.pausing)
+ SendToServer_ContinuePlaying();
+ else
+ SendToServer_PausePlaying();
+ }
+ else
+ TapeTogglePause();
+
+ /*
if (tape.pausing)
{
- if (standalone)
+ if (network)
+ SendToServer_ContinuePlaying();
+ else
{
tape.pausing = FALSE;
DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
}
- else
- SendToServer_ContinuePlaying();
}
else
{
- if (standalone)
+ if (network)
+ SendToServer_PausePlaying();
+ else
{
tape.pausing = TRUE;
DrawVideoDisplay(VIDEO_STATE_PAUSE_ON,0);
}
- else
- SendToServer_PausePlaying();
}
+ */
+
break;
+
case BUTTON_GAME_PLAY:
if (tape.pausing)
{
- if (standalone)
+ if (network)
+ SendToServer_ContinuePlaying();
+ else
{
tape.pausing = FALSE;
DrawVideoDisplay(VIDEO_STATE_PAUSE_OFF,0);
}
- else
- SendToServer_ContinuePlaying();
}
break;
+
default:
break;
}
for(i=0;i<tape.length;i++)
tape_length += tape.pos[i].delay;
- return(tape_length * GAME_FRAME_DELAY / 100);
+ return(tape_length * GAME_FRAME_DELAY / 1000);
}
unsigned int old_door_state;
/* pause network game while waiting for request to answer */
- if (!standalone && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
+ if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
SendToServer_PausePlaying();
old_door_state = GetDoorState();
}
/* continue network game after request */
- if (!standalone && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
+ if (network && game_status == PLAYING && req_state & REQUEST_WAIT_FOR)
SendToServer_ContinuePlaying();
return(result);