Jump to content

[10688][Fix] Diff values for map update cycles


Guest ciphercom

Recommended Posts

http://gist.github.com/659141 version compatible with master code with small changes.

From testing see only one porblem: at teleport to poin near some waypoint/random walking creature it in run mode attempt resync own position for real diff time from last update. So run to next point instead walk... but _normal_ run with expected run speed... no as some extra speed object...

At normal enter to area by player run/walk no described picture because visibility radius > real visible area and mob have small time for resync in grey zone

Because teleporting in to no-player-around places possible only for GM in most cases then this mostly GM view problem.

I not sure that this can be real stopper from adding patch to repo because it solve many other real porblems with mob/object state

Link to comment
Share on other sites

Hi Folks,

I've investigated my Problem.

Pls correct me, if i am wrong.

#if PLATFORM == PLATFORM_WINDOWS
inline uint32 getMSTime() { return GetTickCount(); }
#else
inline uint32 getMSTime()
{
   struct timeval tv;
   struct timezone tz;
   gettimeofday( &tv, &tz );
   return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);
}
#endif

Let's start with windows.

It is called the GetTickCount() method from the WinAPI. (http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx)

Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.

So in the case of my windows computer the Value was in the test something like 5000 0000 --> apr. 5000 seconds --> 83 minutes. 5000 0000 is a relative small number and fits in a unit32 without problems.

So now Linux.

    gettimeofday( &tv, &tz );
   return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);

gettimeofday( &tv, &tz ); Calculates the seconds (and milliseconds) from the 1.1.1970.

Let's Calculate.

Appr. more than 40 Years = 40 * 365 days * 24 hour * 3600 seconds = 1.261.440.000

Ok this wouldn't overflow an uint32 (2^32 = 0-4.294.967.295)

But you return:

return (tv.tv_sec * 1000) + (tv.tv_usec / 1000);

Ok, it makes sense, because we want the milliseconds, but now it ist 1.261.440.000 * 1.000 = 1.261.440.000.000 what definitively overflows the uint32 (2^32 = 0-4.294.967.295).

The result from getMSTime() is used for the Updates in the world since this commit. That's new.

Why I am telling you?

I just want my totems back @ linux :(

I don't now whether I am right.

And even if all the points, I mentioned are correct, I do not know how it could falsify the system. I mean, so what? the milliseconds overflows the data bounds, but there would be some kind of modulo operation. Timeimillisec % 2^32, would'n it?

The easiest way, would be, that some please test this commit @ a platform which is not windows.

Thus, nobody seams to have my totem Problem, I think all my considerations are void :(

Anyway, Good night Everybody!

Marik :)

Small Addition: With this Commit I had very weird crashes in some scripts. In one script its crashed at three different Codelines (Play sound A, Play sound B, change flag --> Easy stuff). Before this commit I haven't got problems with this crash. And now, I am on one Commit before this, I've tested the same script and no crashes. I don't now whether it is all linked together, but it is problably.

Link to comment
Share on other sites

mstime overflow expected result. Specialy for this case used getMSDiff function for calculate diff in 2 mstime values

Global problem in code that not directly related to current problems: time(NULL)/getMSTime _DON'T must be used in code

except very limited places at world/map update start. In all other places must used map/world tick start value time as current indepedent how long tick executes and what time(NULL)/gteMStime value now.

I'am now using rsa patch ([url]https://github.com/rsa/mangos/commit/e8[/url] … 94fefea5fd).

I can't look at like chnages as at normal attempt bug fixing.

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use