[CF-Devel] Python/casino stuff

crossfire-devel-admin at archives.real-time.com crossfire-devel-admin at archives.real-time.com
Fri Oct 24 02:10:06 CDT 2003


Nicolas Weeger wrote:
>
     
      Hello.
     
     >
     
     
     >
     
      I finally fixed python plugins to work under Windows.
     
     >
     
      I'll submit patches when i'm home, assuming my provider works & i can 
     
     >
     
      diff files :)
     
     >
     
     
     >
     
      I got a remark concerning the python plugin, though, at least as it is 
     
     >
     
      used in the casino scripts (Goths tavern, iirc):
     
     >
     
     
     >
     
      When you gain gold, the gold is created on the machine's spot.
     
     >
     
      But what happens is that first gold is created, then # of coins is set.
     
     >
     
      Which leads to incorrect behaviour: if there is gold on the spot 
     
     >
     
      already, the newly created 1 gold coin is merged with it, then the count 
     
     >
     
      is fixed.
     
     >
     
      So you can lose gold!!
     
     >
     
     
     >
     
      The sequence is the following:
     
     >
     
      * create 1 gold coin from plugin
     
     >
     
      * server code creates it, and merges it with gold already on floor
     
     >
     
      * plugin sets # of gold coin to gained value => incorrect count
     
     >
     
     
     >
     
      I don't know the 'right' way to fix: either server must not merge 
     
     >
     
      newly-created items, or must not insert'em in the map already.
     
     >
     
      Or python plugin must take into account already existing gold
     
     >
     
      (so something like # gold coin = current # gold + gain - 1 [1 coming 
     
     >
     
      from the object creation]).
     
     
  It'd be really help to post a plugin snippet that exhibits the bug.

  IF what your doing is doing is calling the function to create the object, and 
then the function to set the nrof, then the behaviour above is correct.  The 
setquantity has no idea of past object state, so thus doesn't know if it should 
set the value absolute or add to it.

  The correct method then in the script would be to call getquanity on the item, 
and then add onto that.

  I'm also not 100% sure why, but it seems the setquantity function has an upper 
boun of 100,000.  This seems quite large, but isn't quite as big if you start 
thinking silver coins (1000 pp worth basically).

  Since nrof is actually a 32 bit value, the practical limit (in terms of code) 
is actually much higher.


>
     
     
     >
     
      Just my 2 gold coins, err, cents of euro :)
     
     >
     
     
     >
     
      Nicolas 'Ryo'
     
     >
     
     
     >
     
     
     >
     
      _______________________________________________
     
     >
     
      crossfire-devel mailing list
     
     >
     
     
      crossfire-devel at lists.real-time.com
      
      
     >
     
     
      https://mailman.real-time.com/mailman/listinfo/crossfire-devel
      
      
     


_______________________________________________
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