View Issue Details

IDProjectCategoryView StatusLast Update
0000417LDMud 3.3Efunspublic2018-01-29 21:57
ReporterSorcerer Assigned Tolars 
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version3.3 
Fixed in Version3.3.713 
Summary0000417: present() does not return all items
DescriptionThis refers to ldmud 3.4.0.
When calling present(<name>,<number>) not all items are returned properly.
Example:
If you have 2 items called "strauss" in the environment() and one more in the inventory of the object using present(), <number>=1 will find the one in the inventory, <number>=2 will find the _second_ one in the environment, but the first one in the environment will never be found. (<number>=3 will return 0).
To me it seems, present() first looks up all items in the inventory but then does not reset it's internal counter and continues to look at environment().


The following code shows this behaviour:

int present_test() {
  write("present(\"strauss\",<n>) :\n");
  write(sprintf("1: %O\n",present("strauss",1)));
  write(sprintf("2: %O\n",present("strauss",2)));
  write(sprintf("3: %O\n",present("strauss",3)));
  write("present(\"strauss\",<n>,environment()) :\n");
  write(sprintf("1: %O\n",present("strauss",1,environment())));
  write(sprintf("2: %O\n",present("strauss",2,environment())));
  write(sprintf("3: %O\n",present("strauss",3,environment())));
  write("present(\"strauss\",<n>,this_object()) :\n");
  write(sprintf("1: %O\n",present("strauss",1,this_object())));
  write(sprintf("2: %O\n",present("strauss",2,this_object())));
  write(sprintf("3: %O\n",present("strauss",3,this_object())));
  return 1;
}

Output for 2 "strauss" in the inventory and 1 in the environment:
present("strauss",<n>) :
1: /wizards/sorcerer/item/blumenstrauss#1394
2: /wizards/sorcerer/item/blumenstrauss#1397
3: 0
present("strauss",<n>,environment()) :
1: /wizards/sorcerer/item/blumenstrauss#1395
2: 0
3: 0
present("strauss",<n>,this_object()) :
1: /wizards/sorcerer/item/blumenstrauss#1394
2: /wizards/sorcerer/item/blumenstrauss#1397
3: 0

This time the one in the environment is not found at all since the counter is already at 2 after the inventory.
TagsNo tags attached.

Activities

lars

2005-11-25 13:06

reporter   ~0000424

This is tricky, as present() is actually working as designed - it is just that item 0000001 in the environment is hidden by item 0000001 in the object itself. Let me think about that.

_xtian_

2005-11-26 11:31

reporter   ~0000425

note: In the unilib family the parser (parse_com) implemented inside the lib gives precedence to objects in the environment before objects inside the second specific object in search space (which will usually be this_player).

This is usefull, since a player can specify himself as only search space by using the keyword "my" ("mein" in German).

So, allthough we rarily use the second argument for present() to select objects in the mudlib, a consistant approach would be elegant, and I dont think this will have any regressions.

lars

2005-11-27 14:39

reporter   ~0000427

I have implemented this now - let's see how many Muds break now :-)

Issue History

Date Modified Username Field Change
2005-11-25 09:09 Sorcerer New Issue
2005-11-25 13:06 lars Note Added: 0000424
2005-11-26 11:31 _xtian_ Note Added: 0000425
2005-11-27 14:39 lars Status new => resolved
2005-11-27 14:39 lars Fixed in Version => 3.3.713
2005-11-27 14:39 lars Resolution open => fixed
2005-11-27 14:39 lars Assigned To => lars
2005-11-27 14:39 lars Note Added: 0000427
2006-02-28 20:04 lars Status resolved => closed
2010-11-16 09:42 lars Source_changeset_attached => ldmud.git master dbef0cd1
2018-01-29 18:59 lars Source_changeset_attached => ldmud.git master dbef0cd1
2018-01-29 21:57 lars Source_changeset_attached => ldmud.git master dbef0cd1