void HandleKey(KeySym key, int key_status)
{
int joy = 0;
+ static struct SetupKeyboardInfo custom_key;
+ static struct
+ {
+ KeySym *keysym_custom;
+ KeySym keysym_default;
+ byte action;
+ } key_info[] =
+ {
+ { &custom_key.left, DEFAULT_KEY_LEFT, JOY_LEFT },
+ { &custom_key.right, DEFAULT_KEY_RIGHT, JOY_RIGHT },
+ { &custom_key.up, DEFAULT_KEY_UP, JOY_UP },
+ { &custom_key.down, DEFAULT_KEY_DOWN, JOY_DOWN },
+ { &custom_key.snap, DEFAULT_KEY_SNAP, JOY_BUTTON_1 },
+ { &custom_key.bomb, DEFAULT_KEY_BOMB, JOY_BUTTON_2 }
+ };
+
+ if (game_status == PLAYING)
+ {
+ int pnr;
+
+ for (pnr=0; pnr<MAX_PLAYERS; pnr++)
+ {
+ int i;
+ byte key_action = 0;
+
+ if (setup.input[pnr].use_joystick)
+ continue;
+
+ custom_key = setup.input[pnr].key;
+
+ for (i=0; i<6; i++)
+ if (key == *key_info[i].keysym_custom)
+ key_action |= key_info[i].action;
+
+ if (key_status == KEY_PRESSED)
+ {
+ if (network_playing)
+ local_player->action |= key_action;
+ else
+ stored_player[pnr].action |= key_action;
+ }
+ else
+ {
+ if (network_playing)
+ local_player->action &= ~key_action;
+ else
+ stored_player[pnr].action &= ~key_action;
+ }
+ }
+ }
+ else
+ {
+ int i;
+
+ for (i=0; i<6; i++)
+ if (key == key_info[i].keysym_default)
+ joy |= key_info[i].action;
+ }
+
+
+#if 0
+
/* Map cursor keys to joystick directions */
break;
}
+
+#endif
+
+
if (joy)
{
if (key_status == KEY_PRESSED)
GAME_FRAME_DELAY * 100 / GameFrameDelay, GameFrameDelay);
break;
+
+#if 0
case XK_a:
if (ScrollStepSize == TILEX/8)
ScrollStepSize = TILEX/4;
ScrollStepSize = TILEX/8;
printf("ScrollStepSize == %d\n", ScrollStepSize);
break;
+#endif
case XK_f:
ScrollStepSize = TILEX/8;
break;
+
+#if 0
case XK_y:
/*
{
printf("direct_draw_on == %d\n", setup.direct_draw_on);
break;
+#endif
+
case XK_z:
{
return;
}
+ /*
if (tape.pausing || AllPlayersGone)
- joy = 0;
+ {
+ int i;
+
+ for (i=0; i<MAX_PLAYERS; i++)
+ stored_player[i].action = 0;
+ }
+ */
- HandleGameActions((byte)joy);
+ HandleGameActions();
break;
default:
void GetPlayerConfig()
{
- int old_joystick_nr = setup.joy_input[0].joystick_nr;
+ int old_joystick_nr = setup.input[0].joystick_nr;
if (sound_status==SOUND_OFF)
local_player->setup &= ~SETUP_SOUND;
setup.joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
#endif
- setup.joy_input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
+ setup.input[0].joystick_nr = SETUP_2ND_JOYSTICK_ON(local_player->setup);
setup.quick_doors = SETUP_QUICK_DOORS_ON(local_player->setup);
setup.scroll_delay_on = SETUP_SCROLL_DELAY_ON(local_player->setup);
setup.soft_scrolling_on = SETUP_SOFT_SCROLL_ON(local_player->setup);
#ifndef MSDOS
- if (setup.joy_input[0].joystick_nr != old_joystick_nr)
+ if (setup.input[0].joystick_nr != old_joystick_nr)
{
if (joystick_device)
close(joystick_device);
player->present = FALSE;
player->active = FALSE;
+ player->action = 0;
+
/*
player->local = FALSE;
*/
*/
player->present = TRUE;
- if (player->connected)
+ if (!network_playing || player->connected)
{
player->active = TRUE;
stored_player_action[player->index_nr] = 0;
num_stored_actions++;
- if (!player->active || player->gone)
+ if (!player->active || player->gone || tape.pausing)
return;
if (player_action)
}
}
-void GameActions(byte player_action)
+void GameActions()
{
static long action_delay = 0;
long action_delay_value;
recorded_player_action = (tape.playing ? TapePlayAction() : NULL);
if (network_playing)
- SendToServer_MovePlayer(player_action);
+ SendToServer_MovePlayer(local_player->action);
for(i=0; i<MAX_PLAYERS; i++)
{
- int actual_player_action =
- (network_playing ? network_player_action[i] : player_action);
-
+ int actual_player_action = stored_player[i].action;
/* TEST TEST TEST */
actual_player_action = 0;
*/
+ /*
if (!options.network && i != TestPlayer)
actual_player_action = 0;
+ */
/* TEST TEST TEST */
PlayerActions(&stored_player[i], actual_player_action);
ScrollFigure(&stored_player[i], SCROLL_GO_ON);
- network_player_action[i] = 0;
+ /*
+ stored_player[i].action = 0;
+ */
+
}
network_player_action_received = FALSE;
if (!IN_VIS_FIELD(SCREENX(jx),SCREENY(jy)))
{
+
+
+ printf("prevent player %d from leaving visible screen\n",
+ player->index_nr);
+
+
+
/* actual player has left the screen -- scroll in that direction */
if (jx != old_jx) /* player has moved horizontally */
scroll_x += (jx - old_jx);
{
if (jx != old_jx) /* player has moved horizontally */
{
+ /*
if ((scroll_x < jx-MIDPOSX-offset || scroll_x > jx-MIDPOSX+offset) &&
jx >= MIDPOSX-1-offset && jx <= lev_fieldx-(MIDPOSX-offset))
- scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : offset);
+ scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+ */
+
+ if ((player->MovDir == MV_LEFT && scroll_x > jx-MIDPOSX+offset) ||
+ (player->MovDir == MV_RIGHT && scroll_x < jx-MIDPOSX-offset))
+ scroll_x = jx-MIDPOSX + (scroll_x < jx-MIDPOSX ? -offset : +offset);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_x < -1 || scroll_x > lev_fieldx - SCR_FIELDX + 2)
+ scroll_x = (scroll_x < -1 ? -1 : lev_fieldx - SCR_FIELDX + 2);
/* don't scroll more than one field at a time */
scroll_x = old_scroll_x + SIGN(scroll_x - old_scroll_x);
}
else /* player has moved vertically */
{
+ /*
if ((scroll_y < jy-MIDPOSY-offset || scroll_y > jy-MIDPOSY+offset) &&
jy >= MIDPOSY-1-offset && jy <= lev_fieldy-(MIDPOSY-offset))
- scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : offset);
+ scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+ */
+
+ if ((player->MovDir == MV_UP && scroll_y > jy-MIDPOSY+offset) ||
+ (player->MovDir == MV_DOWN && scroll_y < jy-MIDPOSY-offset))
+ scroll_y = jy-MIDPOSY + (scroll_y < jy-MIDPOSY ? -offset : +offset);
+
+ /* don't scroll over playfield boundaries */
+ if (scroll_y < -1 || scroll_y > lev_fieldy - SCR_FIELDY + 2)
+ scroll_y = (scroll_y < -1 ? -1 : lev_fieldy - SCR_FIELDY + 2);
/* don't scroll more than one field at a time */
scroll_y = old_scroll_y + SIGN(scroll_y - old_scroll_y);
{
if (!options.network && !AllPlayersInVisibleScreen())
{
+
+
+ printf("oops! not all players visible if we scroll now\n");
+
+
+
scroll_x = old_scroll_x;
scroll_y = old_scroll_y;
}
else
{
+
+
+ printf("ok, scrolling screen...\n");
+
+
+
ScrollScreen(player, SCROLL_INIT);
ScrollLevel(old_scroll_x - scroll_x, old_scroll_y - scroll_y);
}
void EdelsteinFunkeln(int, int);
void MauerWaechst(int, int);
void MauerAbleger(int, int);
-void GameActions(byte);
+void GameActions(void);
void ScrollLevel(int, int);
boolean MoveFigureOneStep(struct PlayerInfo *, int, int, int, int);
setup.quick_doors = FALSE;
for (i=0; i<MAX_PLAYERS; i++)
{
- setup.joy_input[i].use_joystick = FALSE;
- setup.joy_input[i].joystick_nr = i;
- setup.joy_input[i].button_snap = JOY_BUTTON_1;
- setup.joy_input[i].button_bomb = JOY_BUTTON_2;
- setup.key_input[i].left = DEFAULT_KEY_LEFT;
- setup.key_input[i].right = DEFAULT_KEY_RIGHT;
- setup.key_input[i].up = DEFAULT_KEY_UP;
- setup.key_input[i].down = DEFAULT_KEY_DOWN;
- setup.key_input[i].snap = DEFAULT_KEY_SNAP;
- setup.key_input[i].bomb = DEFAULT_KEY_BOMB;
+ setup.input[i].use_joystick = FALSE;
+ setup.input[i].joystick_nr = 0;
+ setup.input[i].joy.snap = (i == 0 ? JOY_BUTTON_1 : 0);
+ setup.input[i].joy.bomb = (i == 0 ? JOY_BUTTON_2 : 0);
+ setup.input[i].key.left = (i == 0 ? DEFAULT_KEY_LEFT : KEY_UNDEFINDED);
+ setup.input[i].key.right = (i == 0 ? DEFAULT_KEY_RIGHT : KEY_UNDEFINDED);
+ setup.input[i].key.up = (i == 0 ? DEFAULT_KEY_UP : KEY_UNDEFINDED);
+ setup.input[i].key.down = (i == 0 ? DEFAULT_KEY_DOWN : KEY_UNDEFINDED);
+ setup.input[i].key.snap = (i == 0 ? DEFAULT_KEY_SNAP : KEY_UNDEFINDED);
+ setup.input[i].key.bomb = (i == 0 ? DEFAULT_KEY_BOMB : KEY_UNDEFINDED);
}
/* choose default local player */
void InitJoystick()
{
- int joystick_nr = setup.joy_input[0].joystick_nr;
+ int joystick_nr = setup.input[0].joystick_nr;
if (global_joystick_status == JOYSTICK_OFF)
return;
} joy_ctrl;
#endif
- int joystick_nr = setup.joy_input[0].joystick_nr;
+ int joystick_nr = setup.input[0].joystick_nr;
int js_x,js_y, js_b1,js_b2;
int left, right, up, down;
int result=0;
int FrameCounter, TimeFrames, TimeLeft;
int MampferNr, SiebAktiv;
-byte network_player_action[MAX_PLAYERS];
boolean network_player_action_received = FALSE;
int TestPlayer = 0;
struct SetupJoystickInfo
{
- boolean use_joystick;
- int joystick_nr;
- int button_snap;
- int button_bomb;
+ int snap;
+ int bomb;
};
struct SetupInfo
boolean fading_on;
boolean autorecord_on;
boolean quick_doors;
- struct SetupKeyboardInfo key_input[MAX_PLAYERS];
- struct SetupJoystickInfo joy_input[MAX_PLAYERS];
+ struct
+ {
+ boolean use_joystick;
+ int joystick_nr;
+ struct SetupJoystickInfo joy;
+ struct SetupKeyboardInfo key;
+ } input[MAX_PLAYERS];
};
struct PlayerInfo
int index_nr, client_nr, element_nr;
+ byte action;
+
char login_name[MAX_NAMELEN];
char alias_name[MAX_NAMELEN];
int handicap;
extern int FrameCounter, TimeFrames, TimeLeft;
extern int MampferNr, SiebAktiv;
-extern byte network_player_action[];
extern boolean network_player_action_received;
extern int TestPlayer;
(s)==SND_TWILIGHT)
/* default input keys */
+#define KEY_UNDEFINDED 0
#define DEFAULT_KEY_LEFT XK_Left
#define DEFAULT_KEY_RIGHT XK_Right
#define DEFAULT_KEY_UP XK_Up
#define DEFAULT_KEY_DOWN XK_Down
#define DEFAULT_KEY_SNAP XK_Shift_L
#define DEFAULT_KEY_BOMB XK_Shift_R
+#define DEFAULT_KEY_OKAY XK_Return
+#define DEFAULT_KEY_CANCEL XK_Escape
/* directions for moving */
#define MV_NO_MOVING 0
/* copy valid player actions */
for (i=0; i<MAX_PLAYERS; i++)
- network_player_action[i] =
+ stored_player[i].action =
(i < len - 6 && stored_player[i].active ? buf[6 + i] : 0);
network_player_action_received = TRUE;
{
int i;
static struct SetupKeyboardInfo custom_key;
- static KeySym *key[] =
+ static struct
{
- &custom_key.left,
- &custom_key.right,
- &custom_key.up,
- &custom_key.down,
- &custom_key.snap,
- &custom_key.bomb
- };
- static char *joy_text[] =
+ KeySym *keysym;
+ char *text;
+ } custom[] =
{
- "Joystick Left",
- "Joystick Right",
- "Joystick Up",
- "Joystick Down",
- "Button 1",
- "Button 2",
+ { &custom_key.left, "Joystick Left" },
+ { &custom_key.right, "Joystick Right" },
+ { &custom_key.up, "Joystick Up" },
+ { &custom_key.down, "Joystick Down" },
+ { &custom_key.snap, "Button 1" },
+ { &custom_key.bomb, "Button 2" }
};
- custom_key = setup.key_input[player_nr];
+ custom_key = setup.input[player_nr].key;
DrawText(SX+11*32, SY+2*32, int2str(player_nr + 1, 1), FS_BIG, FC_RED);
DrawGraphic(8, 2, GFX_SPIELER1 + player_nr);
- if (setup.joy_input[player_nr].use_joystick)
+ if (setup.input[player_nr].use_joystick)
{
DrawText(SX+8*32, SY+3*32,
- (setup.joy_input[player_nr].joystick_nr == 0 ?
+ (setup.input[player_nr].joystick_nr == 0 ?
"Joystick1" : "Joystick2"),
FS_BIG, FC_YELLOW);
DrawText(SX+32, SY+4*32, "Calibrate", FS_BIG, FC_GREEN);
DrawText(SX + 3*32, SY + ypos*32,
" ", FS_BIG, FC_YELLOW);
DrawText(SX + 3*32, SY + ypos*32,
- (setup.joy_input[player_nr].use_joystick ?
- joy_text[i] :
- getKeySymName(*key[i])),
+ (setup.input[player_nr].use_joystick ?
+ custom[i].text :
+ getKeySymName(*custom[i].keysym)),
FS_BIG, FC_YELLOW);
}
}
int one_joystick_nr = (dx >= 0 ? 0 : 1);
int the_other_joystick_nr = (dx >= 0 ? 1 : 0);
- if (setup.joy_input[player_nr].use_joystick)
+ if (setup.input[player_nr].use_joystick)
{
- if (setup.joy_input[player_nr].joystick_nr == one_joystick_nr)
- setup.joy_input[player_nr].joystick_nr = the_other_joystick_nr;
+ if (setup.input[player_nr].joystick_nr == one_joystick_nr)
+ setup.input[player_nr].joystick_nr = the_other_joystick_nr;
else
- setup.joy_input[player_nr].use_joystick = FALSE;
+ setup.input[player_nr].use_joystick = FALSE;
}
else
{
- setup.joy_input[player_nr].use_joystick = TRUE;
- setup.joy_input[player_nr].joystick_nr = one_joystick_nr;
+ setup.input[player_nr].use_joystick = TRUE;
+ setup.input[player_nr].joystick_nr = one_joystick_nr;
}
drawPlayerSetupInputInfo(player_nr);
}
else if (y == 5)
{
- if (setup.joy_input[player_nr].use_joystick)
- CalibrateJoystick(setup.joy_input[player_nr].joystick_nr);
+ if (setup.input[player_nr].use_joystick)
+ CalibrateJoystick(setup.input[player_nr].joystick_nr);
else
CustomizeKeyboard(player_nr);
};
/* read existing key bindings from player setup */
- custom_key = setup.key_input[player_nr];
+ custom_key = setup.input[player_nr].key;
ClearWindow();
DrawText(SX + 16, SY + 16, "Keyboard Input", FS_BIG, FC_YELLOW);
}
/* write new key bindings back to player setup */
- setup.key_input[player_nr] = custom_key;
+ setup.input[player_nr].key = custom_key;
StopAnimation();
DrawSetupInputScreen();
char joy_nr[4];
#endif
- int joystick_nr = setup.joy_input[0].joystick_nr;
+ int joystick_nr = setup.input[0].joystick_nr;
int new_joystick_xleft, new_joystick_xright, new_joystick_xmiddle;
int new_joystick_yupper, new_joystick_ylower, new_joystick_ymiddle;
DrawSetupScreen();
}
-void HandleGameActions(byte player_action)
+void HandleGameActions()
{
if (game_status != PLAYING)
return;
if (AllPlayersGone && !TAPE_IS_STOPPED(tape))
TapeStop();
- GameActions(player_action);
+ GameActions();
BackToFront();
}
void HandleSetupInputScreen(int, int, int, int, int);
void CustomizeKeyboard(int);
void CalibrateJoystick(int);
-void HandleGameActions(byte);
+void HandleGameActions(void);
void HandleVideoButtons(int, int, int);
void HandleSoundButtons(int, int, int);
void HandleGameButtons(int, int, int);