From: Holger Schemel Date: Sat, 26 Apr 2008 00:22:23 +0000 (+0200) Subject: rnd-20080426-1-src X-Git-Tag: 3.2.6.0^2~12 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=ae0e3de423fa4a5a60969bed8adf11e5d147b4dc;p=rocksndiamonds.git rnd-20080426-1-src --- diff --git a/src/conftime.h b/src/conftime.h index 163f51b6..544efe05 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2008-02-06 23:42" +#define COMPILE_DATE_STRING "2008-04-26 02:20" diff --git a/src/events.c b/src/events.c index 811d8f9a..6d52228b 100644 --- a/src/events.c +++ b/src/events.c @@ -223,6 +223,10 @@ void HandleOtherEvents(Event *event) case SDL_JOYBUTTONUP: HandleJoystickEvent(event); break; + + case SDL_SYSWMEVENT: + HandleWindowManagerEvent(event); + break; #endif default: @@ -413,6 +417,13 @@ void HandleClientMessageEvent(ClientMessageEvent *event) CloseAllAndExit(0); } +void HandleWindowManagerEvent(Event *event) +{ +#if defined(TARGET_SDL) + SDLHandleWindowManagerEvent(event); +#endif +} + void HandleButton(int mx, int my, int button, int button_nr) { static int old_mx = 0, old_my = 0; diff --git a/src/events.h b/src/events.h index 16b15ebd..7cde0e00 100644 --- a/src/events.h +++ b/src/events.h @@ -28,7 +28,8 @@ void HandleButtonEvent(ButtonEvent *); void HandleMotionEvent(MotionEvent *); void HandleKeyEvent(KeyEvent *); void HandleFocusEvent(FocusChangeEvent *); -void HandleClientMessageEvent(ClientMessageEvent *event); +void HandleClientMessageEvent(ClientMessageEvent *); +void HandleWindowManagerEvent(Event *); void HandleNoEvent(void); diff --git a/src/game.c b/src/game.c index f99a7627..653cd8c2 100644 --- a/src/game.c +++ b/src/game.c @@ -65,6 +65,8 @@ #define USE_GFX_RESET_WHEN_NOT_MOVING (USE_NEW_STUFF * 1) +#define USE_NEW_PLAYER_ASSIGNMENTS (USE_NEW_STUFF * 1) + #define USE_DELAYED_GFX_REDRAW (USE_NEW_STUFF * 0) #if USE_DELAYED_GFX_REDRAW @@ -4038,6 +4040,52 @@ void InitGame() if (game.belt_dir[i] == MV_NONE) game.belt_dir_nr[i] = 3; /* not moving, next moving left */ +#if USE_NEW_PLAYER_ASSIGNMENTS + /* check if any connected player was not found in playfield */ + for (i = 0; i < MAX_PLAYERS; i++) + { + struct PlayerInfo *player = &stored_player[i]; + + if (player->connected && !player->present) + { + for (j = 0; j < MAX_PLAYERS; j++) + { + struct PlayerInfo *some_player = &stored_player[j]; + int jx = some_player->jx, jy = some_player->jy; + + /* assign first free player found that is present in the playfield */ + if (some_player->present && !some_player->connected) + { + player->present = FALSE; + player->active = FALSE; + + some_player->present = TRUE; + some_player->active = TRUE; + + /* + player->initial_element = some_player->initial_element; + player->artwork_element = some_player->artwork_element; + + player->block_last_field = some_player->block_last_field; + player->block_delay_adjustment = some_player->block_delay_adjustment; + */ + + StorePlayer[jx][jy] = some_player->element_nr; + + some_player->jx = some_player->last_jx = jx; + some_player->jy = some_player->last_jy = jy; + + if (local_player == player) + local_player = some_player; + + break; + } + } + } + } + +#else + /* check if any connected player was not found in playfield */ for (i = 0; i < MAX_PLAYERS; i++) { @@ -4066,6 +4114,7 @@ void InitGame() player->block_delay_adjustment = some_player->block_delay_adjustment; StorePlayer[jx][jy] = player->element_nr; + player->jx = player->last_jx = jx; player->jy = player->last_jy = jy; @@ -4074,6 +4123,7 @@ void InitGame() } } } +#endif if (tape.playing) { diff --git a/src/libgame/sdl.c b/src/libgame/sdl.c index ab3ac82d..f751fe85 100644 --- a/src/libgame/sdl.c +++ b/src/libgame/sdl.c @@ -296,6 +296,26 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen) } } + +#if 1 + SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); + +#if defined(PLATFORM_WIN32) + { + SDL_SysWMinfo wminfo; + HWND hwnd; + + SDL_VERSION(&wminfo.version); + SDL_GetWMInfo(&wminfo); + + hwnd = wminfo.window; + + DragAcceptFiles(hwnd, TRUE); + } +#endif +#endif + + return success; } @@ -1787,6 +1807,36 @@ void SDLNextEvent(Event *event) } } +void SDLHandleWindowManagerEvent(Event *event) +{ +#if defined(PLATFORM_WIN32) + SDL_SysWMEvent *syswmevent = (SDL_SysWMEvent *)event; + SDL_SysWMmsg *syswmmsg = (SDL_SysWMmsg *)(syswmevent->msg); + + if (syswmmsg->msg == WM_DROPFILES) + { + HDROP hdrop = (HDROP)syswmmsg->wParam; + int i, num_files; + + printf("::: SDL_SYSWMEVENT:\n"); + + num_files = DragQueryFile(hdrop, 0xffffffff, NULL, 0); + + for (i = 0; i < num_files; i++) + { + int buffer_len = DragQueryFile(hdrop, i, NULL, 0); + char buffer[buffer_len + 1]; + + DragQueryFile(hdrop, i, buffer, buffer_len + 1); + + printf("::: - '%s'\n", buffer); + } + + DragFinish((HDROP)syswmmsg->wParam); + } +#endif +} + /* ========================================================================= */ /* joystick functions */ diff --git a/src/libgame/sdl.h b/src/libgame/sdl.h index 19ead5e5..62196e1a 100644 --- a/src/libgame/sdl.h +++ b/src/libgame/sdl.h @@ -19,7 +19,9 @@ #include #include #include - +#if defined(PLATFORM_WIN32) +#include +#endif /* definitions needed for "system.c" */ @@ -375,6 +377,7 @@ void SDLOpenAudio(void); void SDLCloseAudio(void); void SDLNextEvent(Event *); +void SDLHandleWindowManagerEvent(Event *); void HandleJoystickEvent(Event *); void SDLInitJoysticks(void);