[CF-Devel] Bug in stealing code

crossfire-devel at archives.real-time.com crossfire-devel at archives.real-time.com
Thu Jun 3 02:19:22 CDT 2004


Andreas Kirschbaum wrote:

>
     
      Besides this, my code declares the variable at the beginning of a
     
     >
     
      block. Therefore it should be valid according to both standards.
     
     >
     
      (My apologies for not using context diffs.)
     
     
  Ok - maybe I didn't look closely enough.

>
     
     
     >
     
      I tend to declare variables at the beginning of the innermost
     
     >
     
      possible block. If this is not acceptable, I'll refrain from doing
     
     >
     
      this and declare them at the beginning of the function.
     
     
  That is fine - declaring variables at the top of blocks is generally not a 
problem, but if you were doing something like:

if ... {
    int i;
   ....
} else {
    int i;
   ..
}

  I'd just assume that int i be declared once at the top.


>>
     
     3) Player has item stolen, and theif correctly has it in his
     
     >>
     
     inventory, but old player still shows higher weight.
     
     >
     
     
     >
     
     
     >
     
      Case 3 does not work correctly (for player and monster
     
     >
     
      interchanged): Monster steals an item successfully, item gets
     
     >
     
      removed from player inventory -- you see the item disappearing
     
     >
     
      from inventory view but the total player weight remains unchanged.
     
     >
     
     
     >
     
      I did ask this question (how to correctly update the player
     
     >
     
      weight) to fix other places with the same bug: after eating or
     
     >
     
      throwing items, the player weight does not change.
     
     
  I think the real problem here isn't that the players weight isn't getting 
updated, but rather that information isn't getting communicated to the client.

  Looking at how weight is handled for hte player, I can see why - basically, 
explicit calls to say 'update the weight' need to be made.  This actually makes 
sense, because it deals with containers.

  The problem seems to be that remove_ob doesn't make that call to update the 
players weight, or adjust weight at all.  This is probably because the caller is 
presumed to do that.

  Not it surprises me that the eating code would have the same issue - if 
decrease_ob_nr is called, that will do the work of updating the players weight.

  But the fix here is to just add lines like:
  esrv_update_item(UPD_WEIGHT, pl, pl);

  It might actually make more sense to treat the weight like any of the other 
stats (at least player weight), store the last value we sent, and send again if 
different instead of having these explicit calls.



_______________________________________________
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