Difference between revisions of "Talk:Container"

From NetHackWiki
Jump to navigation Jump to search
(32k items question)
(32k items question)
Line 48: Line 48:
  
  
for (curr = obj->cobj; curr; curr = otmp) {
+
for (curr = obj->cobj; curr; curr = otmp) {
 
+
    otmp = curr->nobj;
+
    otmp = curr->nobj;
 
+
    if (Is_mbag(obj) && obj->cursed && !rn2(13)) {
+
    if (Is_mbag(obj) && obj->cursed && !rn2(13)) {
 
+
obj_extract_self(curr);
+
obj_extract_self(curr);
 
+
loss += mbag_item_gone(held, curr);
+
loss += mbag_item_gone(held, curr);
 
+
used = 1;
+
used = 1;
 
+
    } else {
+
    } else {
 
+
cnt++;
+
cnt++;
 
+
    }
+
    }
 
+
}
+
}
 
Now, cnt is earlier defined simply as an int; IIRC this should be 32- or 64-bit depending on your system.  As for obj->cobj, in obj.h, around line 29, the quantity (quan) of items in it is defined as a long - so it seems the limiting factor would be cnt; of course, you'd have to put 4 billion+ objects in to hit that even on a 32-bit system.  Anyway, does this look correct to people more code-fluent than I? -[[User:Ion frigate|Ion frigate]] 10:10, 10 December 2011 (UTC)
 
Now, cnt is earlier defined simply as an int; IIRC this should be 32- or 64-bit depending on your system.  As for obj->cobj, in obj.h, around line 29, the quantity (quan) of items in it is defined as a long - so it seems the limiting factor would be cnt; of course, you'd have to put 4 billion+ objects in to hit that even on a 32-bit system.  Anyway, does this look correct to people more code-fluent than I? -[[User:Ion frigate|Ion frigate]] 10:10, 10 December 2011 (UTC)
 +
:In that particular situation, there's no issue with cnt. Even if you did have 4 billion objects, unless you had ''exactly'' 4294967296 objects in there you wouldn't have a problem. cnt is only used to check if the bag is empty, nothing else. If you had that exact number of items in a bag it would mistakenly think it was empty (it'd also take forever to discover this; looping up to 4 billion isn't exactly fast), but you could remedy this by putting one more item in.
 +
:The real question is in adding items to a bag, as there might be some other bit of code that would break if you exceed 32k or 4 billion. The items in a container are stored in a linked list, which on its own can hold any number of objects until you run out of memory. I can't figure out the exact code used for adding items to bags or taking them out, so there might be something troublesome in there. -- [[User:Qazmlpok|Qazmlpok]] 13:04, 10 December 2011 (UTC)

Revision as of 13:04, 10 December 2011

Unlocking

Can you also polymorph to a gelatinous cube and eat it?

--LWM

I tried eating a large box and a chest as a polymorphed gelatinous cube, but I found out I couldn't do that at all. So I guess the answer is no. :/ —Shijun 07:10, 12 August 2008 (UTC)
Let me correct myself. You can't eat a container that has items in it. —Shijun 07:15, 12 August 2008 (UTC)

slashem polymorph trick

Will this anger a shopkeeper, if that is where the ice box happens to be? I'd think yes. Tjr 13:42, 29 April 2009 (UTC)


Does a food store buy ice boxes? Tjr 16:23, 21 May 2009 (UTC)

Nesting

It seems a little strange that chance of an explosion appears to increase after 7 layers. Is this correct? And is it the same for SLASH'EM? MrFroon 20:42, October 14, 2009 (UTC)

It makes sense from a game balance perspective: you could almost eliminate the risk of explosion otherwise. -Tjr 08:02, October 15, 2009 (UTC)

Destroying

Is there any reliable way to destroy boxes and chests? I know you can force with a blunt weapon, but this then relies on failure rather than success (you'd have to keep repairing the lock). This is for the gray stone-in-a-container so polymorph is out.--PeterGFin 10:41, January 11, 2010 (UTC)

To my knowledge, no. If I encounter a gray stone in a container, I will usually either leave it alone or count up my total weight so a loadstone would take me to a different burdoned status than a harmless stone. I have an Excel spreadsheet for this, perhaps I might share it in the future. -Tjr 12:03, January 11, 2010 (UTC)

green goblin

should there be some discussion of strategy w/bag of tricks? Just now learning they are basically just another monster generator, I think.

Bags of Tricks make reliable sacrificial generators. They can be a big help if you've found an altar on an early dungeon level but, due to the way the early location of it, monsters don't get generated too often or close enough to the altar. I guess you can use them as pet generators as long as you have a source of taming. --FJH 23:44, October 10, 2010 (UTC)

sporkhack iron safe

I'm playing sporkhack and found an iron safe? Any1 know anythimg of this? Should there be something in the article? There isn't, you know(btw: The last topic was mine, and I forgot to 4tilde).Slarty 18:00, November 2, 2010 (UTC)

Use a stethoscope or wand of opening to open it.Tjr 18:39, November 2, 2010 (UTC)

Nesting Figures

I just checked with the code and it appearst that the figures for repeated nesting where wrong. If I understand it right, the contents of an object are only checked, if the object itself is not a magic bag or wand of cancellation. So if you put a BoH that already contains another BoH into a third BoH, then the innermost bag does not get an extra chance to cause an explosion.

Zimmi 19:03, 14 January 2011 (UTC)

32k items question

I really don't think that todo belongs in the top of the article - the casual reader isn't going to know how to find the answer to that or be affected much by it. I think I may have an answer to it, also, but I'd like someone else a little better at coding to verify me. In pickup.c around line 2118, there's a loop that counts the number of items in the bag:


	for (curr = obj->cobj; curr; curr = otmp) {

	    otmp = curr->nobj;

	    if (Is_mbag(obj) && obj->cursed && !rn2(13)) {

		obj_extract_self(curr);

		loss += mbag_item_gone(held, curr);

		used = 1;

	    } else {

		cnt++;

	    }

	}

Now, cnt is earlier defined simply as an int; IIRC this should be 32- or 64-bit depending on your system. As for obj->cobj, in obj.h, around line 29, the quantity (quan) of items in it is defined as a long - so it seems the limiting factor would be cnt; of course, you'd have to put 4 billion+ objects in to hit that even on a 32-bit system. Anyway, does this look correct to people more code-fluent than I? -Ion frigate 10:10, 10 December 2011 (UTC)

In that particular situation, there's no issue with cnt. Even if you did have 4 billion objects, unless you had exactly 4294967296 objects in there you wouldn't have a problem. cnt is only used to check if the bag is empty, nothing else. If you had that exact number of items in a bag it would mistakenly think it was empty (it'd also take forever to discover this; looping up to 4 billion isn't exactly fast), but you could remedy this by putting one more item in.
The real question is in adding items to a bag, as there might be some other bit of code that would break if you exceed 32k or 4 billion. The items in a container are stored in a linked list, which on its own can hold any number of objects until you run out of memory. I can't figure out the exact code used for adding items to bags or taking them out, so there might be something troublesome in there. -- Qazmlpok 13:04, 10 December 2011 (UTC)