ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/utils.C
(Generate patch)

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.14 by root, Thu Sep 14 01:34:41 2006 UTC vs.
Revision 1.22 by root, Tue Dec 12 21:39:56 2006 UTC

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
204void 200void
205decay_objects (mapstruct *m) 201decay_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)
258 if (op->material & M_ICE && MAP_TEMP (m) > 32) 254 if (op->material & M_ICE && MAP_TEMP (m) > 32)
259 destroy = 1; 255 destroy = 1;
260 } 256 }
261 /* adjust overall chance below */ 257 /* adjust overall chance below */
262 if (destroy && rndm (0, 1)) 258 if (destroy && rndm (0, 1))
263 { 259 op->destroy ();
264 remove_ob (op);
265 free_object (op);
266 }
267 } 260 }
268} 261}
269 262
270/* convert materialname to materialtype_t */ 263/* convert materialname to materialtype_t */
271 264
545 return; 538 return;
546} 539}
547 540
548///////////////////////////////////////////////////////////////////////////// 541/////////////////////////////////////////////////////////////////////////////
549 542
543#if 0
544refcounted *refcounted::rc_first;
545
546refcounted::refcounted ()
547{
548 refcnt = 0;
549 rc_next = rc_first;
550 rc_first = this;
551}
552
553refcounted::~refcounted ()
554{
555 assert (!rc_next);
556 assert (!refcnt);
557}
558#endif
559
550void *alloc (int s) throw (std::bad_alloc) 560void *alloc (int s) throw (std::bad_alloc)
551{ 561{
552 void *p = g_slice_alloc (s); 562 void *p = g_slice_alloc (s);
553 563
554 if (!p) 564 if (!p)
579 } 589 }
580 else 590 else
581 memcpy (dst, src, len + 1); 591 memcpy (dst, src, len + 1);
582} 592}
583 593
594

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines