diff options
author | Bertram <bertram@cegetel.net> | 2009-10-29 11:20:29 +0100 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-10-29 11:20:29 +0100 |
commit | 6d2a6ee01523bbec105cd2e6ce9a24ab7c1094f2 (patch) | |
tree | 99bd2c18c08a034a5fcffe49dfa3d2ade43095b0 | |
parent | 45223500f7a5f661adea71e57010b018bac2cf32 (diff) | |
download | mana-client-6d2a6ee01523bbec105cd2e6ce9a24ab7c1094f2.tar.gz mana-client-6d2a6ee01523bbec105cd2e6ce9a24ab7c1094f2.tar.bz2 mana-client-6d2a6ee01523bbec105cd2e6ce9a24ab7c1094f2.tar.xz mana-client-6d2a6ee01523bbec105cd2e6ce9a24ab7c1094f2.zip |
Second round of fine tuning for keyboard movement.
I just discovered that the X,Y offsets aren't handled
the same way between eAthena and Manaserv to draw the player's character.
So, this patch hopefully fix the walk on water bug.
There are some glitches left:
- Like walking diagonally to a blocked corner.
- Or Some times the character miss a blocked tile and correct its route.
- The character's name is drawn in the wrong place for Manaserv client.
- The playerBox draws the player at the wrong location; He's not centered at login
and isn't diplayed at all in equipment window...
But anyway, it's better than before.
I'll go on for some polishing before continuing. Some cleanups
are becoming vital for code's understanding.
-rw-r--r-- | src/being.cpp | 12 | ||||
-rw-r--r-- | src/gui/viewport.cpp | 13 | ||||
-rw-r--r-- | src/localplayer.cpp | 6 | ||||
-rw-r--r-- | src/net/manaserv/beinghandler.cpp | 16 |
4 files changed, 33 insertions, 14 deletions
diff --git a/src/being.cpp b/src/being.cpp index feec617a..be98bfdd 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -539,7 +539,6 @@ void Being::logic() // When we've not reached our destination, move to it. if (nominalLength > 1.0f && mWalkSpeed > 0.0f) { - // The private mWalkSpeed member is the speed in tiles per second. // We translate it into pixels per tick, // because the logic is called every ticks. @@ -583,6 +582,7 @@ void Being::logic() direction |= (dir.x > 0) ? RIGHT : LEFT; else direction |= (dir.y > 0) ? DOWN : UP; + setDirection(direction); } else if (!mPath.empty()) @@ -611,11 +611,11 @@ void Being::logic() // Update sprite animations if (mUsedTargetCursor) - mUsedTargetCursor->update(tick_time * 10); + mUsedTargetCursor->update(tick_time * MILLISECONDS_IN_A_TICK); for (SpriteIterator it = mSprites.begin(); it != mSprites.end(); it++) if (*it) - (*it)->update(tick_time * 10); + (*it)->update(tick_time * MILLISECONDS_IN_A_TICK); // Restart status/particle effects, if needed if (mMustResetParticles) { @@ -636,9 +636,13 @@ void Being::draw(Graphics *graphics, int offsetX, int offsetY) const { // TODO: Eventually, we probably should fix all sprite offsets so that // these translations aren't necessary anymore. The sprites know - // best where their centerpoint should be. + // best where their base point should be. const int px = mPx + offsetX - 16; +#ifdef MANASERV_SUPPORT + const int py = mPy + offsetY - 15; // Temporary fix to the Y offset. +#else const int py = mPy + offsetY - 32; +#endif if (mUsedTargetCursor) mUsedTargetCursor->draw(graphics, px, py); diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp index 21a6ec80..6e9720e9 100644 --- a/src/gui/viewport.cpp +++ b/src/gui/viewport.cpp @@ -231,8 +231,8 @@ void Viewport::logic() if (!mMap || !player_node) return; -#ifdef EATHENA_SUPPORT Uint8 button = SDL_GetMouseState(&mMouseX, &mMouseY); +#ifdef EATHENA_SUPPORT if (mPlayerFollowMouse && button & SDL_BUTTON(1) && mWalkTime != player_node->mWalkTime) @@ -241,6 +241,17 @@ void Viewport::logic() mMouseY / 32 + mTileViewY); mWalkTime = player_node->mWalkTime; } +#else // MANASERV_SUPPORT + Uint8 *keys = SDL_GetKeyState(NULL); + if (mPlayerFollowMouse && button & SDL_BUTTON(1) && + !(keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]) && + get_elapsed_time(mLocalWalkTime) >= walkingMouseDelay) + { + mLocalWalkTime = tick_time; + player_node->setDestination(mMouseX + (int) mPixelViewX, + mMouseY + (int) mPixelViewY); + player_node->pathSetByMouse(); + } #endif } diff --git a/src/localplayer.cpp b/src/localplayer.cpp index a6e558e8..f17fbca4 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -303,7 +303,6 @@ void LocalPlayer::nextStep(unsigned char dir = 0) const Vector &pos = getPosition(); // Compute where the next step will be set. - int dx = 0, dy = 0; if (dir & UP) dy--; @@ -342,7 +341,7 @@ void LocalPlayer::nextStep(unsigned char dir = 0) } } - if (dScaler > 0) + if (dScaler > 16) { //effectManager->trigger(15, (int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler)); setDestination((int) pos.x + (dx * dScaler), (int) pos.y + (dy * dScaler)); @@ -526,13 +525,12 @@ void LocalPlayer::setDestination(Uint16 x, Uint16 y) mDestX = x; mDestY = y; + Being::setDestination(x, y); Net::getPlayerHandler()->setDestination(x, y, mDirection); } mPickUpTarget = NULL; mKeepAttacking = false; - - Being::setDestination(x, y); } void LocalPlayer::setWalkingDir(int dir) diff --git a/src/net/manaserv/beinghandler.cpp b/src/net/manaserv/beinghandler.cpp index 3df346a4..d8508f01 100644 --- a/src/net/manaserv/beinghandler.cpp +++ b/src/net/manaserv/beinghandler.cpp @@ -313,12 +313,18 @@ void BeingHandler::handleBeingDirChangeMessage(MessageIn &msg) if (!being) return; int data = msg.readInt8(); - switch (data) + + // The direction for the player's character is handled on client side. + if (being != player_node) { - case DIRECTION_UP: being->setDirection(Being::UP); break; - case DIRECTION_DOWN: being->setDirection(Being::DOWN); break; - case DIRECTION_LEFT: being->setDirection(Being::LEFT); break; - case DIRECTION_RIGHT: being->setDirection(Being::RIGHT); break; + switch (data) + { + case DIRECTION_UP: being->setDirection(Being::UP); break; + case DIRECTION_DOWN: being->setDirection(Being::DOWN); break; + case DIRECTION_LEFT: being->setDirection(Being::LEFT); break; + case DIRECTION_RIGHT: being->setDirection(Being::RIGHT); break; + default: break; + } } } |