#### Archived

This topic is now archived and is closed to further replies.

This topic is 6086 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I have no idea what is going on. Im getting this error that i've spent DAYS on. I know its lame to post a million lines of code on the message board and say "whats my error", but im not sure what else to do. What this loops is doing is building the index buffer for a brute-force terrain algorythm. The vertex buffer has already been built. You will notice:
  IdcGrid[whatever] = 0 
all over. I have other code in there (instead of the 0) but it doesn't change the problem if i set it to another number, so i left it as 0. The error im getting is when the function quits. Its happens in dbgheap.c Looks like an de-initialization error. The error is centered around the IdcGrid linked list. This is probably an easy answer, but im the worlds worst debugger and can't figure it out. Additional Info: NumIndices is 8064 NumVertices is 4096 BlockCount is 64
  bool Virtual3DGrid::BuildIndexList() { short x, y, i; short CurrentVtx = 0; bool EvenRow = true; vector IdcGrid(NumIndices); for (y = 0; y <= NumVertices; y += BlockCount) { for (x = y; x <= y + BlockCount * 2 - 1; x += 2) { if (EvenRow) { IdcGrid[y + x] = 0; IdcGrid[y + x + 1] = 0; } else { IdcGrid[y + x] = 0; IdcGrid[y + x + 1] = 0; } CurrentVtx++; } EvenRow = !EvenRow; } return true; } 
thanks guys hope somebody can figure this out. ps. - if anybody else has code that will generate an index list for similar terrain algorythm, i would be happy to see it. Edited by - Psionic on November 17, 2001 6:22:29 PM

##### Share on other sites
Well I don''t know the value of NumIndices, but I would check if you stay within the vector (x + y + 1 always < NumIndices).
I find the equal in the first for very strange, I would guess it shouldn''t be there, but it depends on the meaning of NumVertices and NumIndices.

##### Share on other sites
Just tracing this through to the return statement, the debugger shows:

x = 4224;
y = 4160;

therefore, y + x + 1 = 8385 - which, if the vector is only 8064 elements long, will cause a big problem. You have to be very careful when using a subscript operator on a vector to ensure that there are enough elements to do this.

I would almost certainly say that''s where your problem is.

##### Share on other sites
The dgbheap.c debugger errors come from memory access or violation errors. I believe JY is correct. When dealing with vectors or any array type for that matter, it is very important to make sure you are not accessing memory that is out of bounds. I would take a look at your loop again and double check what is actually being accessed.

-----------------------------
kevin@mayday-anime.com
http://games.mayday-anime.com

1. 1
Rutin
24
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 9
• 46
• 41
• 23
• 13
• ### Forum Statistics

• Total Topics
631749
• Total Posts
3002031
×