If the body gets rebuild in the draw method then the hand position gets dependent of the draw rate. With the hand position the behavior of grapple gets dependent of the draw rate. Thus players will get different results in network games if the body gets build in the draw method. That's why the characters gets now build at other locations in the code. --- src/character/body.cpp | 6 ++++-- src/character/member.cpp | 2 ++ src/game/game.cpp | 10 ++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/character/body.cpp b/src/character/body.cpp index 7bfa3ec..c64585a 100644 --- a/src/character/body.cpp +++ b/src/character/body.cpp @@ -477,8 +477,7 @@ void Body::DrawWeaponMember(const Point2i& _pos) void Body::Draw(const Point2i& _pos) { - Build(); - + ASSERT(!need_rebuild); int draw_weapon_member = 0; // Finally draw each layer one by one @@ -502,6 +501,9 @@ void Body::Draw(const Point2i& _pos) if (owner->IsActiveCharacter() && draw_weapon_member == 0) { DrawWeaponMember(_pos); } + + // if this assertion fails then the body has been modified in this _draw_ method!!! + ASSERT(!need_rebuild); } void Body::AddChildMembers(Member* parent) diff --git a/src/character/member.cpp b/src/character/member.cpp index 3657a39..4b147f1 100644 --- a/src/character/member.cpp +++ b/src/character/member.cpp @@ -179,6 +179,7 @@ void Member::Draw(const Point2i & _pos, int flip_center, int direction) posi.x = 2 * flip_center - posi.x - spr->GetWidth(); } + ASSERT(parent != NULL || type == "body"); if(parent == NULL && type != "body") { std::cerr << "Error : Member " << name << " have no parent member!" << std::endl; @@ -193,6 +194,7 @@ void Member::Draw(const Point2i & _pos, int flip_center, int direction) void Member::ApplySqueleton(Member* parent_member) { // Place the member to shape the skeleton + ASSERT(parent_member != NULL); if(parent_member == NULL) { std::cerr << "Member " << name << " have no parent member!" << std::endl; diff --git a/src/game/game.cpp b/src/game/game.cpp index 0f0eee8..a52214f 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -518,6 +518,12 @@ void Game::MainLoop() // Refresh clock value RefreshClock(); + // For example the switch of characters can make it necessary to rebuild the body. + // If no cacluate frame action is sheduled the frame calculation will be skipped and the bodies don't get build. + // As the draw method needs builded characters we need to build here + FOR_ALL_CHARACTERS(team,character) + character->GetBody()->Build(); + // The action which verifys the random seed must be the first action sheduled! // Otherwise the following could happen: // 1. Action C gets sheduled which draws values from the random source. @@ -553,6 +559,10 @@ void Game::MainLoop() // Refresh the map GetWorld().Refresh(); + // Build the characters if necessary so that it does not need to happen while drawing. + // The build can become necessary again when for example weapons change the movement. + FOR_ALL_CHARACTERS(team,character) + character->GetBody()->Build(); } else { SDL_Delay(1); } -- 1.6.0.4 _______________________________________________ Wormux-dev mailing list Wormux-dev@gna.org https://mail.gna.org/listinfo/wormux-dev