diff options
author | Bertram <bertram@cegetel.net> | 2009-09-22 00:24:33 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-09-22 00:24:33 +0200 |
commit | bf6e1331941daecb3c3ff12c3b86457899042953 (patch) | |
tree | 35c08ff4c09c602c2b22be2a9dba0b6cb9e1d9a5 /src | |
parent | 1aa425bb4c846c978712410de311181c84a1d097 (diff) | |
download | mana-bf6e1331941daecb3c3ff12c3b86457899042953.tar.gz mana-bf6e1331941daecb3c3ff12c3b86457899042953.tar.bz2 mana-bf6e1331941daecb3c3ff12c3b86457899042953.tar.xz mana-bf6e1331941daecb3c3ff12c3b86457899042953.zip |
Mostly fixed the mouse movement in TMWserv client.
The only case left in mouse movement is that the client doesn't check
for walkability of the destination point when you click on a unwalkable point.
Let me explain this NASTY bug:
The bug remained in the Being::SetDestination() function,
when recalculating the path from tiles to pixels.
The changeX and changeY variables went crazy when (endX - startX) gave a negative value.
That why the given path became random, and the player went anywhere.
This didn't happened to monsters, NPCs, and when walking using the keyboard
because the patnodes system isn't used for movement up to 1 tile at a time.
I removed some dead code (in viewpoint.cpp), made the keyboard navigation a little
bit more bearable, and fixed this client bug.
Now, I'll be up to finish fixing the movement system using mouse (What's remaining is a joke
next to what I had to do to discover this...),
and I'll look at a third time to the keyboard system which is a bit raw, just for now...
Regards,
P.S.: Kage, I'd like to get a three-cheese pizza!
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 12 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 10 | ||||
-rw-r--r-- | src/localplayer.cpp | 4 |
3 files changed, 10 insertions, 16 deletions
diff --git a/src/being.cpp b/src/being.cpp index 32a3b5c3..a1bb7f92 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -168,16 +168,16 @@ void Being::setDestination(int dstX, int dstY) // Interpolate the offsets. Also convert from tile based to pixel based // Find the starting offset - int startX = (srcX % 32); - int startY = (srcY % 32); + float startX = (srcX % 32); + float startY = (srcY % 32); // Find the ending offset - int endX = (dstX % 32); - int endY = (dstY % 32); + float endX = (dstX % 32); + float endY = (dstY % 32); // Find the distance, and divide it by the number of steps - int changeX = (endX - startX) / thisPath.size(); - int changeY = (endY - startY) / thisPath.size(); + int changeX = (int)((endX - startX) / thisPath.size()); + int changeY = (int)((endY - startY) / thisPath.size()); // Convert the map path to pixels over tiles // And add interpolation between the starting and ending offsets diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 9a631581..a2ae684a 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -233,21 +233,15 @@ void Viewport::logic() if (!mMap || !player_node) return; +#ifdef EATHENA_SUPPORT if (mPlayerFollowMouse && button & SDL_BUTTON(1) && -#ifdef TMWSERV_SUPPORT - get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay) - { - mLocalWalkTime = tick_time; - player_node->setDestination(mMouseX + (int) mPixelViewX, - mMouseY + (int) mPixelViewY); -#else mWalkTime != player_node->mWalkTime) { player_node->setDestination(mMouseX / 32 + mTileViewX, mMouseY / 32 + mTileViewY); mWalkTime = player_node->mWalkTime; -#endif } +#endif } void Viewport::drawDebugPath(Graphics *graphics) diff --git a/src/localplayer.cpp b/src/localplayer.cpp index 9b8e4a4b..7cd6b889 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -418,9 +418,9 @@ void LocalPlayer::walk(unsigned char dir) int dScaler; // Distance to walk - // Checks our path up to 1 tiles, if a blocking tile is found + // Checks our path up to 2 tiles, if a blocking tile is found // We go to the last good tile, and break out of the loop - for (dScaler = 1; dScaler <= 32; dScaler++) + for (dScaler = 1; dScaler <= 32 * 2; dScaler++) { if ( (dx || dy) && !mMap->getWalk( ((int) pos.x + (dx * dScaler)) / 32, |