A forum for reporting bugs NOT related to custom plugins.
Moderator: MacroQuest Developers
-
pms
- a grimling bloodguard

- Posts: 663
- Joined: Mon Jan 31, 2005 5:20 pm
- Location: Internet, Earth
-
Contact:
Post
by pms » Fri Dec 26, 2008 6:53 pm
I believe the bool protects from abuse or getting stuck. This is still a safer way to do this instead of setting char data to illegal ranges. I believe this caused a bug in MoveUtils and I had borrowed the logic from this.
MQ2Pulse.cpp - Line 201
Code: Select all
edit: this was a bad implementation
I would say changes in red but I fixed the spacing too, with spaces not tabs even!
Last edited by
pms on Thu Apr 02, 2009 2:28 pm, edited 1 time in total.
-
pms
- a grimling bloodguard

- Posts: 663
- Joined: Mon Jan 31, 2005 5:20 pm
- Location: Internet, Earth
-
Contact:
Post
by pms » Mon Dec 29, 2008 2:39 pm
gLookAngle uses the same logic. Here is the above idea applied to that as well. Also the double <----> float seems unused (convert back then forth?) but didn't change that since I'm unsure why.
MQ2Pulse.cpp - Line 229ish
Code: Select all
if (gLookAngle != 10000.0f) {
if (abs((INT)(pChar->CameraAngle - gLookAngle)) < 5) {
pChar->CameraAngle = (FLOAT)gLookAngle;
gLookAngle = 10000.0f;
TurnNotDone = FALSE;
} else {
TurnNotDone = TRUE;
FLOAT c1 = pChar->CameraAngle;
FLOAT c2 = (FLOAT)gLookAngle;
DOUBLE turn = (DOUBLE)(rand() % 200) / 20;
if (c1 < c2) {
c1 += (FLOAT)turn;
if (c1 >= 128.0f) c1 -= 128.0f;
pChar->CameraAngle = c1;
} else {
c1 -= (FLOAT)turn;
if (c1 <= -128.0f) c1 += 128.0f;
pChar->CameraAngle = c1;
}
}
}
-
dont_know_at_all
- Developer

- Posts: 5450
- Joined: Sun Dec 01, 2002 4:15 am
- Location: Florida, USA
-
Contact:
Post
by dont_know_at_all » Mon Dec 29, 2008 3:19 pm
pms wrote:MQ2Pulse.cpp - Line 201
What problem are you fixing here?
-
pms
- a grimling bloodguard

- Posts: 663
- Joined: Mon Jan 31, 2005 5:20 pm
- Location: Internet, Earth
-
Contact:
Post
by pms » Mon Dec 29, 2008 6:01 pm
repasting this:
the way it was done before it would set heading to an invalid range then correct after the fact if it was out of range. in testing for loose heading in moveutils i found that when you set values out of range, your char can get stuck vibrating left and right over and over. it doesnt happen every time but the way i redid it above it wont let the value get set until it is within the correct range.
looking at this the only part i did not understand was declaring turn as a double then casting it to a float, greater rand precision when rounding back?
also i was under the impression when setting doubles you would use "10.0" whereas float you would use "10.0f" to avoid compiler warnings. this gives none but if my understanding is correct perhaps i should be anal and edit lines like this:
gLookAngle = 10000.0f;
to
gLookAngle = 10000.0; ?
-
dont_know_at_all
- Developer

- Posts: 5450
- Joined: Sun Dec 01, 2002 4:15 am
- Location: Florida, USA
-
Contact:
Post
by dont_know_at_all » Mon Dec 29, 2008 9:24 pm
How does it get stuck? The EQ client is single threaded. There is no way for any other part of the code to read the bad values before it is changed to the right value...
-
pms
- a grimling bloodguard

- Posts: 663
- Joined: Mon Jan 31, 2005 5:20 pm
- Location: Internet, Earth
-
Contact:
Post
by pms » Tue Dec 30, 2008 12:06 am
good to know, this isn't needed then. was just the way i was calling it in moveutils.
thanks!