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

Comparing deliantra/server/common/object.C (file contents):
Revision 1.141 by root, Sun Apr 29 21:44:34 2007 UTC vs.
Revision 1.146 by root, Fri May 11 21:07:13 2007 UTC

29#include <stdio.h> 29#include <stdio.h>
30#include <sys/types.h> 30#include <sys/types.h>
31#include <sys/uio.h> 31#include <sys/uio.h>
32#include <object.h> 32#include <object.h>
33#include <funcpoint.h> 33#include <funcpoint.h>
34#include <sproto.h>
34#include <loader.h> 35#include <loader.h>
35 36
36#include <bitset> 37#include <bitset>
37 38
38int nrofallocobjects = 0; 39int nrofallocobjects = 0;
313 314
314 /* Everything passes, must be OK. */ 315 /* Everything passes, must be OK. */
315 return 1; 316 return 1;
316} 317}
317 318
318void
319player::set_range (rangetype r)
320{
321 shoottype = r;
322}
323
324/* 319/*
325 * sum_weight() is a recursive function which calculates the weight 320 * sum_weight() is a recursive function which calculates the weight
326 * an object is carrying. It goes through in figures out how much 321 * an object is carrying. It goes through in figures out how much
327 * containers are carrying, and sums it up. 322 * containers are carrying, and sums it up.
328 */ 323 */
330sum_weight (object *op) 325sum_weight (object *op)
331{ 326{
332 long sum; 327 long sum;
333 object *inv; 328 object *inv;
334 329
335 for (sum = 0, inv = op->inv; inv != NULL; inv = inv->below) 330 for (sum = 0, inv = op->inv; inv; inv = inv->below)
336 { 331 {
337 if (inv->inv) 332 if (inv->inv)
338 sum_weight (inv); 333 sum_weight (inv);
334
339 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1); 335 sum += inv->carrying + inv->weight * (inv->nrof ? inv->nrof : 1);
340 } 336 }
341 337
342 if (op->type == CONTAINER && op->stats.Str) 338 if (op->type == CONTAINER && op->stats.Str)
343 sum = (sum * (100 - op->stats.Str)) / 100; 339 sum = (sum * (100 - op->stats.Str)) / 100;
452 */ 448 */
453 while (owner->owner) 449 while (owner->owner)
454 owner = owner->owner; 450 owner = owner->owner;
455 451
456 this->owner = owner; 452 this->owner = owner;
453}
454
455void
456object::set_weapon (object *ob)
457{
458 if (current_weapon == ob)
459 return;
460
461 new_draw_info_format (NDI_UNIQUE, 0, this, "You switch to your %s.", &ob->name);
462
463 if (chosen_skill)
464 chosen_skill->flag [FLAG_APPLIED] = false;
465
466 current_weapon = ob;
467 chosen_skill = ob->type == SKILL ? ob : find_skill_by_name (this, ob->skill);
468
469 if (chosen_skill)
470 chosen_skill->flag [FLAG_APPLIED] = true;
471
472 update_stats ();
457} 473}
458 474
459/* Zero the key_values on op, decrementing the shared-string 475/* Zero the key_values on op, decrementing the shared-string
460 * refcounts and freeing the links. 476 * refcounts and freeing the links.
461 */ 477 */
543 * need for monsters, but doesn't hurt to do it for everything. 559 * need for monsters, but doesn't hurt to do it for everything.
544 * by doing so, when a monster is created, it has good starting 560 * by doing so, when a monster is created, it has good starting
545 * values for the body_used info, so when items are created 561 * values for the body_used info, so when items are created
546 * for it, they can be properly equipped. 562 * for it, they can be properly equipped.
547 */ 563 */
548 memcpy (body_used, body_info, sizeof (body_used)); 564 for (int i = NUM_BODY_LOCATIONS; i--; )
565 slot[i].used = slot[i].info;
549 566
550 attachable::instantiate (); 567 attachable::instantiate ();
551} 568}
552 569
553object * 570object *
2589} 2606}
2590 2607
2591const char * 2608const char *
2592object::debug_desc () const 2609object::debug_desc () const
2593{ 2610{
2594 static char info[256 * 4]; 2611 static char info[3][256 * 4];
2612 static int info_idx;
2613
2595 return debug_desc (info); 2614 return debug_desc (info [++info_idx % 3]);
2596}
2597
2598const char *
2599object::debug_desc2 () const
2600{
2601 static char info[256 * 4];
2602 return debug_desc (info);
2603} 2615}
2604 2616
2605struct region * 2617struct region *
2606object::region () const 2618object::region () const
2607{ 2619{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines