1 | /* |
1 | /* |
2 | * static char *rcsid_shop_c = |
2 | * static char *rcsid_shop_c = |
3 | * "$Id: shop.C,v 1.7 2006/08/29 10:51:43 elmex Exp $"; |
3 | * "$Id: shop.C,v 1.8 2006/09/03 00:18:42 root Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | /* |
6 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
7 | CrossFire, A Multiplayer game for X-windows |
8 | |
8 | |
… | |
… | |
137 | else |
137 | else |
138 | val = number * tmp->arch->clone.value / 3; |
138 | val = number * tmp->arch->clone.value / 3; |
139 | } |
139 | } |
140 | } |
140 | } |
141 | } else { /* No archetype with this object */ |
141 | } else { /* No archetype with this object */ |
142 | LOG(llevDebug,"In sell item: Have object with no archetype: %s\n", tmp->name); |
142 | LOG(llevDebug,"In sell item: Have object with no archetype: %s\n", &tmp->name); |
143 | if (flag == F_BUY) { |
143 | if (flag == F_BUY) { |
144 | LOG(llevError, "Asking for buy-value of unidentified object without arch.\n"); |
144 | LOG(llevError, "Asking for buy-value of unidentified object without arch.\n"); |
145 | val = number * tmp->value * 10; |
145 | val = number * tmp->value * 10; |
146 | } |
146 | } |
147 | else |
147 | else |
… | |
… | |
218 | if (idskill2 && find_skill_by_number(who,idskill2)) { |
218 | if (idskill2 && find_skill_by_number(who,idskill2)) { |
219 | lev_identify += find_skill_by_number(who,idskill2)->level; |
219 | lev_identify += find_skill_by_number(who,idskill2)->level; |
220 | } |
220 | } |
221 | } |
221 | } |
222 | } |
222 | } |
223 | else LOG(llevError, "Query_cost: item %s hasn't got a valid type\n", tmp->name); |
223 | else LOG(llevError, "Query_cost: item %s hasn't got a valid type\n", &tmp->name); |
224 | |
224 | |
225 | /* ratio determines how much of the price modification |
225 | /* ratio determines how much of the price modification |
226 | * will come from the basic stat charisma |
226 | * will come from the basic stat charisma |
227 | * the rest will come from the level in bargaining skill |
227 | * the rest will come from the level in bargaining skill |
228 | */ |
228 | */ |
… | |
… | |
351 | strcpy(buf,"an unimaginable sum of money"); |
351 | strcpy(buf,"an unimaginable sum of money"); |
352 | return buf; |
352 | return buf; |
353 | } |
353 | } |
354 | |
354 | |
355 | cost -= (uint64)num * (uint64)coin->clone.value; |
355 | cost -= (uint64)num * (uint64)coin->clone.value; |
356 | sprintf(buf, "%d %s", num, num > 1 ? coin->clone.name_pl : coin->clone.name); |
356 | sprintf(buf, "%d %s", num, num > 1 ? &coin->clone.name_pl : &coin->clone.name); |
357 | |
357 | |
358 | next_coin = find_next_coin(cost, &cointype); |
358 | next_coin = find_next_coin(cost, &cointype); |
359 | if (next_coin == NULL || approx) |
359 | if (next_coin == NULL || approx) |
360 | return buf; |
360 | return buf; |
361 | |
361 | |
362 | coin = next_coin; |
362 | coin = next_coin; |
363 | num = cost / coin->clone.value; |
363 | num = cost / coin->clone.value; |
364 | cost -= (uint64)num * (uint64)coin->clone.value; |
364 | cost -= (uint64)num * (uint64)coin->clone.value; |
365 | |
365 | |
366 | sprintf (buf + strlen (buf), " and %d %s", num, num > 1 ? coin->clone.name_pl : coin->clone.name); |
366 | sprintf (buf + strlen (buf), " and %d %s", num, num > 1 ? &coin->clone.name_pl : &coin->clone.name); |
367 | |
367 | |
368 | return buf; |
368 | return buf; |
369 | } |
369 | } |
370 | |
370 | |
371 | const char *query_cost_string(const object *tmp,object *who,int flag) { |
371 | const char *query_cost_string(const object *tmp,object *who,int flag) { |
… | |
… | |
395 | |
395 | |
396 | if (coin == NULL) return "nothing"; |
396 | if (coin == NULL) return "nothing"; |
397 | |
397 | |
398 | num = real_value / coin->clone.value; |
398 | num = real_value / coin->clone.value; |
399 | if (num == 1) |
399 | if (num == 1) |
400 | sprintf(buf, "about one %s", coin->clone.name); |
400 | sprintf(buf, "about one %s", &coin->clone.name); |
401 | else if (num < 5) |
401 | else if (num < 5) |
402 | sprintf(buf, "a few %s", coin->clone.name_pl); |
402 | sprintf(buf, "a few %s", &coin->clone.name_pl); |
403 | else if (num < 10) |
403 | else if (num < 10) |
404 | sprintf(buf, "several %s", coin->clone.name_pl); |
404 | sprintf(buf, "several %s", &coin->clone.name_pl); |
405 | else if (num < 25) |
405 | else if (num < 25) |
406 | sprintf(buf, "a moderate amount of %s", coin->clone.name_pl); |
406 | sprintf(buf, "a moderate amount of %s", &coin->clone.name_pl); |
407 | else if (num < 100) |
407 | else if (num < 100) |
408 | sprintf(buf, "lots of %s", coin->clone.name_pl); |
408 | sprintf(buf, "lots of %s", &coin->clone.name_pl); |
409 | else if (num < 1000) |
409 | else if (num < 1000) |
410 | sprintf(buf, "a great many %s", coin->clone.name_pl); |
410 | sprintf(buf, "a great many %s", &coin->clone.name_pl); |
411 | else |
411 | else |
412 | sprintf(buf, "a vast quantity of %s", coin->clone.name_pl); |
412 | sprintf(buf, "a vast quantity of %s", &coin->clone.name_pl); |
413 | return buf; |
413 | return buf; |
414 | } |
414 | } |
415 | } |
415 | } |
416 | } |
416 | } |
417 | |
417 | |
… | |
… | |
551 | |
551 | |
552 | /* This should not happen, but if it does, just * |
552 | /* This should not happen, but if it does, just * |
553 | * merge the two. */ |
553 | * merge the two. */ |
554 | if (coin_objs[i]!=NULL) { |
554 | if (coin_objs[i]!=NULL) { |
555 | LOG(llevError,"%s has two money entries of (%s)\n", |
555 | LOG(llevError,"%s has two money entries of (%s)\n", |
556 | pouch->name, coins[NUM_COINS-1-i]); |
556 | &pouch->name, coins[NUM_COINS-1-i]); |
557 | remove_ob(tmp); |
557 | remove_ob(tmp); |
558 | coin_objs[i]->nrof += tmp->nrof; |
558 | coin_objs[i]->nrof += tmp->nrof; |
559 | esrv_del_item(pl->contr, tmp->count); |
559 | esrv_del_item(pl->contr, tmp->count); |
560 | free_object(tmp); |
560 | free_object(tmp); |
561 | } |
561 | } |
… | |
… | |
566 | } |
566 | } |
567 | break; |
567 | break; |
568 | } |
568 | } |
569 | } |
569 | } |
570 | if (i==NUM_COINS) |
570 | if (i==NUM_COINS) |
571 | LOG(llevError,"in pay_for_item: Did not find string match for %s\n", tmp->arch->name); |
571 | LOG(llevError,"in pay_for_item: Did not find string match for %s\n", &tmp->arch->name); |
572 | } |
572 | } |
573 | } |
573 | } |
574 | |
574 | |
575 | /* Fill in any gaps in the coin_objs array - needed to make change. */ |
575 | /* Fill in any gaps in the coin_objs array - needed to make change. */ |
576 | /* Note that the coin_objs array goes from least value to greatest value */ |
576 | /* Note that the coin_objs array goes from least value to greatest value */ |
… | |
… | |
839 | { |
839 | { |
840 | LOG(llevDebug,"Object other than player tried to sell something.\n"); |
840 | LOG(llevDebug,"Object other than player tried to sell something.\n"); |
841 | return; |
841 | return; |
842 | } |
842 | } |
843 | |
843 | |
844 | if(op->custom_name) |
844 | op->custom_name = 0; |
845 | FREE_AND_CLEAR_STR (op->custom_name); |
|
|
846 | |
845 | |
847 | if(!amount) |
846 | if(!amount) |
848 | { |
847 | { |
849 | new_draw_info_format (NDI_UNIQUE, 0, pl, |
848 | new_draw_info_format (NDI_UNIQUE, 0, pl, |
850 | "We're not interested in %s.", query_name (op)); |
849 | "We're not interested in %s.", query_name (op)); |
… | |
… | |
968 | } |
967 | } |
969 | else |
968 | else |
970 | { |
969 | { |
971 | if (!who->map) |
970 | if (!who->map) |
972 | { |
971 | { |
973 | LOG(llevError, "value_limit: asked shop price for ob %s on NULL map\n", who->name); |
972 | LOG(llevError, "value_limit: asked shop price for ob %s on NULL map\n", &who->name); |
974 | return val; |
973 | return val; |
975 | } |
974 | } |
976 | |
975 | |
977 | map = who->map; |
976 | map = who->map; |
978 | |
977 | |