--- deliantra/server/server/player.C 2008/04/21 07:07:36 1.187 +++ deliantra/server/server/player.C 2008/04/30 06:40:28 1.192 @@ -1,7 +1,7 @@ /* * This file is part of Deliantra, the Roguelike Realtime MMORPG. * - * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team + * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team * Copyright (©) 1992,2007 Frank Tore Johansen * @@ -241,7 +241,7 @@ new_draw_info (NDI_UNIQUE, 0, ob, "Welcome Back!"); - esrv_new_player (this, ob->weight + ob->carrying); + esrv_new_player (this); ob->update_stats (); @@ -293,10 +293,10 @@ ob = observe = op; ob->contr = this; /* this aren't yet in archetype */ - ob->speed = 1.0f; - ob->speed_left = 0.5f; + ob->speed = 1.0f; + ob->speed_left = 0.5f; - ob->direction = 5; /* So player faces south */ + ob->direction = 5; /* So player faces south */ ob->flag [FLAG_READY_WEAPON] = false; ob->flag [FLAG_READY_SKILL] = false; @@ -853,7 +853,7 @@ player::chargen_race_done () { /* this must before then initial items are given */ - esrv_new_player (ob->contr, ob->weight + ob->carrying); + esrv_new_player (ob->contr); treasurelist *tl = treasurelist::find ("starting_wealth"); if (tl) @@ -1407,7 +1407,7 @@ else if (arrow->type == ARROW && arrow->race == type) { /* allways prefer assasination/slaying */ - if (target->race != NULL && arrow->slaying != NULL && strstr (arrow->slaying, target->race)) + if (target->race && arrow->slaying && strstr (arrow->slaying, target->race)) { if (arrow->attacktype & AT_DEATH) { @@ -1765,7 +1765,11 @@ } else if (item->type == ROD || item->type == HORN) { - if (item->stats.hp < MAX (item->inv->stats.sp, item->inv->stats.grace)) + sint16 spell_sp = MAX (item->inv->stats.sp, item->inv->stats.grace); + + // using the maximum of the rods charge allows at least one spell cast + // for a rod or horn, this fixes some broken rods. + if (item->stats.hp < MIN (spell_sp, item->stats.maxhp)) { op->contr->play_sound (sound_find ("wand_poof")); @@ -1794,8 +1798,8 @@ item->set_speed (0); } - if ((tmp = item->in_player ())) - esrv_update_item (UPD_ANIM, tmp, item); + if (object *pl = item->visible_to ()) + esrv_update_item (UPD_ANIM, pl, item); } } else if (item->type == ROD || item->type == HORN) @@ -1982,9 +1986,6 @@ /* Do this after we print the message */ key->decrease (); /* Use up one of the keys */ - /* Need to update the weight the container the key was in */ - if (container != op) - esrv_update_item (UPD_WEIGHT, op, container); return 1; /* Nothing more to do below */ } @@ -2273,9 +2274,6 @@ op->play_sound (sound_find ("ob_evaporate")); new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s vibrates violently, then evaporates.", query_name (tmp)); - if (op->contr) - esrv_del_item (op->contr, tmp->count); - tmp->destroy (); CLEAR_FLAG (op, FLAG_LIFESAVE); @@ -2297,7 +2295,7 @@ /* This goes throws the inventory and removes unpaid objects, and puts them * back in the map (location and map determined by values of env). This - * function will descend into containers. op is the object to start the search + * function will descend into containers. op is the object to start the search * from. */ static void @@ -2308,12 +2306,7 @@ object *next = op->below; /* Make sure we have a good value, in case we remove object 'op' */ if (QUERY_FLAG (op, FLAG_UNPAID)) - { - if (env->type == PLAYER) - esrv_del_item (env->contr, op->count); - - op->insert_at (env); - } + op->insert_at (env); else if (op->inv) drop_unpaid_items (op->inv, env); @@ -2335,40 +2328,34 @@ * best, a misc file for object actions is probably better, * but there isn't one in the server directory. */ -char * +const char * gravestone_text (object *op) { - static char buf2[MAX_BUF]; - char buf[MAX_BUF]; - time_t now = time (NULL); + static dynbuf_text buf; - strcpy (buf2, " R.I.P.\n\n"); - if (op->type == PLAYER) - sprintf (buf, "%s the %s\n", &op->name, op->contr->title); - else - sprintf (buf, "%s\n", &op->name); + buf << "---- R.I.P. ----\n\n"; + op->name; - strncat (buf2, " ", 20 - strlen (buf) / 2); - strcat (buf2, buf); if (op->type == PLAYER) - sprintf (buf, "who was in level %d when killed\n", op->level); - else - sprintf (buf, "who was in level %d when died.\n\n", op->level); + buf << " the " << op->contr->title; + + buf << "\n\n"; + + buf << "who was level "; + buf << (sint32)op->level << "\n\n" // OO breakdown + << " when " << (op->contr ? "killed" : "died") << "\n\n"; - strncat (buf2, " ", 20 - strlen (buf) / 2); - strcat (buf2, buf); if (op->type == PLAYER) - { - sprintf (buf, "by %s.\n\n", op->contr->killer); - strncat (buf2, " ", 21 - strlen (buf) / 2); - strcat (buf2, buf); - } + buf << "by " << op->contr->killer_name () << ".\n\n"; - strftime (buf, MAX_BUF, "%b %d %Y\n", localtime (&now)); - strncat (buf2, " ", 20 - strlen (buf) / 2); - strcat (buf2, buf); + { + static char buf2[128]; + time_t now = time (NULL); + strftime (buf2, 128, "%b %d %Y\n\n", localtime (&now)); + buf << buf2; + } - return buf2; + return buf; } void @@ -2652,7 +2639,9 @@ tmp->name_pl = format ("%s's fingers", &op->name); tmp->msg = format ( "This finger has been cut off of %s the %s, when he was defeated at level %d by %s.\n", - &op->name, op->contr->title, (int) (op->level), op->contr->killer + &op->name, op->contr->title, + (int)op->level, + op->contr->killer_name () ); tmp->value = 0, tmp->type = 0; tmp->materialname = "organics"; @@ -2670,7 +2659,10 @@ command_kill_pets (op, 0); if (op->stats.food < 0) - strcpy (op->contr->killer, "starvation"); + { + op->contr->killer = archetype::get ("killer_starvation"); + op->contr->killer->destroy (); + } op->contr->play_sound (sound_find ("player_dies")); @@ -2813,7 +2805,7 @@ tmp->name = buf; sprintf (buf, "%s's gravestones", &op->name); tmp->name_pl = buf; - sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer); + sprintf (buf, "RIP\nHere rests the hero %s the %s,\n" "who was killed\n" "by %s.\n", &op->name, op->contr->title, op->contr->killer_name ()); tmp->msg = buf; tmp->x = op->x, tmp->y = op->y; insert_ob_in_map (tmp, op->map, NULL, 0); @@ -3457,9 +3449,7 @@ /* generate misc. treasure */ tmp = arch_to_object (tr->item); new_draw_info_format (NDI_UNIQUE | NDI_BLUE, 0, who, "You gained %s", query_short_name (tmp)); - tmp = insert_ob_in_ob (tmp, who); - if (who->type == PLAYER) - esrv_send_item (who, tmp); + who->insert (tmp); } }