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

Comparing deliantra/server/common/item.C (file contents):
Revision 1.44 by root, Sun Apr 13 21:22:47 2008 UTC vs.
Revision 1.50 by root, Wed Apr 30 05:06:36 2008 UTC

1/* 1/*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG. 2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 * 3 *
4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team 4 * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (©) 1992,2007 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * Deliantra is free software: you can redistribute it and/or modify 8 * Deliantra is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
20 * 20 *
21 * The authors can be reached via e-mail to <support@deliantra.net> 21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */ 22 */
23 23
24#include <global.h> 24#include <global.h>
25#include <funcpoint.h>
26#include <living.h> 25#include <living.h>
27#include <spells.h> 26#include <spells.h>
28 27
29const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 }; 28const char *const coins[NUM_COINS + 1] = { "royalty", "platinacoin", "goldcoin", "silvercoin", 0 };
30 29
300 if (op->type == WEAPON) 299 if (op->type == WEAPON)
301 { 300 {
302 for (i = 1; i < NROFATTACKS; i++) 301 for (i = 1; i < NROFATTACKS; i++)
303 if (op->attacktype & (1 << i)) 302 if (op->attacktype & (1 << i))
304 enc++; 303 enc++;
304
305 if (op->slaying) 305 if (op->slaying)
306 enc += 2; /* What it slays is probably more relevent */ 306 enc += 2; /* What it slays is probably more relevent */
307 } 307 }
308
308 /* Items the player can equip */ 309 /* Items the player can equip */
309 if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) || 310 if ((op->type == WEAPON) || (op->type == ARMOUR) || (op->type == HELMET) ||
310 (op->type == SHIELD) || (op->type == RING) || 311 (op->type == SHIELD) || (op->type == RING) ||
311 (op->type == BOOTS) || (op->type == GLOVES) || 312 (op->type == BOOTS) || (op->type == GLOVES) ||
312 (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK)) 313 (op->type == AMULET) || (op->type == GIRDLE) || (op->type == BRACERS) || (op->type == CLOAK))
315 enc += op->stats.hp; /* hp regen */ 316 enc += op->stats.hp; /* hp regen */
316 enc += op->stats.sp; /* mana regen */ 317 enc += op->stats.sp; /* mana regen */
317 enc += op->stats.grace; /* grace regen */ 318 enc += op->stats.grace; /* grace regen */
318 enc += op->stats.exp; /* speed bonus */ 319 enc += op->stats.exp; /* speed bonus */
319 } 320 }
321
320 enc += op->stats.luck; 322 enc += op->stats.luck;
321 323
322 /* Do spell paths now */ 324 /* Do spell paths now */
323 for (i = 1; i < NRSPELLPATHS; i++) 325 for (i = 1; i < NRSPELLPATHS; i++)
324 { 326 {
356 int i; 358 int i;
357 359
358 for (i = 0; i < item_types_size; i++) 360 for (i = 0; i < item_types_size; i++)
359 if (item_types[i].number == itemtype) 361 if (item_types[i].number == itemtype)
360 return &item_types[i]; 362 return &item_types[i];
363
361 return NULL; 364 return NULL;
362} 365}
363 366
364/* returns the typedata that has a name equal to itemtype, if there 367/* returns the typedata that has a name equal to itemtype, if there
365 * isn't one, return the plural name that matches, if there still isn't 368 * isn't one, return the plural name that matches, if there still isn't
370 int i; 373 int i;
371 374
372 for (i = 0; i < item_types_size; i++) 375 for (i = 0; i < item_types_size; i++)
373 if (!strcmp (item_types[i].name, name)) 376 if (!strcmp (item_types[i].name, name))
374 return &item_types[i]; 377 return &item_types[i];
378
375 for (i = 0; i < item_types_size; i++) 379 for (i = 0; i < item_types_size; i++)
376 if (!strcmp (item_types[i].name_pl, name)) 380 if (!strcmp (item_types[i].name_pl, name))
377 { 381 {
378 LOG (llevInfo, 382 LOG (llevInfo,
379 "get_typedata_by_name: I have been sent the plural %s, the singular form %s is preffered\n", name, item_types[i].name); 383 "get_typedata_by_name: I have been sent the plural %s, the singular form %s is prefered\n", name, item_types[i].name);
380 return &item_types[i]; 384 return &item_types[i];
381 } 385 }
386
382 return NULL; 387 return NULL;
383} 388}
384 389
385/* describe_resistance generates the visible naming for resistances. 390/* describe_resistance generates the visible naming for resistances.
386 * returns a static array of the description. This can return 391 * returns a static array of the description. This can return
419 */ 424 */
420const char * 425const char *
421query_weight (const object *op) 426query_weight (const object *op)
422{ 427{
423 static char buf[10]; 428 static char buf[10];
424 sint32 i = (op->nrof ? op->nrof : 1) * op->weight + op->carrying; 429 sint32 i = op->total_weight ();
425 430
426 if (op->weight < 0) 431 if (op->weight < 0)
427 return " "; 432 return " ";
428 433
429 if (i % 1000) 434 if (i % 1000)
1194} 1199}
1195 1200
1196void 1201void
1197examine (object *op, object *tmp) 1202examine (object *op, object *tmp)
1198{ 1203{
1199 std::string s = tmp->describe (op); 1204 std::string info = tmp->describe (op);
1200 1205 op->contr->infobox (MSG_CHANNEL ("examine"), info.c_str ());
1201 new_draw_info (NDI_UNIQUE, 0, op, s.c_str ());
1202} 1206}
1203 1207
1204/* 1208/*
1205 * inventory prints object's inventory. If inv==NULL then print player's 1209 * inventory prints object's inventory. If inv==NULL then print player's
1206 * inventory. 1210 * inventory.
1358 * Supposed to fix face-values as well here, but later. 1362 * Supposed to fix face-values as well here, but later.
1359 */ 1363 */
1360void 1364void
1361identify (object *op) 1365identify (object *op)
1362{ 1366{
1363 object *pl;
1364
1365 SET_FLAG (op, FLAG_IDENTIFIED); 1367 SET_FLAG (op, FLAG_IDENTIFIED);
1366 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL); 1368 CLEAR_FLAG (op, FLAG_KNOWN_MAGICAL);
1367 CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT); 1369 CLEAR_FLAG (op, FLAG_NO_SKILL_IDENT);
1368 1370
1369 /* 1371 /*
1376 { 1378 {
1377 if (op->inv && op->randomitems) 1379 if (op->inv && op->randomitems)
1378 op->title = op->inv->name; 1380 op->title = op->inv->name;
1379 else if (op->arch) 1381 else if (op->arch)
1380 { 1382 {
1381 op->name = op->arch->object::name; 1383 op->name = op->arch->object::name;
1382 op->name_pl = op->arch->object::name_pl; 1384 op->name_pl = op->arch->object::name_pl;
1383 } 1385 }
1384 } 1386 }
1385 1387
1386 /* If the object is on a map, make sure we update its face */ 1388 /* If the object is on a map, make sure we update its face */
1387 if (op->map) 1389 if (op->map)
1388 update_object (op, UP_OBJ_CHANGE); 1390 update_object (op, UP_OBJ_CHANGE);
1389 else 1391
1390 { 1392 if (object *pl = op->visible_to ())
1391 pl = op->in_player ();
1392 if (pl)
1393 /* A lot of the values can change from an update - might as well send 1393 /* A lot of the values can change from an update - might as well send
1394 * it all. 1394 * it all.
1395 */ 1395 */
1396 esrv_send_item (pl, op); 1396 esrv_send_item (pl, op);
1397 }
1398} 1397}
1399 1398

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines