Commit Graph

113 Commits

Author SHA1 Message Date
nhmall
3198c3bf79 shk segfault diagnostic workaround but not fix
Changes to be committed:
	modified:   src/shk.c
2016-01-03 11:33:03 -05:00
Pasi Kallinen
cdde5b76c9 Some shopkeepers are always stingier
This prevents the "drop the item few times, just to see if
the sell price changes"
2015-12-22 21:44:59 +02:00
PatR
40ad82ed77 fix #H4105 - credit cloning
Putting gold into a hero-owned container on a shop's floot gave credit
for the amount of the gold but also set the gold object no_charge, so
it could be taken out without taking away the credit.  Then put back
in and taken out as many times as the player liked, doubling the gold
each time until the shopkeeper was out of cash.

I think the proper fix would be to avoid giving credit instead of not
marking the gold no_charge, but that would require multiple additional
changes so I took the easy way out.

Most of the changes to pickup.c are reformatting that it escaped prior
to release.  The changes to shk.c are cosmetic and not part of the fix.
2015-12-20 01:44:19 -08:00
PatR
449084fa6c eliminate implicit concatenation of strings
Explicitly combine adjacent string literals so that pre-ANSI compilers
still have a chance to compile the code.  I thought these had already
been dealt with, but I kept stumbling across them while reformatting,
so am trying to get them all out of the way now.
2015-11-06 15:57:23 -08:00
PatR
ea8afe7e24 formatting - last of the trailing continuations
Last few && or || followed by end-of-line comments, plus tab replacement
and 'return' parentheses.  Not as many of those; some of these files had
already had that done.

Also, tweaked non-cursed scroll of charging read while confused to be a
tiny bit more effective.

To do:  find and fix block comments that immediately follow a line with
an end-of-line comment and got misindented to line up with that comment.
2015-11-05 00:54:13 -08:00
PatR
bb09cab067 formatting: src/r*.c - src/s*.c continuation lines 2015-10-26 17:49:40 -07:00
Pasi Kallinen
af1c77808b Comment typofixes, pt 4 2015-10-17 18:47:31 +03:00
Pasi Kallinen
66dd87454b Comment typofixes, pt 3 2015-10-17 13:47:25 +03:00
PatR
24b4872e2f get_cost_from_price
I couldn't figure out why walking over a container in a shop might
give the wrong price; the code looks correct.  But I've reorganized
get_cost_from_price to perform the cheapest tests first.  The u.ushops
check should probably be done in doname to avoid calling this routine
at all 99.99% of the time.
2015-05-30 18:22:14 -07:00
Pasi Kallinen
2944dc6935 Show cost of merchandise when walking over it
This is another feature the betatesters seemed to miss a lot.
2015-05-27 21:45:00 +03:00
Sean Hunt
1c081b1647 Remove stale version control lines. 2015-05-25 09:21:31 +09:00
Sean Hunt
97d6fade74 Reformat all C files.
I'll push a formatting guide at some point. There may still be
outstanding changes, but please feel free to resolve those as you arrive
a them.

To the best of my knowledge, there is no changes to the actual code
content, but the formatter does have the occasional bug. If you run into
an issue, please fix it!
2015-05-09 13:43:16 -04:00
karnov
2a907f894e Version number increment 2015-05-06 22:04:27 -04:00
Pasi Kallinen
5479a0b44c Also allow q at the Itemized billing -prompt
Original change via AceHack by Alex Smith
2015-04-25 12:56:55 +03:00
Pasi Kallinen
aea472c0c0 Give honorifics to vampires and elves 2015-04-23 21:46:10 +03:00
PatR
14525ed0c6 DEBUG/debugpline() fixup
* Replace variadic debugpline() with fixed argument debugpline0(str),
   debugpline1(fmt,arg), and so on so that C99 support isn't required;
 * showdebug() becomes a function rather than a macro and handles a
   bit more;
 * two debugpline() calls in light.c have been changed to impossible();
 * DEBUGFILES macro (in sys.c) can substitute for SYSCF's DEBUGFILES
   setting in !SYSCF configuration (I hope that's temporary).
2015-03-15 18:02:26 -07:00
Pasi Kallinen
612852f7de Apply paxed's DEBUG patch to remove DEBUG/D_DEBUG.
Move debugging output into couple preprocessor defines, which
    are no-op without DEBUG.  To show debugging output from a
    certain source files, use sysconf:

    DEBUGFILES=dungeon.c questpgr.c

    Also fix couple debug lines which did not compile.

This also includes fixes due to Derek Ray to depugpline to work better
on other platforms.
2015-02-27 19:33:45 -05:00
Sean Hunt
ac108cd365 Make GOLDOBJ unconditional. 2015-02-27 19:33:40 -05:00
Sean Hunt
260f7ea860 Make TOURIST unconditional. 2015-02-27 19:33:12 -05:00
Sean Hunt
b066b7c170 Make KOPS unconditional. 2015-02-27 19:33:04 -05:00
Sean Hunt
9e65758947 Make STEED unconditional. 2015-02-27 19:33:01 -05:00
keni
03140969ee Bulk recovery of file CVS headers and addition of NHDT- headers. 2015-02-26 09:19:03 -05:00
nethack.rankin
d356779195 fix #H2671 - feedback when entering untended shop while blind
From a bug report, you get the message "this shop
appears to be deserted" when entering a shop whose shopkeeper is not there,
even if you can't see at the time.  Change it to be
 'this shop is deserted'
     when you can see that the shop is empty,
 'this shop is untended'
     when there's no shopkeeper but you can see some other monster(s) inside,
 'this shop seems to be deserted'
     when you can see but there is a monster that you can't see (probably a
     hidden mimic, but possibly an invisible monster or one standing behind
     a boulder that's ended up in the shop), or
 'this shop seems to be untended'
     when you can't see (and don't have active telepathy or persistent
     monster detection).
2012-07-03 22:54:49 +00:00
keni
f95549512a another pile on the trunk 2012-01-04 18:14:41 +00:00
nethack.rankin
3337f05af8 shop feedback ("gold piecess") (trunk only)
From a bug report, dropping and selling a container that had some things owned
by the hero and some already owned by the shop, you could get "You sold
some items inside <a container> for N gold piecess."  Shop handing for
containers has been changed significantly since 3.4.3, but the typo
"pieces" that then optionally gets plural "s" appended was still there.

     While testing the trivial fix, I noticed suboptional feedback in the
prompt about selling.  For a container owned by the shop, it said "items"
even when there was just one hero owned item inside.  Fortunately this
potentinal can of worns only seemed to have one tiny weeny worm in it....

     The revised version of count_buc() that I've had laying around for
a while is also included.

     The fixes entry is for "piecess", not escaped/captured/exterminated
worms, and goes into fixes34.4 despite this patch being labeled "trunk
only".  Separate patch for trunk to follow.
2011-10-27 02:24:54 +00:00
nethack.rankin
67f3a26e52 shopkeeper inheriting hero's possessions (trunk only)
Fix one of the issues noticed while investigating the report of a
shopkeeper sighing when a hero died without owing anything.  If the death
takes place outside of any shop on a level with multiple shopkeepers, the
first one in the fmon list would be the one who had access to the dying
hero's inventory, even if nothing was owed to that one and something was
owed to another shopkeeper.  Now the one who is owed gets first chance to
take the hero's possessions.

     When dying inside a shop, the keeper of that shop takes control of
the possessions regardless of whether he or anyone else is owed anything.
That hasn't changed, except that if the hero is simutaneoulsy inside
multiple shops (within a wall spot shared by two or more shops) and owes
money to one of them, the one who is owed will take his inventory even if
the other shk is found first.

     This doesn't include any changes to feedback given when the hero dies
in the presence of shopkeepers.
2011-08-28 02:11:12 +00:00
nethack.rankin
c98133ac80 calculating shop price adjustments (trunk only)
Fix the second of a couple of minor things I noticed when viewing
that guy's ttyrec about a hidden inventory item which turned out to be
scrolls of scare monster on the used-up items section of his shop bill.

     He had a lot of scroll prices which started as $X00 and were changed
to $Y99 due to integer division roundoff when being hit with a 1/3 price
increase for unID'd items followed by 1/2 price increase for low charisma:
  100  ->  133  ->  199
  200  ->  266  ->  399
Forcing things to round up instead of truncate would help in some cases
but yield $Z01 in others.  Rather than doing that, this accumulates the
adjustment factors and then uses them to make one calculation which gives
a better result:
  100  ->  200
  200  ->  400
Other values and/or other adjustments might not work out so well, but I
don't think they'll ever become prices which look worse than before.
For a single increase of 1/3, 100 still yields 133 but 200 now gives 267
(so ends up differing from the combined price for two 100->133 items).
2011-07-23 03:57:09 +00:00
nethack.rankin
236c3524d2 shop credit feedback (trunk only)
Fix the first of a couple of minor things I noticed when viewing
that guy's ttyrec about a hidden inventory item which turned out to be
scrolls of scare monster on the used-up items section of his shop bill.

     Be more precise when a shopkeeper gives the hero credit for dropped
gold.  Instead of just displaying
  N zorkmids are added to your credit.
show either
  You have established N zorkmids credit.
when you had no previous credit, or
  N zorkmids added to your credit; total is now X zorkmids.
when adding to existing credit.
2011-07-23 03:53:09 +00:00
nethack.rankin
8df1e4d6cb fix #2253 - shk dismissing kops from other level (trunk only)
From a bug report, if you rob a shop, let the
angry shopkeeper catch up with you outside his shop, escape to another
level with adjacent shk tagging along, then pacify the shk by paying him
off, he will dismiss kops on the present level and return to his shop
but when you return to his shop level there'll still be kops chasing you
there.  This fix adds an extra flag to the eshk structure so that kops
can be dismissed a second time when the shk migrates back to shop level.
The first dismisal (on the "wrong" level) still takes place in case any
kops are around.  Neither dismissal actually occurs if there happens to
be another angry shk present on the level where dismissal is being done.
2011-04-15 01:55:42 +00:00
nethack.rankin
363163b0c3 thrownobj, kick[ed]obj (trunk only)
Rename ``kickobj'' to ``kickedobj'' so that the tense matches that
of ``thrownobj''.  Also, move their declarations to decl.h and their
definitions to decl.c since usage has spread from dokick.c/dothrow.c to
various files and is about to expand to another one.
2011-01-16 01:29:18 +00:00
keni
4eabcee787 Add RCS version lines 2009-05-06 10:50:32 +00:00
nethack.allison
d430db0718 remove time_t from struct you (trunk only)
There was an issue reported where save files between different
versions of a manufacturer's compiler were incompatible because the time_t
ubirthday field was changed from 32 bits to 64 bits.

32 bit time_t implementations will break at 19:14:07 on  January 18, 2038.
64 bit time_t implementations will break at 23:59:59 on December 31, 3000.

This removes the dependency on the size of time_t from the save file.
The ubirthday field is no longer embedded in struct you.
This also adds two general purpose routines to hacklib.c, one to convert a time
value to a 14 character char representation and the other to convert that
back to time_t. Those are used by the save/restore routines.

This is a savefile breaking change, so editlevel in patchlevel.h was
incremented.
2007-12-19 03:19:25 +00:00
nethack.rankin
2ad3afee05 GOLDOBJ pickup handling (trunk only)
For GOLDOBJ configuration, relax the 52 object limit for inventory
when gold uses the special $ slot instead of a letter.  Takes care of an
old buglist entry from the beta testers.  [It will need to be revisited
if we ever implement multiple coin types that can't all fit in one slot.]

     Also for GOLDOBJ, prevents nymphs and monkeys from stealing coins,
since allowing that made their steal-item attack be a complete superset
of leprechaun's steal-gold attack.
2007-06-16 02:22:01 +00:00
nethack.rankin
46a8bf78a3 object deletion bookkeeping
Remove some obfree() vs dealloc_obj() confusion.
2007-05-11 00:56:26 +00:00
nethack.rankin
271632db58 object deletion bookkeeping
After the apply-wielded-pie-to-blind-self (quite a while back) and
quivered-candle-burns-out (a week or two ago) bugs where object deletion
left dangling worn-object pointers, add a general check to try to catch
such things at the time of deletion.  Also, clear thrownobj and kickobj
pointers at the time corresponding object is deleted.  (This doesn't add
any checks for them becoming null during process of throwing or kicking,
where I'm not sure that the possibility of missile going away is being
adequately tracked).
2007-03-22 04:23:55 +00:00
nethack.rankin
23eb08a462 shop bones
Dying at a shop doorway, or at the free spot one step in, while not
owing the shopkeeper anything would yield "<shk> gratefully inherites all
your possessions" but leave those possesions where the next hero could
just pick them up for free.  Move them all the way inside the shop, as
happens when the hero dies while owing the shk.  Also, if hero has gold
left after shopkeeper takes any payment owed, force it to go into shk's
inventory instead of having it end up in the pile of other stuff.

     finish_paybill() duplicated much of drop_upon_death(), but not the
two-weapon hack to avoid curse() causing hero's secondary weapon to be
dropped while in the midst of removing it from inventory (but unlike the
old 3.4.1 panic for that, this one just triggered a warning about nonzero
worn mask).  It also lacked the named fruit fixup, whatever that does.
Make finish_paybill() call drop_upon_death() instead of copying it.
2007-03-02 03:28:25 +00:00
nethack.rankin
ef2085bcaf "(contents, N zorkmids)" fix (trunk only)
Some code I recently added was misusing count_unpaid() and would
traverse some or all of inventory instead of just container's contents
when looking for unpaid items.  Add mew routine `is_unpaid(obj)' to do
what I was intending to do with count_unpaid().
2006-11-09 05:20:00 +00:00
nethack.rankin
b5633d17c3 more shopkeeper feedback (trunk only)
The earlier change involving "you sneaky cad!" got me wondering, so
I looked up cad in the dictionary:  "an ungentlemanly man".  I can see
that being extended to a male gnome, even to an orc, but not to a women.
2006-11-07 05:19:48 +00:00
nethack.rankin
0a7c5d6ad2 shopkeeper feedback (trunk only)
Use verbalize instead of pline for shop "thank you, scum" message
(From a bug report.  Suppress shop "you sneaky cad" message
when removing a hero-owned pick-axe from a container inside a shop if the
shk is unable to speak; also give it at most one time per move (taking
multiple pick-axes out of a bag at once was way too verbose).  Honor
addtobill's silent flag for the bill overflow message when/if that occurs.

     Also adds a safe_qbuf usage for the #tip command that I had pending
for pickup.c.
2006-11-07 02:49:09 +00:00
nethack.rankin
bc9f91fce5 unpaid shop goods in inventory (trunk only)
Inventory display adds "(unpaid, N zorkmids)" to carried unpaid
items, but it didn't show anything comparable for indirect unpaid ones
(hero-owned containers holding shop-owned objects).  Now it will include
"(contents, N zorkmids)" in such cases.
2006-11-04 07:49:49 +00:00
nethack.rankin
9d8f6fdc8e shop fixes
Try to fix multiple container-in-shop bugs; it seemed as if every time
I tried to investigate one I stumbled into another.  billable() (post-3.4.3
code, but already present in branch as well as trunk) didn't handle
containers properly.  It sometimes gave the wrong answer and it didn't
clear the no_charge flag of contained items as the old code in addtobill()
it replaced did.  stolen_value() didn't use the actual bill price for an
item already on the shop bill; it generated a new price which might be
different if the object was unID'd (3.4.3 had this one).  Throwing didn't
handle a container owned by the hero which contained items owned by the
shopkeeper.  I'm still not quite sure what's going on there, but throwing
the container out of the shop didn't give any feedback but did add to shop
charges which don't show up in ``I x'' (but do get revealed by ``$'' or
``I $'').  (This was intertwined with some of the other stuff and I don't
know how 3.4.3 behaved in this regard.  Now there's some shop feedback for
the throw and the contents show up for ``I x''.)  An unpaid container which
contained another nonempty unpaid container showed a different price when
picked up and in inventory display [k - a bag (unpaid, NNN zorkmids)]
compared to what was on the bill and showed by ``I u'' because the first
two included double billing of the nested container (just it, not its own
contents).  [There where a few recursive calls of the form
    x += func(x)
which should have been either
    x = func(x)
or  x += func(0).]  Purchasing used the right amount, I think.  I'm not
sure whether 3.4.3 had this particular bug or whether fixes for some of its
other container bugs inadvertently caused this one.

     This patch also changes stolen_container() to work like the other
recursive shop routines:  it just handles the contents, leaving the outer
container itself to be handled by its caller.  It seemed inconsistent, and
changing it simplified the fix for using bill price on stolen unpaid items.
2006-10-31 07:03:37 +00:00
nethack.rankin
4e25ab378b shop price quotes (trunk only)
Add some extra container feedback when shop items are picked up or
browsed via #chat.  Dropping items (sell prompting) already has such.
2006-10-31 05:49:39 +00:00
nethack.rankin
3911716297 shop queries (trunk only)
This eliminates a whole bunch of the "Query truncated" entries in
the nethack.alt.org paniclog file by using safe_qbuf() where applicable.
It also makes selling queries and some other shop messages be less verbose
when shopkeepers are invisible (not uncommon after characters achieve see
invisible capability) by using shkname() to get "Manlobbi" instead of
Monnam()'s "Manlobbi the invisible shopkeeper" (something I had planned
to do even before seeing the truncations in that paniclog; repetition of
"the invisible shopkeeper" was very annoying when stepping through
multiple unpaid objects with itemized billing).

     This also simplifies several GOLDOBJ conditional sections which
happened to be near the other code I was modifying.
2006-10-29 04:10:55 +00:00
nethack.rankin
8f92715098 comment tidbit (trunk only) 2006-06-22 04:57:27 +00:00
nethack.rankin
dc63ed8a80 shop theft/breakage (trunk only)
The recent fix for "breaking glass wand in tool shop" looked suspect,
adding a call to costly_alteration after an existing call to stolen_value.
Either one or the other ought to suffice.  (For items on the floor,
costly_alteration() calls stolen_value(); for items in inventory, or just
released from inventory and not placed on floor yet, costly_alteration()
adds a usage fee to the shop bill but doesn't annoy the shopkeeper into
adding surcharges to prices or summoning the kops if already hostile.)

     In 3.4.3, stolen_value() wasn't smart enough to charge for an out-of-
shk's-field item (like a wand in a tool shop) taken from a shop container,
and that's the problem the user was reporting.  But the post-3.4.3 code was
changed to handle that by checking billable() instead of saleable(); this
bug should have been gone.  Unfortunately, billable() treats items already
on the bill as not interesting--from the perspective of adding things to
the bill--so the change accidentally resulted in stolen_value() no longer
handling objects which are marked unpaid, triggering the same symptom for
a different reason.  (Other events besides the breakage of thrown objects
suffered from the bug's new incarnation since various places deliberately
call stolen_value() for unpaid objects.)  This updates stolen_value() and
stolen_container() to account for the behavior of billable().  And a few
calls to subfrombill() go away since stolen_value() now takes care of that.
2006-06-22 04:08:40 +00:00
nethack.rankin
58137a608a bag of tricks, horn of plenty, #tip (trunk only)
<Someone> reported that he applied an unID'd bag and it became
discovered as a bag of tricks even though a spellbook appeared on the floor
next to him rather than having a monster show up (the monster was a mimic).
Suppress the bag discovery unless you can see or sense a monster appear.
(This doesn't really achieve much for most players, who'll recognize the
bag because they know that only one type of container doesn't prompt to
take things out and/or put things in, but I think it does make sense.)

     While mucking with bag of tricks I decided that to be consistent with
the behavior of other containers, the #tip command should release all the
monsters in the bag instead of just one.

     And after doing that, I realized that horn of plenty ought to behave
much the same, so #tip will operate on it now.  However, it won't be listed
as a likely candidate in the "which item?" prompt unless/until it has been
discovered.  (Attempting to empty any other type of horn yields "nothing
happens", same as for a horn of plenty with no charges left.)  Emptying a
horn of plenty in a shop can be extremely verbose, but I don't think that
qualifies as a bug and don't currently have any plans to alter it.
2006-06-18 05:20:36 +00:00
nethack.rankin
1c66428a26 shktalk patch - speech by polymorphed shopkeepers (trunk only)
Add a patch attached to one of the bug reports sent by <email deleted>
which prevents shopkeepers who have been polymorphed into animals from
speaking.  Some messages are altered so that the player gets informed about
shop interactions without it seeming to be spoken by the shk, other messages
are suppressed outright.  I cleaned it up a bit (mostly formatting, but the
``getcad'' section seemed to have a logic error--using goto to jump into
the middle of an if-then-else is evil...) and implemented a TODO comment he
added (to use mbodypart() when second shopkeeper at end of game shakes his
head; also, skip that phrase if shk is in headless form--futility while
attempting to test this led to discovery of the misplaced parenthesis bug).
2006-05-21 04:22:09 +00:00
nethack.rankin
d736570d01 end of game shopkeeper messages
Fix something I accidentally broke nearly three years ago (post 3.4.2,
so the bug appeared in 3.4.3).  A misplaced closing parenthesis caused an
in-sight check to always fail, so the "<shk> looks at your corpse, shakes
his head, and sighs" message when game ends would never occur.  That
situation is extremely rare anyway; it only happens after some other shk
has taken the hero's possessions.
2006-05-21 04:00:08 +00:00
nethack.rankin
5333a7a30d candelabrum in shop (trunk only)
The code to have Izchak recognize the Candelabrum of Invocation
instead of just being uninterested in an item not stocked in his shop was
being skipped when the character is hallucinating.  Make it work for any
lighting store (slash'em sometimes has another candle shop, run by a
randomly named shopkeeper), and make it recogize Izchak even when
hallucinating.  Also, have him give a message about the need for 7 candles
if the candelabrum doesn't already have them attached.
2006-05-12 00:30:32 +00:00
nethack.allison
e0e3bf2453 selling candelabrum in lighting store
<email deleted> wrote:
> * You can't sell a candelabrum (with candles attached) to a lighting store.

You still can't sell the candelabrum after this, but acknowledge
the situation by having Izchak say something unique.
2006-05-10 03:31:53 +00:00