Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Detecting if pilot is in certain coords
Goto page Previous  1, 2
 
Post new topic   Reply to topic Printable version
 View previous topic  confused Post :: Post String help  View next topic  
Author Message
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Jul 15, 2004 3:37 am    Post subject: Reply to topic Reply with quote

Bak wrote:
The only issue you might get is after the system is on 25 days where the integer variable will wrap around to negatives. Then new players may get warped more than once. I'll update the code to use centiseconds instead and it should solve this, as the value will always stay positive. Good catch Ekted.


The old wrap. icon_smile.gif That is one of the first things I try to deal with when handling integer compares. It's especially bad with things like ticks in windows since they are unsigned, and people often try to subtract to compare to some expected range. I never subtract unless I know I set a base that IS relative to the value.
_________________
4,691 irradiated haggis!
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Jul 15, 2004 10:15 am    Post subject: Reply to topic Reply with quote

so how do you compare to some expected range. I couldn't change the variable to unsigned long here because the tag's use integers, unless I didn't use tags or modfied them.

Do you do something like:

Code: Show/Hide
if (time2 - time1 < tolerance && time1 - time2 > -tolerance)
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Mr Ekted
Movie Geek


Gender:Gender:Male
Joined: Feb 09 2004
Posts: 1379
Offline

PostPosted: Thu Jul 15, 2004 1:55 pm    Post subject: Reply to topic Reply with quote

If you have a known base, like start_time = GetTickCount(), then at some point in the future, you can do GetTickCount() - start_time >= SOME_INTERVAL. This will always work even if the values wrap, because the difference also wraps.

0x00000001 - 0xffffffff = 2

If MERV tags are 32-bit ints, then you can simply cast ticks back and forth to unsigned ints. No change of bits is performed, just change of interpretation.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:26
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Thu Jul 15, 2004 2:38 pm    Post subject: Reply to topic Reply with quote

that's what it's doing. The problem is that if the tag isn't found it'll default to 0.

so curTime = -124114 and
lastWarpTime = 0

curTime - lastWarpTime is -124114 which is < 100 (tolerance).

but with centiseconds the value will never be negative, so the problem is solved.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Goto page Previous  1, 2
Page 2 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 55 page(s) served in previous 5 minutes.

phpBB Created this page in 0.457518 seconds : 28 queries executed (93.8%): GZIP compression disabled