… | |
… | |
102 | // sign returns -1 or +1 |
102 | // sign returns -1 or +1 |
103 | template<typename T> |
103 | template<typename T> |
104 | static inline T sign (T v) { return v < 0 ? -1 : +1; } |
104 | static inline T sign (T v) { return v < 0 ? -1 : +1; } |
105 | // relies on 2c representation |
105 | // relies on 2c representation |
106 | template<> |
106 | template<> |
107 | inline sint8 sign (sint8 v) { return 1 - (sint8 (uint8 (v) >> 7) * 2); } |
107 | inline sint8 sign (sint8 v) { return 1 - (sint8 (uint8 (v) >> 7) * 2); } |
|
|
108 | template<> |
|
|
109 | inline sint16 sign (sint16 v) { return 1 - (sint16 (uint16 (v) >> 15) * 2); } |
|
|
110 | template<> |
|
|
111 | inline sint32 sign (sint32 v) { return 1 - (sint32 (uint32 (v) >> 31) * 2); } |
108 | |
112 | |
109 | // sign0 returns -1, 0 or +1 |
113 | // sign0 returns -1, 0 or +1 |
110 | template<typename T> |
114 | template<typename T> |
111 | static inline T sign0 (T v) { return v ? sign (v) : 0; } |
115 | static inline T sign0 (T v) { return v ? sign (v) : 0; } |
112 | |
116 | |
… | |
… | |
482 | } |
486 | } |
483 | |
487 | |
484 | // return a number within the closed interval [min .. max] |
488 | // return a number within the closed interval [min .. max] |
485 | int operator () (int r_min, int r_max) |
489 | int operator () (int r_min, int r_max) |
486 | { |
490 | { |
487 | return is_constant (r_min) && is_constant (r_max) && r_min <= r_max |
491 | return is_constant (r_min <= r_max) && r_min <= r_max |
488 | ? r_min + operator ()(r_max - r_min + 1) |
492 | ? r_min + operator ()(r_max - r_min + 1) |
489 | : get_range (r_min, r_max); |
493 | : get_range (r_min, r_max); |
490 | } |
494 | } |
491 | |
495 | |
492 | // return a number within the closed interval [0..1] |
496 | // return a number within the closed interval [0..1] |
… | |
… | |
572 | typedef refptr<maptile> maptile_ptr; |
576 | typedef refptr<maptile> maptile_ptr; |
573 | typedef refptr<object> object_ptr; |
577 | typedef refptr<object> object_ptr; |
574 | typedef refptr<archetype> arch_ptr; |
578 | typedef refptr<archetype> arch_ptr; |
575 | typedef refptr<client> client_ptr; |
579 | typedef refptr<client> client_ptr; |
576 | typedef refptr<player> player_ptr; |
580 | typedef refptr<player> player_ptr; |
|
|
581 | typedef refptr<region> region_ptr; |
577 | |
582 | |
578 | #define STRHSH_NULL 2166136261 |
583 | #define STRHSH_NULL 2166136261 |
579 | |
584 | |
580 | static inline uint32_t |
585 | static inline uint32_t |
581 | strhsh (const char *s) |
586 | strhsh (const char *s) |