Log in

View Full Version : MOBs and Minor typo


Scorpious2k
12-02-2003, 04:51 AM
In mob.cpp Mob::CalculateDistance it reads:

return (float)sqrt( ((x_pos-x)*(x_pos-x)) + ((y_pos-x)*(y_pos-x)) + ((z_pos-z)*(z_pos-z)) );

and should be... (notice the y calc)

return (float)sqrt( ((x_pos-x)*(x_pos-x)) + ((y_pos-y)*(y_pos-y)) + ((z_pos-z)*(z_pos-z)) );

Among other things it might explain the vanishing mobs.

Edgar1898
12-02-2003, 05:37 AM
good catch! I'll fix that tonight :)

Scorpious2k
12-02-2003, 07:59 AM
good catch! I'll fix that tonight :)

Thanks.

To be honest, I was in the process of replacing it with some expiremental code when I noticed it...

expiremental code:

float xDiff=(x_pos-x);
float yDiff=(y_pos-y);
float zDiff=(z_pos-z);

float calctemp;
float calcdist;

__asm
{
fld xDiff
fmul xDiff
fst calctemp
fld yDiff
fmul yDiff
fadd calctemp
fst calctemp
fld zDiff
fmul zDiff
fadd calctemp
fsqrt
fst calcdist
}
return calcdist;


So far, it seems to work correctly.

Trumpcard
12-02-2003, 10:25 AM
That was probably my mistake when I was refactoring the DIST calculations.. Doh! Classic cut and paste error!

Good catch and thanks!

Scorp, I tried to use the inline asm, but the implementation doesnt work well with gcc/gas. I'll see if I can convert it over, but I stopped worrying about it when I eliminated 99.99% of the dist calls in the 1st place... (did a precheck before calling the dist function so its only called when its needed) At this point, converting it too assembly might be an overcomplication with minimal performance gains, not that I dont appreciate the work necessary to generate it.

Scorpious2k
12-02-2003, 10:52 AM
That was probably my mistake when I was refactoring the DIST calculations.. Doh! Classic cut and paste error!

And I thought I was the only one who did that... note to self: cancel patent search on cut & paste errors. :-)

I tried to use the inline asm, but the implementation doesnt work well with gcc/gas.

Compatability. A very good reason to keep it out.

stopped worrying about it when I eliminated 99.99% of the dist calls in the 1st place... (did a precheck before calling the dist function so its only called when its needed)

I saw that. A brilliant move.

At this point, converting it too assembly might be an overcomplication with minimal performance gains, not that I dont appreciate the work necessary to generate it.

It really wasn't much work.

There are some people who might 1) do it just to prove to himself that it works and 2) think cutting clock cycles with ingenuity is actually fun.

The fifth amendment gives me the right to not mention the name of one of these people.

Trumpcard
12-02-2003, 12:04 PM
I'm all for performance/process improvement (look up 6 sigma blackbelts if you get the chance..lol... Thats a big part of what i do).. If I can test the compile of it on VS.net (I've only got 6) , we can put the inline assembly in an #ifdef WIN32 , clause until i can work out the gas implementation...

bobzub
12-03-2003, 05:37 AM
I just wanted to mention that I did not find the line Scorp listed above,
in mob.cpp. I found it in MobAI.cpp.

-bobzub

Eglin
12-03-2003, 06:06 AM
look up 6 sigma blackbelts if you get the chance..lol... Thats a big part of what i doack! I feel your pain, man. Looked it up out of curiousity, and everthing from the intro on made me feel sick. The 6 Sigma Black Belt is a team leader, a project coordinator, and a mentor. She identifies trends that may be causing defects, and pursues perfection. Her training results is higher profitability and lower costs for the entire organization.I'm not a sexist, but I sure as hell wouldn't bring the authors of this statement in to train my QA team. She and Her? You know, I'm looking at that and wondering what the hell they were thinknig. Then again, QA people always do manage to get under my skin somehow ;)