[CF-Devel] Patch for minor bug, and a minor bug

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Mon Jun 16 05:41:17 CDT 2003


As dungeonmaster, if you click on a shop tile, you'll find that shop-type
items are turning up *inside* the tile. Having spent all that time rolling
for treasure that no-one can get to seems a waste of memory. ;)

A patch against CVS:

     
     krudat at kevin
     
     :~/fiddling/crossfire/crossfire/crossfire/server$ cvs diff -u
apply.c
Index: apply.c
===================================================================
RCS file: /cvsroot/crossfire/crossfire/server/apply.c,v
retrieving revision 1.82
diff -u -r1.82 apply.c
--- apply.c     24 May 2003 04:51:12 -0000      1.82
+++ apply.c     16 Jun 2003 10:06:50 -0000
@@ -3234,7 +3234,7 @@
          update_ob_speed(tmp);
        }
         if(tmp && tmp->arch && tmp->type!=PLAYER && tmp->type!=TREASURE &&
-         tmp->randomitems)
+         tmp->type!=SHOP_FLOOR && tmp->randomitems)
             create_treasure(tmp->randomitems, tmp, GT_APPLY,
                             m->difficulty,0);
       }

Now for a stranger problem. I'd call it minor since it's probably difficult
to reproduce and won't affect normal play.

Also, as dungeon master, if I 'create gem of flawless beauty', I get two or
three diamonds, but they have the face of the pretty emerald. 'dump'ing them
doesn't reveal anything else out of place.

The above two things have been confirmed in the CVS version and a 1.1.0
server. The below thing I've only tested in CVS version, as the 1.1.0 server
doesn't have the Python plugin.

There's a stranger bug involving diamonds of flawless beauty. When I open
the pouch described below, the bow of Auriga, waybread of Aelingas and
rubies come out okay, but the diamonds, emeralds and sapphires of flawless
beauty all use the diamond face and completely wrong.

To me, the numbers look like they're pointers to *something* which have been
written to the value field by mistake. They're still turning out like this
after a clean recompile of the server.

Erk, now that I've tested it again, if I open the pouch three times in a
row, the server segfaults in libc6, but in a different function. Another
pouch that doesn't count up the value of unpaid items first segfaults on the
first opening.

(gdb) bt
#0  0x400f4099 in realloc () from /lib/libc.so.6
#1  0x400f3fb4 in realloc () from /lib/libc.so.6
#2  0x40202846 in PyNode_AddChild () from /usr/lib/libpython2.2.so.0.0
#3  0x40202c27 in PyParser_AddToken () from /usr/lib/libpython2.2.so.0.0
#4  0x40202ff7 in PyParser_Delete () from /usr/lib/libpython2.2.so.0.0
#5  0x402032c1 in PyParser_ParseFileFlags () from
/usr/lib/libpython2.2.so.0.0
#6  0x40273a94 in PyParser_SimpleParseFileFlags () from
/usr/lib/libpython2.2.so.0.0
#7  0x40273c4f in PyRun_FileExFlags () from /usr/lib/libpython2.2.so.0.0
#8  0x402726ef in PyRun_SimpleFileExFlags () from
/usr/lib/libpython2.2.so.0.0
#9  0x40273923 in PyRun_SimpleFileEx () from /usr/lib/libpython2.2.so.0.0
#10 0x402738fb in PyRun_SimpleFile () from /usr/lib/libpython2.2.so.0.0
#11 0x401df2e5 in HandleEvent (PParm=0xbffff894) at plugin_python.c:6882
#12 0x401ded69 in triggerEvent (PParm=0xbffff894) at plugin_python.c:6704
#13 0x0805ddee in manual_apply (op=0x813c548, tmp=0x88917b0, aflag=0) at
apply.c:2196
#14 0x0805e300 in player_apply (pl=0x813c548, op=0x88917b0, aflag=0,
quiet=0) at apply.c:2423
#15 0x080d4641 in ApplyCmd (buf=0x881be50 "1304", len=4, pl=0x4031e008) at
item.c:596
#16 0x080d5257 in HandleClient (ns=0x4031e00c, pl=0x4031e008) at loop.c:363
#17 0x080d5990 in doeric_server () at loop.c:618
#18 0x08079493 in main (argc=1, argv=0xbffffc84) at main.c:1173

(gdb) bt
#0  0x400f3c1b in free () from /lib/libc.so.6
#1  0x400f3aa3 in free () from /lib/libc.so.6
#2  0x4022c5ce in _PyObject_Del () from /usr/lib/libpython2.2.so.0.0
#3  0x40232d0d in PyString_AsDecodedObject () from
/usr/lib/libpython2.2.so.0.0
#4  0x402344e7 in PyTuple_SetItem () from /usr/lib/libpython2.2.so.0.0
#5  0x4025673e in PyEval_EvalCode () from /usr/lib/libpython2.2.so.0.0
#6  0x4027405c in PyOS_setsig () from /usr/lib/libpython2.2.so.0.0
#7  0x40273fef in PyOS_setsig () from /usr/lib/libpython2.2.so.0.0
#8  0x40273c7d in PyRun_FileExFlags () from /usr/lib/libpython2.2.so.0.0
#9  0x402726ef in PyRun_SimpleFileExFlags () from
/usr/lib/libpython2.2.so.0.0
#10 0x40273923 in PyRun_SimpleFileEx () from /usr/lib/libpython2.2.so.0.0
#11 0x402738fb in PyRun_SimpleFile () from /usr/lib/libpython2.2.so.0.0
#12 0x401df2e5 in HandleEvent (PParm=0xbffff894) at plugin_python.c:6882
#13 0x401ded69 in triggerEvent (PParm=0xbffff894) at plugin_python.c:6704
#14 0x0805ddee in manual_apply (op=0x813c548, tmp=0x88d39b4, aflag=0) at
apply.c:2196
#15 0x0805e300 in player_apply (pl=0x813c548, op=0x88d39b4, aflag=0,
quiet=0) at apply.c:2423
#16 0x080d4641 in ApplyCmd (buf=0x881be50 "1627", len=4, pl=0x4031e008) at
item.c:596
#17 0x080d5257 in HandleClient (ns=0x4031e00c, pl=0x4031e008) at loop.c:363
#18 0x080d5990 in doeric_server () at loop.c:618
#19 0x08079493 in main (argc=1, argv=0xbffffc84) at main.c:1173


arch pouch
title of Shopping
event_apply /python/pouch_shopping.py
event_apply_plugin Python
materialname cloth
end

Below is the event script:

#

## Triggers on EVENT_CLOSE, which means it needs to be a script for a container. 
## I'd like it to be on 'open', but that's a little hard to hook for, or something. :(
## Hooking it to EVENT_APPLY would make it fire twice.
# Meant to be attached to a pouch. (What else?)
# Might be fairly self-documenting.
# Corollary: do not let a player obtain an object with this event linked.

import CFPython

this = CFPython.WhoAmI() # Gives us a long that was the pointer inside Crossfire. :(
# Not that the surrogates really work that way, mind you. :(

# ...NULL is 0 on my computer, via Python. (Argh argh argh...)
NULL = 0

if this != NULL:
    # ... I thought this was called BEFORE esrv_apply_container(). :P
    # Well, we'll try the other one of three.
    if not CFPython.IsApplied(this):
        ## *Hopefully* means the container was applied, and is now being 
        ## opened; the *second* middle-click in the three-state cycle.
        ##
        ch=CFPython.WhoIsActivator()

        if ch != NULL:
            foo = CFPython.GetInventory(ch)
            if foo != NULL:
                # Just to be sure, find the real top before actually traversing the list.
                while foo != NULL:
                    top = foo
                    foo = CFPython.GetPreviousObject(top)
                    
                total_unpaid = 0

                # Now whirl over the contents of the character.
                ob=top
                while ob != NULL:
                    #CFPython.Write("Object '%s'" % (CFPython.GetName(ob),), ch)
                    if CFPython.IsUnpaid(ob):
                        #CFPython.Write("    is unpaid", ch)
                        cost = CFPython.GetObjectCost(ch, ob, CFPython.CostFlagFBuy())
                        #CFPython.Write("   and would cost '%d' to buy." % cost, ch)
                        total_unpaid = total_unpaid + cost
                    ob = CFPython.GetNextObject(ob)
                
                CFPython.Write("You're carrying '%d' of potential purchases." % (total_unpaid,), ch)
                # Seems to be in silver.
            
            
            ## Turns out to be worth approx. 2 ^ 32 - 1 platinum.
            #CFPython.CreateObjectInside("diamond of flawless beauty", this)    
            # Still one plat long.
            CFPython.CreateObjectInside("platinacoin", this)    
            # Doesn't seem outrageously overpriced.
            CFPython.CreateObjectInside("ruby", this)
            ## These look like diamonds, and have the wrong (probably pointerized) value.
            #CFPython.CreateObjectInside("ruby of flawless beauty", this)
            #
            CFPython.CreateObjectInside("sapphire of flawless beauty", this)
            #
            CFPython.CreateObjectInside("emerald of flawless beauty", this)
            # 
            CFPython.CreateObjectInside("waybread of Aelingas", this)
            # Comes out unidentified, but otherwise unharmed.
            CFPython.CreateObjectInside("bow of Auriga", this)
            
            # One other strangeness I've noted, is that ... (aside from the segfaults 
            # in libc6 :P) DM-created items have materials, but pouch created items don't.
            # Or maybe the other way around.
            
            
            
                
# No returning from a module, bleh. :P




-- 
  Thanks,

 -- Kevin "Third Time's an Evacuation" Rudat <
     
     krudat at origin.net.au
     
     >

Has been bitten by semantics before.   Sci-Fi/Fantasy ... type.
Pretends to know a bit of programming. Very bad manners.
Terrible posture and co-ordination.    A forgetful ... wha?

<Kaa-Hahhnn> Humans are an example of a species rushed to life without
          proper testing... they have LOTS of bugs to fix. ;>

_______________________________________________
crossfire-devel mailing list
     
     crossfire-devel at lists.real-time.com
     
     
     https://mailman.real-time.com/mailman/listinfo/crossfire-devel
     
     
    


More information about the crossfire mailing list