Previous to this patch remote characters don't drop dynamites and grenades. This bug occurred from time to time previous to the last patch and occurred constantly since the last patch.
Additionally this patch makes the code simpler and reduce the network traffic. --- lib/wormux/include/WORMUX_action.h | 1 - src/game/game.cpp | 34 +++++++++++----------------------- src/game/game.h | 7 +++---- src/include/action_handler.cpp | 7 ------- 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/lib/wormux/include/WORMUX_action.h b/lib/wormux/include/WORMUX_action.h index 1675417..dd4471e 100644 --- a/lib/wormux/include/WORMUX_action.h +++ b/lib/wormux/include/WORMUX_action.h @@ -48,7 +48,6 @@ public: ACTION_PLAYER_CHANGE_WEAPON, ACTION_PLAYER_CHANGE_CHARACTER, ACTION_GAMELOOP_NEXT_TEAM, - ACTION_GAMELOOP_SET_STATE, // ######################################################## // To be sure that rules will be the same on each computer diff --git a/src/game/game.cpp b/src/game/game.cpp index 1151dee..c22f74e 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -609,11 +609,17 @@ void Game::AddNewBox(ObjBox * box) SetCurrentBox(box); } - -void Game::Really_SetState(game_loop_state_t new_state) +void Game::SetState(game_loop_state_t new_state, bool begin_game) { + if (begin_game && + (Network::GetInstance()->IsGameMaster() || Network::GetInstance()->IsLocal())) + Network::GetInstance()->SetTurnMaster(true); + // already in good state, nothing to do - if (state == new_state) return; + if ((state == new_state) && !begin_game) return; + + MSG_DEBUG("game", "Ask for state %d", new_state); + state = new_state; Interface::GetInstance()->weapons_menu.Hide(); @@ -636,25 +642,7 @@ void Game::Really_SetState(game_loop_state_t new_state) m_current_turn++; break; } -} -void Game::SetState(game_loop_state_t new_state, bool begin_game) const -{ - if (begin_game && - (Network::GetInstance()->IsGameMaster() || Network::GetInstance()->IsLocal())) - Network::GetInstance()->SetTurnMaster(true); - - if (!Network::GetInstance()->IsTurnMaster()) - return; - - // already in good state, nothing to do - if ((state == new_state) && !begin_game) return; - - MSG_DEBUG("game", "Ask for state %d", new_state); - - Action *a = new Action(Action::ACTION_GAMELOOP_SET_STATE); - a->Push(new_state); - ActionHandler::GetInstance()->NewAction(a); } PhysicalObj* Game::GetMovingObject() const @@ -707,7 +695,7 @@ bool Game::IsAnythingMoving() const } // Signal death of a character -void Game::SignalCharacterDeath (const Character *character) const +void Game::SignalCharacterDeath (const Character *character) { std::string txt; @@ -784,7 +772,7 @@ void Game::SignalCharacterDeath (const Character *character) const } // Signal falling or any kind of damage of a character -void Game::SignalCharacterDamage(const Character *character) const +void Game::SignalCharacterDamage(const Character *character) { MSG_DEBUG("game.endofturn", "%s has been hurt", character->GetName().c_str()); diff --git a/src/game/game.h b/src/game/game.h index e83d9c9..3c0ccba 100644 --- a/src/game/game.h +++ b/src/game/game.h @@ -140,16 +140,15 @@ public: // Read/Set State game_loop_state_t ReadState() const { return state; } - void SetState(game_loop_state_t new_state, bool begin_game=false) const; + void SetState(game_loop_state_t new_state, bool begin_game=false); void UserAsksForMenu() { ask_for_menu = true; }; - void Really_SetState(game_loop_state_t new_state); // called by the action_handler // Signal death of a player - void SignalCharacterDeath (const Character *character) const; + void SignalCharacterDeath (const Character *character); // Signal character damage - void SignalCharacterDamage(const Character *character) const; + void SignalCharacterDamage(const Character *character); // Bonus box handling bool NewBox(); diff --git a/src/include/action_handler.cpp b/src/include/action_handler.cpp index 2653c42..7241d9e 100644 --- a/src/include/action_handler.cpp +++ b/src/include/action_handler.cpp @@ -332,12 +332,6 @@ static void Action_DropBonusBox (Action */*a*/) } } -static void Action_Game_SetState (Action *a) -{ - Game::game_loop_state_t state = Game::game_loop_state_t(a->PopInt()); - Game::GetInstance()->Really_SetState(state); -} - // ######################################################## static void Action_Rules_SetGameMode (Action *a) @@ -928,7 +922,6 @@ void Action_Handler_Init() ActionHandler::GetInstance()->Register (Action::ACTION_PLAYER_CHANGE_WEAPON, "PLAYER_change_weapon", &Action_Player_ChangeWeapon); ActionHandler::GetInstance()->Register (Action::ACTION_PLAYER_CHANGE_CHARACTER, "PLAYER_change_character", &Action_Player_ChangeCharacter); ActionHandler::GetInstance()->Register (Action::ACTION_GAMELOOP_NEXT_TEAM, "GAMELOOP_change_team", &Action_Game_NextTeam); - ActionHandler::GetInstance()->Register (Action::ACTION_GAMELOOP_SET_STATE, "GAMELOOP_set_state", &Action_Game_SetState); // ######################################################## // To be sure that rules will be the same on each computer -- 1.6.0.4 _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev