--- lib/wormux/include/WORMUX_action.h | 7 -- src/ai/ai_movement_module.cpp | 2 +- src/character/character.cpp | 169 +------------------------------ src/character/character.h | 10 -- src/game/game.cpp | 31 +----- src/include/action_handler.cpp | 156 +--------------------------- src/include/action_handler.h | 8 -- src/interface/man_machine_interface.cpp | 9 +- src/interface/mouse.cpp | 7 +- src/map/wind.cpp | 5 +- src/map/wind.h | 2 +- src/network/network.cpp | 3 +- src/network/network.h | 1 - src/object/bonus_box.cpp | 12 -- src/object/bonus_box.h | 2 - src/object/medkit.cpp | 12 -- src/object/medkit.h | 2 - src/object/objbox.cpp | 16 --- src/object/objbox.h | 2 - src/object/physical_obj.cpp | 49 --------- src/object/physical_obj.h | 4 - src/object/physics.cpp | 53 ---------- src/object/physics.h | 4 - src/team/teams_list.cpp | 1 - src/weapon/explosion.cpp | 94 +---------------- src/weapon/explosion.h | 11 +-- src/weapon/grapple.cpp | 3 +- src/weapon/jetpack.cpp | 1 - src/weapon/parachute.cpp | 3 +- src/weapon/suicide.cpp | 1 - src/weapon/weapon.cpp | 4 +- src/weapon/weapon_launcher.cpp | 4 +- 32 files changed, 38 insertions(+), 650 deletions(-)
diff --git a/lib/wormux/include/WORMUX_action.h b/lib/wormux/include/WORMUX_action.h index 4f9dc21..32460f3 100644 --- a/lib/wormux/include/WORMUX_action.h +++ b/lib/wormux/include/WORMUX_action.h @@ -75,8 +75,6 @@ public: ACTION_CHARACTER_HIGH_JUMP, ACTION_CHARACTER_BACK_JUMP, - ACTION_CHARACTER_SET_PHYSICS, - // ######################################################## // Using Weapon ACTION_WEAPON_SHOOT, @@ -94,14 +92,9 @@ public: ACTION_WEAPON_SUPERTUX, // Bonus Box - ACTION_NEW_BONUS_BOX, ACTION_DROP_BONUS_BOX, // ######################################################## - ACTION_NETWORK_SYNC_BEGIN, - ACTION_NETWORK_SYNC_END, - ACTION_EXPLOSION, - ACTION_WIND, ACTION_NETWORK_PING, ACTION_NETWORK_RANDOM_INIT, ACTION_INFO_CLIENT_CONNECT, diff --git a/src/ai/ai_movement_module.cpp b/src/ai/ai_movement_module.cpp index c838065..c1f8859 100644 --- a/src/ai/ai_movement_module.cpp +++ b/src/ai/ai_movement_module.cpp @@ -137,7 +137,7 @@ void AIMovementModule::Jump() // GameMessages::GetInstance()->Add("try to jump!"); SetMovement(JUMPING); - ActionHandler::GetInstance()->NewActionActiveCharacter(new Action(Action::ACTION_CHARACTER_HIGH_JUMP)); + ActionHandler::GetInstance()->NewAction(new Action(Action::ACTION_CHARACTER_HIGH_JUMP)); } void AIMovementModule::EndOfJump() diff --git a/src/character/character.cpp b/src/character/character.cpp index 3061eb6..f6ffdb8 100644 --- a/src/character/character.cpp +++ b/src/character/character.cpp @@ -687,11 +687,6 @@ void Character::MoveRight(bool slowly) } ASSERT(&ActiveCharacter() == this); - - //Refresh skin position across network - if (!Network::GetInstance()->IsLocal() - && (ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI())) - SendActiveCharacterInfo(); } void Character::MoveLeft(bool slowly) @@ -708,11 +703,6 @@ void Character::MoveLeft(bool slowly) } ASSERT(&ActiveCharacter() == this); - - //Refresh skin position across network - if (!Network::GetInstance()->IsLocal() - && (ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI())) - SendActiveCharacterInfo(); } // Signal the end of a fall @@ -930,154 +920,6 @@ uint Character::GetCharacterIndex() const return 0; } -// ################################################################### -// ################################################################### -// ################################################################### - -void Character::StoreValue(Action *a) -{ - PhysicalObj::StoreValue(a); - a->Push((int)GetDirection()); - a->Push(GetAbsFiringAngle()); - a->Push((int)disease_damage_per_turn); - a->Push((int)disease_duration); - if (IsActiveCharacter()) { // If active character, store step animation - a->Push((int)true); - a->Push(GetBody()->GetClothe()); - a->Push(GetBody()->GetMovement()); - a->Push((int)GetBody()->GetFrame()); - } else { - a->Push((int)false); - } -} - -void Character::GetValueFromAction(Action *a) -{ - // those 2 parameters will be retrieved by PhysicalObj::GetValueFromAction - alive_t prev_live_state = m_alive; - int prev_energy = m_energy; - Point2d prev_position = Physics::GetPos(); - - PhysicalObj::GetValueFromAction(a); - SetDirection((BodyDirection_t)(a->PopInt())); - SetFiringAngle(a->PopDouble()); - - if (m_alive != prev_live_state) { - switch (m_alive) { - case ALIVE: - fprintf(stderr, "Character::GetValueFromAction: %s has been resurrected\n", - GetName().c_str()); - SetClothe("normal"); - SetMovement("breathe"); - if (prev_live_state == DROWNED) { - SignalGoingOutOfWater(); - } - break; - case DEAD: - fprintf(stderr, - "Character::GetValueFromAction: %s has died on the other side of the network\n" - " Previous energy: %d\n", - GetName().c_str(), prev_energy); - death_explosion = false; - - // to avoid violating an ASSERT in Die() - m_alive = prev_live_state; - if (m_alive != ALIVE && m_alive != DROWNED) - m_alive = ALIVE; - - Die(); - break; - case GHOST: { - fprintf(stderr, "Character::GetValueFromAction: %s is now a ghost!\n", GetName().c_str()); - m_alive = prev_live_state; - bool was_dead = IsDead(); - m_alive = GHOST; - SignalGhostState(was_dead); - break; - } - case DROWNED: - fprintf(stderr, "Character::GetValueFromAction: %s is drowning!\n", GetName().c_str()); - SignalDrowning(); - break; - } - } - - if (prev_energy != m_energy) { - fprintf(stderr, - "Character::GetValueFromAction: energy points were differents for %s:\n" - " - remote : %d\n" - " - local : %d\n", - GetName().c_str(), m_energy, prev_energy); - if (m_energy > 0) { - energy_bar.Actu(m_energy); - } - } - - uint disease_damage_per_turn = (a->PopInt()); - uint disease_duration = (a->PopInt()); - SetDiseaseDamage(disease_damage_per_turn, disease_duration); - if (a->PopInt()) { // If active characters, retrieve stored animation - if (GetTeam().IsActiveTeam()) - ActiveTeam().SelectCharacter(this); - - std::string clothe = a->PopString(); - std::string movement = a->PopString(); - uint frame = a->PopInt(); - - fprintf(stderr, - "Character::GetValueFromAction: Animation for %s\n" - " - Clothe %s (current: %s)\n" - " - Movement %s (current: %s)\n" - " - Frame %d (current: %d)\n", - GetName().c_str(), - clothe.c_str(), GetBody()->GetClothe().c_str(), - movement.c_str(), GetBody()->GetMovement().c_str(), - frame, GetBody()->GetFrame()); - - SetClothe(clothe, true); - SetMovement(movement, true); - GetBody()->SetFrame(frame); - - GetBody()->UpdateWeaponPosition(GetPosition()); - } - - // If the player has moved, the camera should follow it! - Point2d current_position = Physics::GetPos(); - if (IsActiveCharacter() && prev_position != current_position) { - Camera::GetInstance()->FollowObject(this, true); - HideGameInterface(); - } -} - -// Static method -void Character::RetrieveCharacterFromAction(Action *a) -{ - int team_no = a->PopInt(); - int char_no = a->PopInt(); - Character * c = GetTeamsList().FindPlayingByIndex(team_no)->FindByIndex(char_no); - c->GetValueFromAction(a); -} - -// Static method -void Character::StoreActiveCharacter(Action *a) -{ - Character::StoreCharacter(a, ActiveCharacter().GetTeamIndex(), ActiveCharacter().GetCharacterIndex()); -} - -// Static method -void Character::StoreCharacter(Action *a, uint team_no, uint char_no) -{ - a->Push((int)team_no); - a->Push((int)char_no); - Character * c = GetTeamsList().FindPlayingByIndex(team_no)->FindByIndex(char_no); - c->StoreValue(a); -} - -// ################################################################### -// ################################################################### -// ################################################################### - - const std::string& Character::GetName() const { return character_name; @@ -1119,8 +961,6 @@ void Character::HandleKeyReleased_MoveRight(bool /*slowly*/) StopWalk(); ActiveTeam().crosshair.Show(); - - SendActiveCharacterInfo(); } // #################### MOVE_LEFT @@ -1146,8 +986,6 @@ void Character::HandleKeyReleased_MoveLeft(bool /*slowly*/) body->StopWalk(); ActiveTeam().crosshair.Show(); - - SendActiveCharacterInfo(); } // #################### UP @@ -1179,7 +1017,6 @@ void Character::HandleKeyRefreshed_Down(bool slowly) CharacterCursor::GetInstance()->Hide(); if (slowly) AddFiringAngle(DELTA_CROSSHAIR/10.0); else AddFiringAngle(DELTA_CROSSHAIR); - SendActiveCharacterInfo(); } } @@ -1193,7 +1030,7 @@ void Character::HandleKeyPressed_Jump() if (IsImmobile()) { Action a(Action::ACTION_CHARACTER_JUMP); - SendActiveCharacterAction(a); + Network::GetInstance()->SendActionToAll(a); Jump(); } } @@ -1207,7 +1044,7 @@ void Character::HandleKeyPressed_HighJump() if (IsImmobile()) { Action a(Action::ACTION_CHARACTER_HIGH_JUMP); - SendActiveCharacterAction(a); + Network::GetInstance()->SendActionToAll(a); HighJump(); } } @@ -1221,7 +1058,7 @@ void Character::HandleKeyPressed_BackJump() if (IsImmobile()) { Action a(Action::ACTION_CHARACTER_BACK_JUMP); - SendActiveCharacterAction(a); + Network::GetInstance()->SendActionToAll(a); BackJump(); } } diff --git a/src/character/character.h b/src/character/character.h index 5c6534a..9e7a0ea 100644 --- a/src/character/character.h +++ b/src/character/character.h @@ -149,16 +149,6 @@ public: else disease_damage_per_turn = 0; } - // ================================================ - // Used to sync value across network - virtual void GetValueFromAction(Action *); - virtual void StoreValue(Action *); - - static void RetrieveCharacterFromAction(Action *); - static void StoreActiveCharacter(Action *); - static void StoreCharacter(Action *, uint team_no, uint char_no); - // ================================================ - void Draw(); void Refresh(); diff --git a/src/game/game.cpp b/src/game/game.cpp index e7ca30c..065b129 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -297,14 +297,7 @@ void Game::RefreshInput() Joystick::GetInstance()->Refresh(); AIengine::GetInstance()->Refresh(); - // Execute action - do { - ActionHandler::GetInstance()->ExecActions(); - if (Network::GetInstance()->sync_lock) SDL_Delay(SDL_TIMESLICE); - } while (Network::GetInstance()->sync_lock && - !HasBeenNetworkDisconnected()); - - Network::GetInstance()->sync_lock = false; + ActionHandler::GetInstance()->ExecActions(); GameMessages::GetInstance()->Refresh(); @@ -596,21 +589,14 @@ bool Game::NewBox() } // Randomize container box->Randomize(); - // Storing value of bonus box and send it over network. - Action * a = new Action(Action::ACTION_NEW_BONUS_BOX); - a->Push(type); if(!box->PutRandomly(true, 0, false)) { MSG_DEBUG("box", "Missed to put a box"); delete box; - } else { - /* We only randomize value. The real box will be inserted into world later - using action handling (see include/action_handler.cpp */ - box->StoreValue(a); - ActionHandler::GetInstance()->NewAction(a); - delete box; - return true; + return false; } - return false; + + Game::GetInstance()->AddNewBox(box); + return true; } void Game::AddNewBox(ObjBox * box) @@ -662,13 +648,6 @@ void Game::SetState(game_loop_state_t new_state, bool begin_game) const // already in good state, nothing to do if ((state == new_state) && !begin_game) return; - // Send information about energy and position of every characters - // ONLY at the beginning of a new turn! - // (else you can send unstable information of a character which is moving) - // See bug #10668 - if (Network::GetInstance()->IsTurnMaster() && new_state == PLAYING) - SyncCharacters(); - MSG_DEBUG("game", "Ask for state %d", new_state); Action *a = new Action(Action::ACTION_GAMELOOP_SET_STATE); diff --git a/src/include/action_handler.cpp b/src/include/action_handler.cpp index f22348d..9e8ed53 100644 --- a/src/include/action_handler.cpp +++ b/src/include/action_handler.cpp @@ -41,7 +41,6 @@ #include "map/camera.h" #include "map/map.h" #include "map/maps_list.h" -#include "map/wind.h" #include "menu/network_menu.h" #include "network/randomsync.h" #include "network/network.h" @@ -305,8 +304,9 @@ static void Action_Player_ChangeWeapon (Action *a) static void Action_Player_ChangeCharacter (Action *a) { JukeBox::GetInstance()->Play("default", "character/change_in_same_team"); - Character::RetrieveCharacterFromAction(a); // Retrieve current character's information - Character::RetrieveCharacterFromAction(a); // Retrieve next character information + int char_no = a->PopInt(); + Character * c = ActiveTeam().FindByIndex(char_no); + ActiveTeam().SelectCharacter(c); Camera::GetInstance()->FollowObject(&ActiveCharacter(), true); } @@ -314,11 +314,7 @@ static void Action_Game_NextTeam (Action *a) { std::string team = a->PopString(); GetTeamsList().SetActive(team); - - Character::RetrieveCharacterFromAction(a); // Retrieve current character's information - - ASSERT (!ActiveCharacter().IsDead()); - + ActiveTeam().NextCharacter(true); Camera::GetInstance()->FollowObject(&ActiveCharacter(), true); // Are we turn master for next turn ? @@ -328,26 +324,10 @@ static void Action_Game_NextTeam (Action *a) Network::GetInstance()->SetTurnMaster(false); } -static void Action_NewBonusBox (Action *a) -{ - ObjBox * box; - switch(a->PopInt()) { - case 2 : - box = new BonusBox(); - break; - default: /* case 1 */ - box = new Medkit(); - break; - } - box->GetValueFromAction(a); - Game::GetInstance()->AddNewBox(box); -} - -static void Action_DropBonusBox (Action *a) +static void Action_DropBonusBox (Action */*a*/) { ObjBox* current_box = Game::GetInstance()->GetCurrentBox(); if (current_box != NULL) { - current_box->GetValueFromAction(a); current_box->DropBox(); } } @@ -578,34 +558,6 @@ void WORMUX_DisconnectPlayer(Player& player) // ######################################################## -// Send information about energy and the position of every character -void SyncCharacters() -{ - ASSERT(Network::GetInstance()->IsTurnMaster()); - - Action a_begin_sync(Action::ACTION_NETWORK_SYNC_BEGIN); - Network::GetInstance()->SendActionToAll(a_begin_sync); - TeamsList::iterator - it=GetTeamsList().playing_list.begin(), - end=GetTeamsList().playing_list.end(); - - for (int team_no = 0; it != end; ++it, ++team_no) - { - Team& team = **it; - Team::iterator - tit = team.begin(), - tend = team.end(); - - for (int char_no = 0; tit != tend; ++tit, ++char_no) - { - // Sync the character's position, energy, ... - SendCharacterInfo(team_no, char_no); - } - } - Action a_sync_end(Action::ACTION_NETWORK_SYNC_END); - Network::GetInstance()->SendActionToAll(a_sync_end); -} - static void Action_Character_Jump (Action */*a*/) { Game::GetInstance()->SetCharacterChosen(true); @@ -627,46 +579,6 @@ static void Action_Character_BackJump (Action */*a*/) ActiveCharacter().BackJump(); } -static void Action_Character_SetPhysics (Action *a) -{ - while(!a->IsEmpty()) - Character::RetrieveCharacterFromAction(a); -} - -void SendActiveCharacterAction(const Action& a) -{ - ASSERT(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()); - Action a_begin_sync(Action::ACTION_NETWORK_SYNC_BEGIN); - Network::GetInstance()->SendActionToAll(a_begin_sync); - SendActiveCharacterInfo(); - Network::GetInstance()->SendActionToAll(a); - Action a_end_sync(Action::ACTION_NETWORK_SYNC_END); - Network::GetInstance()->SendActionToAll(a_end_sync); -} - -// Send character information over the network (it's totally stupid to send it locally ;-) -void SendCharacterInfo(int team_no, int char_no) -{ - Action a(Action::ACTION_CHARACTER_SET_PHYSICS); - Character::StoreCharacter(&a, team_no, char_no); - Network::GetInstance()->SendActionToAll(a); -} - -uint last_time = 0; - -// Send active character information over the network (it's totally stupid to send it locally ;-) -void SendActiveCharacterInfo(bool can_be_dropped) -{ - uint current_time = Time::GetInstance()->Read(); - - if (!can_be_dropped || last_time + 100 < Time::GetInstance()->Read()) { - last_time = current_time; - SendCharacterInfo(ActiveCharacter().GetTeamIndex(), ActiveCharacter().GetCharacterIndex()); - } -} - -// ######################################################## - static void Action_Weapon_Shoot (Action *a) { if (Game::GetInstance()->ReadState() != Game::PLAYING) @@ -797,29 +709,12 @@ static void Action_Weapon_Supertux (Action *a) // ######################################################## -static void Action_Wind (Action *a) -{ - Wind::GetRef().SetVal (a->PopInt()); -} - static void Action_Network_RandomInit (Action *a) { MSG_DEBUG("random", "Initialization from network"); RandomSync().SetRand(a->PopInt()); } -static void Action_Network_SyncBegin (Action */*a*/) -{ - ASSERT(!Network::GetInstance()->sync_lock); - Network::GetInstance()->sync_lock = true; -} - -static void Action_Network_SyncEnd (Action */*a*/) -{ - ASSERT(Network::GetInstance()->sync_lock); - Network::GetInstance()->sync_lock = false; -} - // Nothing to do here. Just for time synchronisation static void Action_Network_Ping(Action */*a*/) { @@ -989,28 +884,6 @@ void WORMUX_DisconnectHost(DistantComputer& host) Network::GetInstance()->SendActionToAll(a); // host is already removed from the list } } - -static void Action_Explosion (Action *a) -{ - ExplosiveWeaponConfig config; - MSG_DEBUG("action_handler","-> Begin"); - - Point2i pos = a->PopPoint2i(); - config.explosion_range = a->PopInt(); - config.particle_range = a->PopInt(); - config.damage = a->PopInt(); - config.blast_range = a->PopInt(); - config.blast_force = a->PopInt(); - std::string son = a->PopString(); - bool fire_particle = !!a->PopInt(); - ParticleEngine::ESmokeStyle smoke = (ParticleEngine::ESmokeStyle)a->PopInt(); - std::string unique_id = a->PopString(); - - ApplyExplosion_common(pos, config, son, fire_particle, smoke, unique_id); - - MSG_DEBUG("action_handler","<- End"); -} - // ######################################################## // ######################################################## // ######################################################## @@ -1057,9 +930,6 @@ void Action_Handler_Init() ActionHandler::GetInstance()->Register (Action::ACTION_CHARACTER_JUMP, "CHARACTER_jump", &Action_Character_Jump); ActionHandler::GetInstance()->Register (Action::ACTION_CHARACTER_HIGH_JUMP, "CHARACTER_super_jump", &Action_Character_HighJump); ActionHandler::GetInstance()->Register (Action::ACTION_CHARACTER_BACK_JUMP, "CHARACTER_back_jump", &Action_Character_BackJump); - - ActionHandler::GetInstance()->Register (Action::ACTION_CHARACTER_SET_PHYSICS, "CHARACTER_set_physics", &Action_Character_SetPhysics); - // ######################################################## // Using Weapon ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SHOOT, "WEAPON_shoot", &Action_Weapon_Shoot); @@ -1077,15 +947,9 @@ void Action_Handler_Init() ActionHandler::GetInstance()->Register (Action::ACTION_WEAPON_SUPERTUX, "WEAPON_supertux", &Action_Weapon_Supertux); // Bonus box - ActionHandler::GetInstance()->Register (Action::ACTION_NEW_BONUS_BOX, "BONUSBOX_new_box", &Action_NewBonusBox); ActionHandler::GetInstance()->Register (Action::ACTION_DROP_BONUS_BOX, "BONUSBOX_drop_box", &Action_DropBonusBox); // ######################################################## - ActionHandler::GetInstance()->Register (Action::ACTION_NETWORK_SYNC_BEGIN, "NETWORK_sync_begin", &Action_Network_SyncBegin); - ActionHandler::GetInstance()->Register (Action::ACTION_NETWORK_SYNC_END, "NETWORK_sync_end", &Action_Network_SyncEnd); ActionHandler::GetInstance()->Register (Action::ACTION_NETWORK_PING, "NETWORK_ping", &Action_Network_Ping); - - ActionHandler::GetInstance()->Register (Action::ACTION_EXPLOSION, "explosion", &Action_Explosion); - ActionHandler::GetInstance()->Register (Action::ACTION_WIND, "wind", &Action_Wind); ActionHandler::GetInstance()->Register (Action::ACTION_NETWORK_RANDOM_INIT, "NETWORK_random_init", &Action_Network_RandomInit); ActionHandler::GetInstance()->Register (Action::ACTION_INFO_CLIENT_DISCONNECT, "INFO_client_disconnect", &Action_Info_ClientDisconnect); ActionHandler::GetInstance()->Register (Action::ACTION_INFO_CLIENT_CONNECT, "INFO_client_connect", &Action_Info_ClientConnect); @@ -1171,14 +1035,4 @@ void ActionHandler::NewAction(Action* a, bool repeat_to_network) Menu::WakeUpOnCallback(); } -void ActionHandler::NewActionActiveCharacter(Action* a) -{ - ASSERT(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()); - Action a_begin_sync(Action::ACTION_NETWORK_SYNC_BEGIN); - Network::GetInstance()->SendActionToAll(a_begin_sync); - SendActiveCharacterInfo(); - NewAction(a); - Action a_end_sync(Action::ACTION_NETWORK_SYNC_END); - Network::GetInstance()->SendActionToAll(a_end_sync); -} diff --git a/src/include/action_handler.h b/src/include/action_handler.h index a2764a8..210c404 100644 --- a/src/include/action_handler.h +++ b/src/include/action_handler.h @@ -52,14 +52,6 @@ void Action_Handler_Init(); // TODO: Move it in an object ! -// Send character information over the network (it's totally stupid to send it locally ;-) -void SendCharacterInfo(int team_no, int char_no); -void SendActiveCharacterInfo(bool can_be_dropped = false); - -// Send character information + an action over the network -// WARNING: it does not post the action in local queue!! -void SendActiveCharacterAction(const Action& a); - void SendGameMode(); void SyncCharacters(); diff --git a/src/interface/man_machine_interface.cpp b/src/interface/man_machine_interface.cpp index d72a3a8..bc480fa 100644 --- a/src/interface/man_machine_interface.cpp +++ b/src/interface/man_machine_interface.cpp @@ -269,7 +269,6 @@ void ManMachineInterface::HandleKeyReleased(const Key_t &key) ObjBox* current_box = Game::GetInstance()->GetCurrentBox(); if (current_box != NULL) { Action * a = new Action(Action::ACTION_DROP_BONUS_BOX); - current_box->StoreValue(a); ActionHandler::GetInstance()->NewAction(a); } } else if (Game::GetInstance()->ReadState() == Game::PLAYING && @@ -426,15 +425,15 @@ void ManMachineInterface::HandleKeyReleased(const Key_t &key) { if (GameMode::GetInstance()->AllowCharacterSelection()) { SDLMod mod = SDL_GetModState(); - Action * change_character = new Action(Action::ACTION_PLAYER_CHANGE_CHARACTER); - Character::StoreActiveCharacter(change_character); if (mod & KMOD_CTRL) { ActiveTeam().PreviousCharacter(); } else { ActiveTeam().NextCharacter(); } - Character::StoreActiveCharacter(change_character); - ActionHandler::GetInstance()->NewAction(change_character); + Action * next_character = new Action(Action::ACTION_PLAYER_CHANGE_CHARACTER); + uint next_character_index = ActiveCharacter().GetCharacterIndex(); + next_character->Push((int)next_character_index); + ActionHandler::GetInstance()->NewAction(next_character); } } return; diff --git a/src/interface/mouse.cpp b/src/interface/mouse.cpp index c1305a7..98a6c6d 100644 --- a/src/interface/mouse.cpp +++ b/src/interface/mouse.cpp @@ -118,13 +118,12 @@ void Mouse::ActionLeftClic(bool) const } if (character_found) { - Action * next_character = new Action(Action::ACTION_PLAYER_CHANGE_CHARACTER); - Character::StoreActiveCharacter(next_character); - while ( &(*it) != &ActiveCharacter() ) ActiveTeam().NextCharacter (); - Character::StoreActiveCharacter(next_character); + Action * next_character = new Action(Action::ACTION_PLAYER_CHANGE_CHARACTER); + uint next_character_index = (*it).GetCharacterIndex(); + next_character->Push((int)next_character_index); ActionHandler::GetInstance()->NewAction(next_character); return; diff --git a/src/map/wind.cpp b/src/map/wind.cpp index 2b933b7..3e69b9c 100644 --- a/src/map/wind.cpp +++ b/src/map/wind.cpp @@ -216,10 +216,9 @@ void Wind::Reset() RandomizeParticlesPos(); } -void Wind::ChooseRandomVal() const +void Wind::ChooseRandomVal() { - int val = RandomLocal().GetLong(-100, 100); - ActionHandler::GetInstance()->NewAction (new Action(Action::ACTION_WIND, val)); + SetVal(RandomLocal().GetLong(-100, 100)); } void Wind::DrawParticles() diff --git a/src/map/wind.h b/src/map/wind.h index 740bbc2..f4eb937 100644 --- a/src/map/wind.h +++ b/src/map/wind.h @@ -69,8 +69,8 @@ private: public: double GetStrength() const; - void ChooseRandomVal() const; + void ChooseRandomVal(); void SetVal(long val); void Refresh(); void Reset(); diff --git a/src/network/network.cpp b/src/network/network.cpp index 5652b5c..cc28ea2 100644 --- a/src/network/network.cpp +++ b/src/network/network.cpp @@ -227,8 +227,7 @@ Network::Network(const std::string& _game_name, const std::string& passwd) : fout(0), fin(0), #endif - network_menu(NULL), - sync_lock(false) + network_menu(NULL) { cpus_lock = SDL_CreateMutex(); player.SetNickname(Player::GetDefaultNickname()); diff --git a/src/network/network.h b/src/network/network.h index a9bd1c2..61744f8 100644 --- a/src/network/network.h +++ b/src/network/network.h @@ -106,7 +106,6 @@ protected: void SetGameName(const std::string& game_name); public: NetworkMenu* network_menu; - bool sync_lock; virtual ~Network(); diff --git a/src/object/bonus_box.cpp b/src/object/bonus_box.cpp index 19c8204..320bac0 100644 --- a/src/object/bonus_box.cpp +++ b/src/object/bonus_box.cpp @@ -171,19 +171,7 @@ void BonusBox::LoadXml(const xmlNode* object) ASSERT(total_probability != 0.0); } -void BonusBox::GetValueFromAction(Action * a) -{ - ObjBox::GetValueFromAction(a); - weapon_num = (uint)(a->PopInt()); -} - void BonusBox::Randomize() { PickRandomWeapon(); } - -void BonusBox::StoreValue(Action * a) -{ - ObjBox::StoreValue(a); - a->Push(int(weapon_num)); -} diff --git a/src/object/bonus_box.h b/src/object/bonus_box.h index 6f48962..69c33d2 100644 --- a/src/object/bonus_box.h +++ b/src/object/bonus_box.h @@ -57,8 +57,6 @@ class BonusBox : public ObjBox void ApplyBonus(Character *); void Randomize(); - void GetValueFromAction(Action *); - void StoreValue(Action *); }; //----------------------------------------------------------------------------- diff --git a/src/object/medkit.cpp b/src/object/medkit.cpp index cb07455..1600596 100644 --- a/src/object/medkit.cpp +++ b/src/object/medkit.cpp @@ -84,15 +84,3 @@ void Medkit::LoadXml(const xmlNode* object) XmlReader::ReadInt(object,"life_points",start_life_points); XmlReader::ReadInt(object,"energy_boost",nbr_health); } - -void Medkit::GetValueFromAction(Action * a) -{ - ObjBox::GetValueFromAction(a); - nbr_health = a->PopInt(); -} - -void Medkit::StoreValue(Action * a) -{ - ObjBox::StoreValue(a); - a->Push(nbr_health); -} diff --git a/src/object/medkit.h b/src/object/medkit.h index 4612b2e..92d6499 100644 --- a/src/object/medkit.h +++ b/src/object/medkit.h @@ -44,8 +44,6 @@ class Medkit : public ObjBox//public PhysicalObj static void LoadXml(const xmlNode * object); void ApplyBonus(Character *); - void GetValueFromAction(Action *); - void StoreValue(Action *); }; //----------------------------------------------------------------------------- diff --git a/src/object/objbox.cpp b/src/object/objbox.cpp index 659dbc9..2ca5b18 100644 --- a/src/object/objbox.cpp +++ b/src/object/objbox.cpp @@ -159,22 +159,6 @@ void ObjBox::SignalGhostState(bool /*was_already_dead*/) Explode(); } -void ObjBox::GetValueFromAction(Action * a) -{ - PhysicalObj::GetValueFromAction(a); - start_life_points = a->PopInt(); - SetXY(a->PopPoint2d()); - SetSpeedXY(a->PopPoint2d()); -} - -void ObjBox::StoreValue(Action *a) -{ - PhysicalObj::StoreValue(a); - a->Push(start_life_points); - a->Push(GetPosition()); - a->Push(GetSpeed()); -} - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // Static methods diff --git a/src/object/objbox.h b/src/object/objbox.h index d52c1a0..36c64e4 100644 --- a/src/object/objbox.h +++ b/src/object/objbox.h @@ -53,8 +53,6 @@ class ObjBox : public PhysicalObj //it would be nice to name this "Box", but tha void Draw(); virtual void Refresh(); virtual void Randomize() {}; - virtual void GetValueFromAction(Action *); - virtual void StoreValue(Action *); virtual void ApplyBonus(Character *) {}; protected: diff --git a/src/object/physical_obj.cpp b/src/object/physical_obj.cpp index a5a4ef8..5ff1f56 100644 --- a/src/object/physical_obj.cpp +++ b/src/object/physical_obj.cpp @@ -132,55 +132,6 @@ void PhysicalObj::SetSize(const Point2i &newSize) SetPhysSize( (double)newSize.x / PIXEL_PER_METER, (double)newSize.y/PIXEL_PER_METER ); } -void PhysicalObj::StoreValue(Action *a) -{ - Physics::StoreValue(a); - a->Push(m_collides_with_ground); - a->Push(m_collides_with_characters); - a->Push(m_collides_with_objects); - a->Push(m_rebound_position); - a->Push((int)m_minimum_overlapse_time); - a->Push(m_ignore_movements); - a->Push(m_is_character); - a->Push(m_test_left); - a->Push(m_test_right); - a->Push(m_test_top); - a->Push(m_test_bottom); - a->Push(m_width); - a->Push(m_height); - a->Push(m_alive); - a->Push(m_energy); - a->Push(m_allow_negative_y); -} - -void PhysicalObj::GetValueFromAction(Action *a) -{ - Physics::GetValueFromAction(a); - m_collides_with_ground = !!a->PopInt(); - m_collides_with_characters = !!a->PopInt(); - m_collides_with_objects = !!a->PopInt(); - m_rebound_position = a->PopPoint2i(); - m_minimum_overlapse_time = (uint)a->PopInt(); - m_ignore_movements = !!a->PopInt(); - m_is_character = !!a->PopInt(); - m_test_left = a->PopInt(); - m_test_right = a->PopInt(); - m_test_top = a->PopInt(); - m_test_bottom = a->PopInt(); - m_width = a->PopInt(); - m_height = a->PopInt(); - m_alive = (alive_t)a->PopInt(); - m_energy = a->PopInt(); - m_allow_negative_y = !!a->PopInt(); - - ASSERT(m_test_left >= 0); - ASSERT(m_test_right >= 0); - ASSERT(m_test_top >= 0); - ASSERT(m_test_bottom >= 0); - ASSERT(m_width >= 0); - ASSERT(m_height >= 0); -} - void PhysicalObj::SetOverlappingObject(PhysicalObj* obj, int timeout) { m_minimum_overlapse_time = 0; diff --git a/src/object/physical_obj.h b/src/object/physical_obj.h index f2674f1..d0da305 100644 --- a/src/object/physical_obj.h +++ b/src/object/physical_obj.h @@ -105,10 +105,6 @@ public: double GetYdouble() const; const Point2d GetPosition() const { return Point2d(GetXdouble(), GetYdouble()) ;}; - // Used to sync value across network - virtual void GetValueFromAction(Action *); - virtual void StoreValue(Action *); - // Set/Get size void SetSize(const Point2i &newSize); int GetWidth() const { return m_width; }; diff --git a/src/object/physics.cpp b/src/object/physics.cpp index c5ae5c2..5cedb8b 100644 --- a/src/object/physics.cpp +++ b/src/object/physics.cpp @@ -144,59 +144,6 @@ void Physics::GetSpeed(double &norm, double &angle) const } } - -void Physics::StoreValue(Action *a) -{ - a->Push((int)m_motion_type); - a->Push(m_pos_x); - a->Push(m_pos_y); - a->Push(m_extern_force); - a->Push((int)m_last_move); - a->Push(m_phys_width); - a->Push(m_phys_height); - a->Push(m_fix_point_gnd); - a->Push(m_fix_point_dxy); - a->Push(m_rope_angle); - a->Push(m_rope_length); - a->Push(m_rope_elasticity); - a->Push(m_elasticity_damping); - a->Push(m_balancing_damping); - a->Push(m_elasticity_off); - - MSG_DEBUG( "physic.sync", "%s now - x0:%f, x1:%f, x2:%f - y0:%f, y1:%f, y2:%f - extern_force: %f, %f", - typeid(*this).name(), - m_pos_x.x0, m_pos_x.x1, m_pos_x.x2, - m_pos_y.x0, m_pos_y.x1, m_pos_y.x2, - m_extern_force.x, m_extern_force.y); -} - -void Physics::GetValueFromAction(Action *a) -{ - m_motion_type = (MotionType_t)a->PopInt(); - m_pos_x = a->PopEulerVector(); - m_pos_y = a->PopEulerVector(); - m_extern_force = a->PopPoint2d(); - m_last_move = (uint)a->PopInt(); - m_phys_width = a->PopDouble(); - m_phys_height = a->PopDouble(); - m_fix_point_gnd = a->PopPoint2d(); - m_fix_point_dxy = a->PopPoint2d(); - m_rope_angle = a->PopEulerVector(); - m_rope_length = a->PopEulerVector(); - m_rope_elasticity = a->PopDouble(); - m_elasticity_damping = a->PopDouble(); - m_balancing_damping = a->PopDouble(); - m_elasticity_off = !!a->PopInt(); - - ASSERT(Time::GetInstance()->Read() >= m_last_move); - - MSG_DEBUG( "physic.sync", "%s now - x0:%f, x1:%f, x2:%f - y0:%f, y1:%f, y2:%f - extern_force: %f, %f", - typeid(*this).name(), - m_pos_x.x0, m_pos_x.x1, m_pos_x.x2, - m_pos_y.x0, m_pos_y.x1, m_pos_y.x2, - m_extern_force.x, m_extern_force.y); -} - void Physics::SetExternForceXY (const Point2d& vector) { bool was_moving = IsMoving(); diff --git a/src/object/physics.h b/src/object/physics.h index 1a5e595..d593921 100644 --- a/src/object/physics.h +++ b/src/object/physics.h @@ -103,10 +103,6 @@ public: void SetRebounding (bool rebounding) { m_rebounding = rebounding; } bool GetRebounding () const { return m_rebounding; } - // Used to sync value across network - virtual void GetValueFromAction(Action *); - virtual void StoreValue(Action *); - // Reset the physics constants (mass, air_resistance...) to the default values in the cfg void ResetConstants() { *((ObjectConfig*)this) = m_cfg; }; diff --git a/src/team/teams_list.cpp b/src/team/teams_list.cpp index 5becd92..286930c 100644 --- a/src/team/teams_list.cpp +++ b/src/team/teams_list.cpp @@ -78,7 +78,6 @@ void TeamsList::NextTeam () ActiveTeam().NextCharacter(true); Action a(Action::ACTION_GAMELOOP_NEXT_TEAM, next->GetId()); - Character::StoreActiveCharacter(&a); Network::GetInstance()->SendActionToAll(a); printf("\nPlaying character : %i %s\n", ActiveCharacter().GetCharacterIndex(), ActiveCharacter().GetName().c_str()); diff --git a/src/weapon/explosion.cpp b/src/weapon/explosion.cpp index e7d1b18..aa5be08 100644 --- a/src/weapon/explosion.cpp +++ b/src/weapon/explosion.cpp @@ -43,13 +43,12 @@ Profile *weapons_res_profile = NULL; -void ApplyExplosion_common (const Point2i &pos, - const ExplosiveWeaponConfig &config, - const std::string& son, - bool fire_particle, - ParticleEngine::ESmokeStyle smoke, - std::string network_id - ) +void ApplyExplosion (const Point2i &pos, + const ExplosiveWeaponConfig &config, + const std::string& son, + bool fire_particle, + ParticleEngine::ESmokeStyle smoke + ) { MSG_DEBUG("explosion", "explosion range : %i", config.explosion_range); @@ -144,11 +143,6 @@ void ApplyExplosion_common (const Point2i &pos, { PhysicalObj *obj = *it; - if (obj->GetUniqueId() == network_id) { - MSG_DEBUG("explosion", "!! skip blast for object %s", network_id.c_str()); - continue; // hack to fix bug #8529 - } - if (obj->CollidesWithGround() && !obj->IsGhost()) { double distance = pos.Distance(obj->GetCenter()); @@ -183,7 +177,6 @@ void ApplyExplosion_common (const Point2i &pos, ASSERT( obj->GetMass() != 0.0); - MSG_DEBUG("explosion", "!! blasting object %s", network_id.c_str()); obj->AddSpeed (force / obj->GetMass(), angle); } } @@ -207,78 +200,3 @@ void ApplyExplosion_common (const Point2i &pos, }; } -void ApplyExplosion_master (const Point2i &pos, - const ExplosiveWeaponConfig &config, - const std::string& son, - bool fire_particle, - ParticleEngine::ESmokeStyle smoke, - std::string network_id - ) -{ - ActionHandler* action_handler = ActionHandler::GetInstance(); - - Action a_begin_sync(Action::ACTION_NETWORK_SYNC_BEGIN); - Network::GetInstance()->SendActionToAll(a_begin_sync); - - TeamsList::iterator - it=GetTeamsList().playing_list.begin(), - end=GetTeamsList().playing_list.end(); - - Action a_characters_info(Action::ACTION_CHARACTER_SET_PHYSICS); - - for (int team_no = 0; it != end; ++it, ++team_no) - { - Team& team = **it; - Team::iterator - tit = team.begin(), - tend = team.end(); - - for (int char_no = 0; tit != tend; ++tit, ++char_no) - { - Character &character = *tit; - - double distance = pos.Distance( character.GetCenter()); - - // If the character is in the explosion range, apply damage on it ! - if (distance <= config.explosion_range || distance < config.blast_range) - { - // clients : Place characters - Character::StoreCharacter(&a_characters_info, team_no, char_no); - } - } - } - // send characters infos on network - Network::GetInstance()->SendActionToAll(a_characters_info); - - Action* a = new Action(Action::ACTION_EXPLOSION); - a->Push(pos); - a->Push((int)config.explosion_range); - a->Push((int)config.particle_range); - a->Push((int)config.damage); - a->Push((int)config.blast_range); - a->Push((int)config.blast_force); - a->Push(son); - a->Push(fire_particle); - a->Push(smoke); - ASSERT(network_id.size()>0); - a->Push(network_id); - - action_handler->NewAction(a); - Action a_sync_end(Action::ACTION_NETWORK_SYNC_END); - Network::GetInstance()->SendActionToAll(a_sync_end); -} - - -void ApplyExplosion (const Point2i &pos, - const ExplosiveWeaponConfig &config, - const std::string& son, - bool fire_particle, - ParticleEngine::ESmokeStyle smoke, - std::string network_id - ) -{ - if (Network::GetInstance()->IsLocal()) - ApplyExplosion_common(pos, config, son, fire_particle, smoke, network_id); - else if (Network::GetInstance()->IsTurnMaster()) - ApplyExplosion_master(pos, config, son, fire_particle, smoke, network_id); -} diff --git a/src/weapon/explosion.h b/src/weapon/explosion.h index 6cb3b7c..f6ceeff 100644 --- a/src/weapon/explosion.h +++ b/src/weapon/explosion.h @@ -32,18 +32,9 @@ void ApplyExplosion(const Point2i &pos, const ExplosiveWeaponConfig &config, const std::string& son="weapon/explosion", bool fire_particle = true, - ParticleEngine::ESmokeStyle smoke = ParticleEngine::BigESmoke, - std::string network_id = "LOCAL" // Useful only on network : this is used to know that we should not apply blast and damage to the projectile which has created the explosion (bugfix #8529) + ParticleEngine::ESmokeStyle smoke = ParticleEngine::BigESmoke ); -void ApplyExplosion_common (const Point2i &pos, - const ExplosiveWeaponConfig &config, - const std::string& son, - bool fire_particle, - ParticleEngine::ESmokeStyle smoke, - std::string network_id - ); - extern Profile *weapons_res_profile; #endif //WEAPON_TOOLS_H diff --git a/src/weapon/grapple.cpp b/src/weapon/grapple.cpp index af7d6c1..6d0c73e 100644 --- a/src/weapon/grapple.cpp +++ b/src/weapon/grapple.cpp @@ -416,11 +416,10 @@ void Grapple::Refresh() if (!ActiveTeam().IsLocal() && !ActiveTeam().IsLocalAI()) return; -if (IsInUse() && !m_attaching) + if (IsInUse() && !m_attaching) { ActiveCharacter().SetMovement("ninja-rope"); ActiveCharacter().UpdatePosition(); - SendActiveCharacterInfo(true); } } diff --git a/src/weapon/jetpack.cpp b/src/weapon/jetpack.cpp index 6d1ab74..7e22a0d 100644 --- a/src/weapon/jetpack.cpp +++ b/src/weapon/jetpack.cpp @@ -75,7 +75,6 @@ void JetPack::Refresh() F.y = m_y_force ; ActiveCharacter().SetExternForceXY(F); - SendActiveCharacterInfo(true); if (!F.IsNull()) { diff --git a/src/weapon/parachute.cpp b/src/weapon/parachute.cpp index cc48a9f..304fb23 100644 --- a/src/weapon/parachute.cpp +++ b/src/weapon/parachute.cpp @@ -149,11 +149,10 @@ void Parachute::Refresh() } } // If parachute is open => character can move a little to the left or to the right - if (open && Network::GetInstance()->IsTurnMaster()) { + if (open) { ActiveCharacter().SetExternForce(m_x_strength.x_extern, 0.0); if (m_x_strength.changing) { m_x_strength.changing = false; - SendActiveCharacterInfo(false); } } } diff --git a/src/weapon/suicide.cpp b/src/weapon/suicide.cpp index 3877003..4ed9bc5 100644 --- a/src/weapon/suicide.cpp +++ b/src/weapon/suicide.cpp @@ -55,7 +55,6 @@ void Suicide::Refresh() ActiveCharacter().DisableDeathExplosion(); ActiveCharacter().body->MakeParticles(ActiveCharacter().GetPosition()); ActiveCharacter().SetEnergy(0); // Die! - SendActiveCharacterInfo(); ApplyExplosion(ActiveCharacter().GetCenter(),cfg()); } } diff --git a/src/weapon/weapon.cpp b/src/weapon/weapon.cpp index 68de2fc..75d4e8f 100644 --- a/src/weapon/weapon.cpp +++ b/src/weapon/weapon.cpp @@ -251,7 +251,7 @@ void Weapon::NewActionWeaponShoot() const Action* a_shoot = new Action(Action::ACTION_WEAPON_SHOOT, m_strength, ActiveCharacter().GetAbsFiringAngle()); - ActionHandler::GetInstance()->NewActionActiveCharacter(a_shoot); + ActionHandler::GetInstance()->NewAction(a_shoot); } void Weapon::NewActionWeaponStopUse() const @@ -259,7 +259,7 @@ void Weapon::NewActionWeaponStopUse() const ASSERT(ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()); Action* a = new Action(Action::ACTION_WEAPON_STOP_USE); - ActionHandler::GetInstance()->NewActionActiveCharacter(a); + ActionHandler::GetInstance()->NewAction(a); } void Weapon::PrepareShoot(double strength, double angle) diff --git a/src/weapon/weapon_launcher.cpp b/src/weapon/weapon_launcher.cpp index 5d9b3ec..1179acd 100644 --- a/src/weapon/weapon_launcher.cpp +++ b/src/weapon/weapon_launcher.cpp @@ -108,7 +108,7 @@ void WeaponBullet::Refresh() void WeaponBullet::DoExplosion() { Point2i pos = GetCenter(); - ApplyExplosion(pos, cfg, "", false, ParticleEngine::LittleESmoke, GetUniqueId()); + ApplyExplosion(pos, cfg, "", false, ParticleEngine::LittleESmoke); } //----------------------------------------------------------------------------- @@ -348,7 +348,7 @@ void WeaponProjectile::SignalExplosion() void WeaponProjectile::DoExplosion() { Point2i pos = GetCenter(); - ApplyExplosion(pos, cfg, "weapon/explosion", true, ParticleEngine::BigESmoke, GetUniqueId()); + ApplyExplosion(pos, cfg, "weapon/explosion", true, ParticleEngine::BigESmoke); } void WeaponProjectile::IncrementTimeOut() -- 1.6.0.4 _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev