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

Comparing deliantra/server/server/player.C (file contents):
Revision 1.182 by root, Thu Apr 17 14:06:03 2008 UTC vs.
Revision 1.187 by root, Mon Apr 21 07:07:36 2008 UTC

215 215
216 /* make sure he's a player -- needed because of class change. */ 216 /* make sure he's a player -- needed because of class change. */
217 ob->type = PLAYER; // we are paranoid 217 ob->type = PLAYER; // we are paranoid
218 ob->race = ob->arch->race; 218 ob->race = ob->arch->race;
219 219
220 ob->carrying = sum_weight (ob); 220 ob->update_weight ();
221 link_player_skills (ob); 221 link_player_skills (ob);
222 222
223 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER); 223 CLEAR_FLAG (ob, FLAG_NO_FIX_PLAYER);
224 224
225 assign (title, ob->arch->object::name); 225 assign (title, ob->arch->object::name);
404 * Note: there MUST be at least one player archetype! 404 * Note: there MUST be at least one player archetype!
405 */ 405 */
406archetype * 406archetype *
407get_player_archetype (archetype *at) 407get_player_archetype (archetype *at)
408{ 408{
409 // archetypes could have been reloaded
410 archetype *nat = at ? archetype::find (at->archname) : archetypes [0];
411
412 if (!nat)
413 return at;
414
409 archvec::iterator i = at ? archetypes.find (at) : archetypes.begin (); 415 archvec::iterator i = archetypes.find (nat);
410 416
411 for (;;) 417 for (;;)
412 { 418 {
413 if (++i == archetypes.end ()) 419 if (++i == archetypes.end ())
414 i = archetypes.begin (); 420 i = archetypes.begin ();
1597 arrow->destroy (); 1603 arrow->destroy ();
1598 return 0; 1604 return 0;
1599 } 1605 }
1600 1606
1601 left = arrow; /* these are arrows left to the player */ 1607 left = arrow; /* these are arrows left to the player */
1602 arrow = get_split_ob (arrow, 1); 1608 arrow = arrow->split ();
1603 if (!arrow) 1609 if (!arrow)
1604 { 1610 {
1605 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race); 1611 new_draw_info_format (NDI_UNIQUE, 0, op, "You have no %s left.", &bow->race);
1606 return 0; 1612 return 0;
1607 } 1613 }
1674 op->play_sound (sound_find ("fire_arrow")); 1680 op->play_sound (sound_find ("fire_arrow"));
1675 m->insert (arrow, sx, sy, op); 1681 m->insert (arrow, sx, sy, op);
1676 1682
1677 if (!arrow->destroyed ()) 1683 if (!arrow->destroyed ())
1678 move_arrow (arrow); 1684 move_arrow (arrow);
1679
1680 if (op->type == PLAYER)
1681 {
1682 if (left->destroyed ())
1683 esrv_del_item (op->contr, left->count);
1684 else
1685 esrv_send_item (op, left);
1686 }
1687 1685
1688 return 1; 1686 return 1;
1689} 1687}
1690 1688
1691/* Special fire code for players - this takes into 1689/* Special fire code for players - this takes into
1981 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN); 1979 op->statusmsg (format ("You open the door with the %s", query_short_name (key)), NDI_BROWN);
1982 remove_door2 (door); /* remove door without violence ;-) */ 1980 remove_door2 (door); /* remove door without violence ;-) */
1983 } 1981 }
1984 1982
1985 /* Do this after we print the message */ 1983 /* Do this after we print the message */
1986 decrease_ob (key); /* Use up one of the keys */ 1984 key->decrease (); /* Use up one of the keys */
1987 /* Need to update the weight the container the key was in */ 1985 /* Need to update the weight the container the key was in */
1988 if (container != op) 1986 if (container != op)
1989 esrv_update_item (UPD_WEIGHT, op, container); 1987 esrv_update_item (UPD_WEIGHT, op, container);
1990 1988
1991 return 1; /* Nothing more to do below */ 1989 return 1; /* Nothing more to do below */
2928 2926
2929 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3)))) 2927 if (!QUERY_FLAG (tmp, FLAG_UNIQUE) && (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || QUERY_FLAG (tmp, FLAG_NO_DROP) || !(rndm (3))))
2930 { 2928 {
2931 if (tmp->nrof > 1) 2929 if (tmp->nrof > 1)
2932 { 2930 {
2933 tmp2 = get_split_ob (tmp, 1 + RANDOM () % (tmp->nrof - 1)); 2931 tmp->decrease (rndm (1, tmp->nrof - 1));
2934 tmp2->destroy ();
2935 insert_ob_in_map (tmp, op->map, NULL, 0); 2932 insert_ob_in_map (tmp, op->map, NULL, 0);
2936 } 2933 }
2937 else 2934 else
2938 tmp->destroy (); 2935 tmp->destroy ();
2939 } 2936 }
2950void 2947void
2951fix_weight (void) 2948fix_weight (void)
2952{ 2949{
2953 for_all_players (pl) 2950 for_all_players (pl)
2954 { 2951 {
2955 int old = pl->ob->carrying, sum = sum_weight (pl->ob); 2952 sint32 old = pl->ob->carrying;
2956 2953
2957 if (old == sum) 2954 pl->ob->update_weight ();
2958 continue; 2955
2956 if (old != pl->ob->carrying)
2957 {
2959 pl->ob->update_stats (); 2958 pl->ob->update_stats ();
2960 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, old, sum); 2959 LOG (llevDebug, "Fixed inventory in %s (%d -> %d)\n", &pl->ob->name, (int)old, (int)pl->ob->carrying);
2960 }
2961 } 2961 }
2962} 2962}
2963 2963
2964void 2964void
2965fix_luck (void) 2965fix_luck (void)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines