… | |
… | |
16 | |
16 | |
17 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
20 | |
21 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | /* |
24 | /* |
25 | * General convenience functions for crossfire. |
25 | * General convenience functions for crossfire. |
26 | */ |
26 | */ |
… | |
… | |
97 | diff = max - min + 1; |
97 | diff = max - min + 1; |
98 | ((diff > 2) ? (base = 20) : (base = 50)); /* d2 and d3 are corner cases */ |
98 | ((diff > 2) ? (base = 20) : (base = 50)); /* d2 and d3 are corner cases */ |
99 | |
99 | |
100 | if (max < 1 || diff < 1) |
100 | if (max < 1 || diff < 1) |
101 | { |
101 | { |
102 | #ifndef WIN32 |
|
|
103 | LOG (llevError, "Calling random_roll with min=%lld max=%lld\n", min, max); |
|
|
104 | #else |
|
|
105 | LOG (llevError, "Calling random_roll with min=%I64d max=%I64d\n", min, max); |
102 | LOG (llevError, "Calling random_roll with min=%" PRId64 " max=%" PRId64 "\n", min, max); |
106 | #endif |
|
|
107 | return (min); /* avoids a float exception */ |
103 | return (min); /* avoids a float exception */ |
108 | } |
104 | } |
109 | |
105 | |
110 | /* Don't know of a portable call to get 64 bit random values. |
106 | /* Don't know of a portable call to get 64 bit random values. |
111 | * So make a call to get two 32 bit random numbers, and just to |
107 | * So make a call to get two 32 bit random numbers, and just to |
… | |
… | |
200 | } |
196 | } |
201 | |
197 | |
202 | /* decay and destroy persihable items in a map */ |
198 | /* decay and destroy persihable items in a map */ |
203 | |
199 | |
204 | void |
200 | void |
205 | decay_objects (mapstruct *m) |
201 | decay_objects (maptile *m) |
206 | { |
202 | { |
207 | int x, y, destroy; |
203 | int x, y, destroy; |
208 | object *op, *otmp; |
204 | object *op, *otmp; |
209 | |
205 | |
210 | if (m->unique) |
206 | if (m->unique) |
… | |
… | |
543 | strcpy (input, tmp); |
539 | strcpy (input, tmp); |
544 | |
540 | |
545 | return; |
541 | return; |
546 | } |
542 | } |
547 | |
543 | |
|
|
544 | ///////////////////////////////////////////////////////////////////////////// |
|
|
545 | |
|
|
546 | #if 0 |
|
|
547 | refcounted *refcounted::rc_first; |
|
|
548 | |
|
|
549 | refcounted::refcounted () |
|
|
550 | { |
|
|
551 | refcnt = 0; |
|
|
552 | rc_next = rc_first; |
|
|
553 | rc_first = this; |
|
|
554 | } |
|
|
555 | |
|
|
556 | refcounted::~refcounted () |
|
|
557 | { |
|
|
558 | assert (!rc_next); |
|
|
559 | assert (!refcnt); |
|
|
560 | } |
|
|
561 | #endif |
|
|
562 | |
548 | void *alloc (int s) throw (std::bad_alloc) |
563 | void *alloc (int s) throw (std::bad_alloc) |
549 | { |
564 | { |
550 | void *p = g_slice_alloc (s); |
565 | void *p = g_slice_alloc (s); |
551 | |
566 | |
552 | if (!p) |
567 | if (!p) |
… | |
… | |
577 | } |
592 | } |
578 | else |
593 | else |
579 | memcpy (dst, src, len + 1); |
594 | memcpy (dst, src, len + 1); |
580 | } |
595 | } |
581 | |
596 | |
|
|
597 | |