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

Comparing deliantra/server/server/shop.C (file contents):
Revision 1.23 by root, Thu Dec 14 22:45:41 2006 UTC vs.
Revision 1.29 by pippijn, Sat Jan 6 14:42:31 2007 UTC

1/* 1/*
2 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
3 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
4 Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2002 Mark Wedel & Crossfire Development Team
5 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
6 7
7 This program is free software; you can redistribute it and/or modify 8 This program is free software; you can redistribute it and/or modify
8 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
23 24
24#include <global.h> 25#include <global.h>
25#include <spells.h> 26#include <spells.h>
26#include <skills.h> 27#include <skills.h>
27#include <living.h> 28#include <living.h>
28#include <newclient.h>
29#ifndef __CEXTRACT__
30# include <sproto.h> 29#include <sproto.h>
31#endif
32#include <math.h> 30#include <math.h>
33 31
34/* this is a measure of how effective store specialisation is. A general store 32/* this is a measure of how effective store specialisation is. A general store
35 * will offer this proportion of the 'maximum' price, a specialised store will 33 * will offer this proportion of the 'maximum' price, a specialised store will
36 * offer a range of prices around it such that the maximum price is always one 34 * offer a range of prices around it such that the maximum price is always one
505 503
506 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) 504 for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below)
507 if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold"))) 505 if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold")))
508 pay_from_container (pl, pouch, to_pay); 506 pay_from_container (pl, pouch, to_pay);
509 507
510 fix_player (pl); 508 pl->update_stats ();
511 return 1; 509 return 1;
512} 510}
513 511
514/* DAMN: This is now a wrapper for pay_from_container, which is 512/* DAMN: This is now a wrapper for pay_from_container, which is
515 * called for the player, then for each active container that can hold 513 * called for the player, then for each active container that can hold
545 pay_from_container (pl, pouch, to_pay); 543 pay_from_container (pl, pouch, to_pay);
546 544
547 if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ)) 545 if (settings.real_wiz == FALSE && QUERY_FLAG (pl, FLAG_WAS_WIZ))
548 SET_FLAG (op, FLAG_WAS_WIZ); 546 SET_FLAG (op, FLAG_WAS_WIZ);
549 547
550 fix_player (pl); 548 pl->update_stats ();
551 return 1; 549 return 1;
552} 550}
553 551
554/* This pays for the item, and takes the proper amount of money off 552/* This pays for the item, and takes the proper amount of money off
555 * the player. 553 * the player.
933 double ratio = SPECIALISATION_EFFECT, likedness = 0.001; 931 double ratio = SPECIALISATION_EFFECT, likedness = 0.001;
934 int i; 932 int i;
935 933
936 if (item == NULL) 934 if (item == NULL)
937 { 935 {
938 LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", map->path); 936 LOG (llevError, "shop_specialisation_ratio: passed a NULL item for map %s\n", &map->path);
939 return 0; 937 return 0;
940 } 938 }
941 939
942 if (!item->type) 940 if (!item->type)
943 { 941 {
956 likedness = items[i].strength / 100.0; 954 likedness = items[i].strength / 100.0;
957 } 955 }
958 956
959 if (likedness > 1.0) 957 if (likedness > 1.0)
960 { /* someone has been rather silly with the map headers. */ 958 { /* someone has been rather silly with the map headers. */
961 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, map->path); 959 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is above 100%%\n", item->type, &map->path);
962 likedness = 1.0; 960 likedness = 1.0;
963 } 961 }
964 962
965 if (likedness < -1.0) 963 if (likedness < -1.0)
966 { 964 {
967 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, map->path); 965 LOG (llevDebug, "shop_specialisation ratio: item type %d on map %s is below -100%%\n", item->type, &map->path);
968 likedness = -1.0; 966 likedness = -1.0;
969 } 967 }
970 968
971 ratio = ratio + (1.0 - ratio) * likedness; 969 ratio = ratio + (1.0 - ratio) * likedness;
972 970
1213 magic_mapping_mark (op, map_mark, 3); 1211 magic_mapping_mark (op, map_mark, 3);
1214 items = (shopinv *) malloc (40 * sizeof (shopinv)); 1212 items = (shopinv *) malloc (40 * sizeof (shopinv));
1215 numallocated = 40; 1213 numallocated = 40;
1216 1214
1217 /* Find all the appropriate items */ 1215 /* Find all the appropriate items */
1218 for (i = 0; i < MAP_WIDTH (op->map); i++) 1216 for (i = 0; i < op->map->width; i++)
1219 { 1217 {
1220 for (j = 0; j < MAP_HEIGHT (op->map); j++) 1218 for (j = 0; j < op->map->height; j++)
1221 { 1219 {
1222 /* magic map code now centers the map on the object at MAGIC_MAP_HALF. 1220 /* magic map code now centers the map on the object at MAGIC_MAP_HALF.
1223 * 1221 *
1224 */ 1222 */
1225 nx = i - op->x + MAGIC_MAP_HALF; 1223 nx = i - op->x + MAGIC_MAP_HALF;
1228 if (nx < 0 || ny < 0 || nx > MAGIC_MAP_SIZE || ny > MAGIC_MAP_SIZE) 1226 if (nx < 0 || ny < 0 || nx > MAGIC_MAP_SIZE || ny > MAGIC_MAP_SIZE)
1229 continue; 1227 continue;
1230 1228
1231 if (map_mark[nx + MAGIC_MAP_SIZE * ny] & FACE_FLOOR) 1229 if (map_mark[nx + MAGIC_MAP_SIZE * ny] & FACE_FLOOR)
1232 { 1230 {
1233 stack = get_map_ob (op->map, i, j); 1231 stack = GET_MAP_OB (op->map, i, j);
1234 1232
1235 while (stack) 1233 while (stack)
1236 { 1234 {
1237 if (QUERY_FLAG (stack, FLAG_UNPAID)) 1235 if (QUERY_FLAG (stack, FLAG_UNPAID))
1238 { 1236 {
1292 1290
1293/* elmex: this function checks whether we are in a shop or not */ 1291/* elmex: this function checks whether we are in a shop or not */
1294bool 1292bool
1295is_in_shop (maptile *map, int x, int y) 1293is_in_shop (maptile *map, int x, int y)
1296{ 1294{
1297 for (object *floor = get_map_ob (map, x, y); floor; floor = floor->above) 1295 for (object *floor = GET_MAP_OB (map, x, y); floor; floor = floor->above)
1298 if (floor->type == SHOP_FLOOR) 1296 if (floor->type == SHOP_FLOOR)
1299 return true; 1297 return true;
1300 1298
1301 return false; 1299 return false;
1302} 1300}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines