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.60 by root, Sun Jul 1 05:00:18 2007 UTC vs.
Revision 1.63 by root, Mon Aug 6 10:54:11 2007 UTC

36#include <funcpoint.h> 36#include <funcpoint.h>
37#include <material.h> 37#include <material.h>
38 38
39#include <glib.h> 39#include <glib.h>
40 40
41refcnt_base::refcnt_t refcnt_dummy;
42
41rand_gen rndm; 43rand_gen rndm;
42 44
43void 45void
44tausworthe_random_generator::seed (uint32_t seed) 46tausworthe_random_generator::seed (uint32_t seed)
45{ 47{
212{ 214{
213 for (materialtype_t *mt = materialt; mt && mt->next; mt = mt->next) 215 for (materialtype_t *mt = materialt; mt && mt->next; mt = mt->next)
214 if (name == mt->name) 216 if (name == mt->name)
215 return mt; 217 return mt;
216 218
217 return materialt; 219 return 0;
218} 220}
219 221
220/* when doing transmutation of objects, we have to recheck the resistances, 222/* when doing transmutation of objects, we have to recheck the resistances,
221 * as some that did not apply previously, may apply now. 223 * as some that did not apply previously, may apply now.
222 */ 224 */
258void 260void
259set_materialname (object *op, int difficulty, materialtype_t *nmt) 261set_materialname (object *op, int difficulty, materialtype_t *nmt)
260{ 262{
261 materialtype_t *mt, *lmt; 263 materialtype_t *mt, *lmt;
262 264
263#ifdef NEW_MATERIAL_CODE
264 int j;
265#endif
266
267 if (op->materialname != NULL) 265 if (op->materialname != NULL)
268 return; 266 return;
269 267
270
271
272 if (nmt == NULL) 268 if (nmt == NULL)
273 { 269 {
274 lmt = NULL; 270 lmt = NULL;
275#ifndef NEW_MATERIAL_CODE 271
276 for (mt = materialt; mt && mt->next; mt = mt->next) 272 for (mt = materialt; mt && mt->next; mt = mt->next)
277 { 273 if (op->materials & mt->material && rndm (1, 100) <= mt->chance &&
278 if (op->materials & mt->material) 274 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0))
279 { 275 {
280 lmt = mt; 276 lmt = mt;
277 if (!(op->is_weapon () || op->is_armor ()))
281 break; 278 break;
282 } 279 }
283 }
284
285#else
286 for (mt = materialt; mt && mt->next; mt = mt->next)
287 {
288 if (op->materials & mt->material && rndm (1, 100) <= mt->chance &&
289 difficulty >= mt->difficulty && (op->magic >= mt->magic || mt->magic == 0))
290 {
291 lmt = mt;
292 if (!(op->is_weapon () || op->is_armor ()))
293 break;
294 }
295 }
296#endif
297 } 280 }
298 else 281 else
299 {
300 lmt = nmt; 282 lmt = nmt;
301 }
302 283
303 if (lmt != NULL) 284 if (lmt != NULL)
304 { 285 {
305#ifndef NEW_MATERIAL_CODE
306 op->materialname = lmt->name;
307 return;
308#else
309
310 if (op->stats.dam && op->is_weapon ()) 286 if (op->stats.dam && op->is_weapon ())
311 { 287 {
312 op->stats.dam += lmt->damage; 288 op->stats.dam += lmt->damage;
313 if (op->stats.dam < 1) 289 if (op->stats.dam < 1)
314 op->stats.dam = 1; 290 op->stats.dam = 1;
320 op->stats.wc += lmt->wc; 296 op->stats.wc += lmt->wc;
321 if (op->is_armor ()) 297 if (op->is_armor ())
322 { 298 {
323 if (op->stats.ac) 299 if (op->stats.ac)
324 op->stats.ac += lmt->ac; 300 op->stats.ac += lmt->ac;
301
325 for (j = 0; j < NROFATTACKS; j++) 302 for (int j = 0; j < NROFATTACKS; j++)
326 if (op->resist[j] != 0) 303 if (op->resist[j] != 0)
327 { 304 {
328 op->resist[j] += lmt->mod[j]; 305 op->resist[j] += lmt->mod[j];
329 if (op->resist[j] > 100) 306 if (op->resist[j] > 100)
330 op->resist[j] = 100; 307 op->resist[j] = 100;
331 if (op->resist[j] < -100) 308 if (op->resist[j] < -100)
332 op->resist[j] = -100; 309 op->resist[j] = -100;
333 } 310 }
334 } 311 }
312
335 op->materialname = lmt->name; 313 op->materialname = lmt->name;
336 /* dont make it unstackable if it doesn't need to be */ 314 /* dont make it unstackable if it doesn't need to be */
337 if (op->is_weapon () || op->is_armor ()) 315 if (op->is_weapon () || op->is_armor ())
338 { 316 {
339 op->weight = (op->weight * lmt->weight) / 100; 317 op->weight = (op->weight * lmt->weight) / 100;
340 op->value = (op->value * lmt->value) / 100; 318 op->value = (op->value * lmt->value) / 100;
341 } 319 }
342#endif
343 } 320 }
344} 321}
345 322
346/* 323/*
347 * Strip out the media tags from a String. 324 * Strip out the media tags from a String.
653 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 630 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
654 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 631 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
655 0x2d02ef8dL 632 0x2d02ef8dL
656}; 633};
657 634
635#if 0
636void xyzzy (object_ptr &a, object_ptr &o)
637{
638 asm volatile ("int3");
639 a = o;
640 asm volatile ("int3");
641}
642#endif
658 643

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines