Magic Casting Interrupted

Forum rules
NO LONGER BEING MAINTAINED!
azafaraht
Posts: 74
Joined: Thu Nov 22, 2012 11:04 am

Re: Magic Casting Interrupted

Post by azafaraht » Sat Jan 26, 2013 7:06 pm

The output was:

[02:49:48][Debug] startpos x: -272.800000 startpos z: -272.800000 endpos x: 361.000000 endpos z: 361.000000

I copy pasted what you posted, but it seems parameter positions 2 and 3 are inverted. So in reality, what I got was:

[02:49:48][Debug] startpos x: -272.800000 startpos z: 361.000000 endpos x: -272.800000 endpos z: 361.000000

Edit: This makes no sense. With those values, it's not supposed to enter THAT if... The "ShowDebug" statement is inside that if...
Server running on Ubuntu 12.04 Server 64-bit on VirtualBox
Client running on Windows 7 64-bit iMac

azafaraht
Posts: 74
Joined: Thu Nov 22, 2012 11:04 am

Re: Magic Casting Interrupted

Post by azafaraht » Sat Jan 26, 2013 7:40 pm

I was able to cast by making the following changes:

Code: Select all

               //the check for player position only occurs AFTER the cast time is up, you can move so long as x/z is the same on finish.
                //furthermore, it's actually quite lenient, hence the rounding to 1 dp
                float StartX;
                float StartZ;
                float EndX;
                float EndZ;
                StartX=floorf(m_PChar->m_StartActionPos.x * 10 + 0.5) / 10;
                StartZ=floorf(m_PChar->m_StartActionPos.z * 10 + 0.5) / 10;
                EndX=floorf(m_PChar->loc.p.x * 10 + 0.5) / 10;
                EndZ=floorf(m_PChar->loc.p.z * 10 + 0.5) / 10;
                ShowDebug("startpos x: %f startpos z: %f endpos x: %f endpos z: %f\n",StartX,StartZ,EndX,EndZ);
                ShowDebug("startpos x: %f startpos z: %f endpos x: %f endpos z: %f\n", floorf(m_PChar->m_StartActionPos.x * 10 + 0.5) / 10, floorf(m_PChar->m_StartActionPos.z * 10 + 0.5) / 10, floorf(m_PChar->loc.p.x * 10 + 0.5) / 10, floorf(m_PChar->loc.p.z * 10 + 0.5) / 10);
                if (StartX != EndX || StartZ != EndZ)
                //if (floorf(m_PChar->m_StartActionPos.x * 10 + 0.5) / 10 != floorf(m_PChar->loc.p.x * 10 + 0.5) / 10 ||
                //floorf(m_PChar->m_StartActionPos.z * 10 + 0.5) / 10 != floorf(m_PChar->loc.p.z * 10 + 0.5) / 10)
                {
                        m_PChar->pushPacket(new CMessageBasicPacket(m_PChar, m_PChar, 0, 0, 16));

                        m_ActionType = ACTION_MAGIC_INTERRUPT;
                        return;
                }
I made this changes because of two reasons:
1. I wanted to see exactly what was being evaluated, not the values after the evaluation turned out to be true. That's why I used the variables.
2. I wanted to see if there would be a difference between the number being evaluted, and getting the pos coordinates again.

Well, I was able to cast... but this gets me nowhere. It works in the official server, but it's not working for me. XD
Server running on Ubuntu 12.04 Server 64-bit on VirtualBox
Client running on Windows 7 64-bit iMac

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Magic Casting Interrupted

Post by kjLotus » Sat Jan 26, 2013 11:44 pm

try this:

http://stackoverflow.com/questions/1733 ... comparison

it might be a problem of decimals storage in binary. i'm pretty sure this would be a machine dependent case, which would explain why it only happens to you

basically, they might not be equal because there's some really really tiny number difference that is there because the exact decimal number can't be expressed in binary

so replace both direct comparisons with fabs(oldpos, newpos) < some tiny ass number and see if that works

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: Magic Casting Interrupted

Post by kjLotus » Sat Jan 26, 2013 11:57 pm

thought of something better: since they're all one decimal precision, just get rid of the division by 10

they don't even have to be floats anymore at this point, they can just be ints

azafaraht
Posts: 74
Joined: Thu Nov 22, 2012 11:04 am

Re: Magic Casting Interrupted

Post by azafaraht » Sun Jan 27, 2013 9:16 am

Thanks alot for your help kj. Will try asap.
Server running on Ubuntu 12.04 Server 64-bit on VirtualBox
Client running on Windows 7 64-bit iMac

Post Reply