… | |
… | |
32 | ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg)) |
32 | ((unsigned int)(val) - (unsigned int)(beg) <= (unsigned int)(end) - (unsigned int)(beg)) |
33 | |
33 | |
34 | // in range excluding end |
34 | // in range excluding end |
35 | #define IN_RANGE_EXC(val,beg,end) \ |
35 | #define IN_RANGE_EXC(val,beg,end) \ |
36 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
36 | ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) |
|
|
37 | |
|
|
38 | void fork_abort (const char *msg); |
37 | |
39 | |
38 | // this is much faster than crossfires original algorithm |
40 | // this is much faster than crossfires original algorithm |
39 | // on modern cpus |
41 | // on modern cpus |
40 | inline int |
42 | inline int |
41 | isqrt (int n) |
43 | isqrt (int n) |
… | |
… | |
58 | #if 0 |
60 | #if 0 |
59 | return dx_ > dy_ |
61 | return dx_ > dy_ |
60 | ? (dx_ * 61685 + dy_ * 26870) >> 16 |
62 | ? (dx_ * 61685 + dy_ * 26870) >> 16 |
61 | : (dy_ * 61685 + dx_ * 26870) >> 16; |
63 | : (dy_ * 61685 + dx_ * 26870) >> 16; |
62 | #else |
64 | #else |
63 | return dx + dy - min (dx, dy) * 5 / 8; |
65 | return dx_ + dy_ - min (dx_, dy_) * 5 / 8; |
64 | #endif |
66 | #endif |
65 | } |
67 | } |
66 | |
68 | |
|
|
69 | /* |
|
|
70 | * absdir(int): Returns a number between 1 and 8, which represent |
|
|
71 | * the "absolute" direction of a number (it actually takes care of |
|
|
72 | * "overflow" in previous calculations of a direction). |
|
|
73 | */ |
|
|
74 | inline int |
|
|
75 | absdir (int d) |
|
|
76 | { |
|
|
77 | return ((d - 1) & 7) + 1; |
|
|
78 | } |
67 | |
79 | |
68 | // makes dynamically allocated objects zero-initialised |
80 | // makes dynamically allocated objects zero-initialised |
69 | struct zero_initialised |
81 | struct zero_initialised |
70 | { |
82 | { |
71 | void *operator new (size_t s, void *p) |
83 | void *operator new (size_t s, void *p) |