Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Any idea why this crashes? Even when I comment out the heapget lines it still crashes
Any idea why this crashes? Even when I comment out the heapget lines it still crashes
2005-01-11, 4:57 PM #1
Quote:
startup:

Sleep(1.0);

HeapNew(160000);

slot = 0;
For(i = 1; i <= GetThingCount(); i = i + 1)
{
If(GetThingTemplate(i) == nodetemplate)
{
HeapSet(slot, i); //current thing is a node, place it in current slot
slot = slot + 1; // go to next 'slot'

if(slot >= 9999)
i = GetThingCount(); //bail out if we've reached the max of nodes
}
}

nodecount = slot; // this is the actual amount of nodes used, logically the heap amount should be size - 1

//Heap of all nodes now available, now we need to find and mark the nodes that can be moved too
For(slot = 0; slot < nodecount; slot = slot + 1)
{
//get the thing we're going to work on here (this works)
WorkingNode = HeapGet(slot);

//Set all the nodes as zero to start, we will allow up to 9 possible nodes to be moved too. (zero no more nodes)
For(i = 0; i <= 7; i = i + 1)
MoveNode = 0;

//reset node count
movenodes = 0;

//Things are in order, do the dirty work of finding a list of their move to able nodes

For(slotcheck = 0; slotcheck < nodecount - 1; slotcheck = slotcheck + 1)
{
CheckNode = HeapGet(slotcheck);

If(HasLOS(WorkingNode, CheckNode)) // First things first, they've got to see eachother
{



MoveNode[movenodes] = CheckNode;
movenodes = movenodes + 1;
}
}


for(i = 0; i < 9; i = i + 1)
{

HeapSet( ((i + 1) * 10000) + slot, MoveNode
);

}


}
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-11, 5:12 PM #2
try using for(...; i < getthingcount();...)
(removed the '=')
Don't know if it'll stop your crashing but if you had 1 thing in your level (thing 0), your loop will exectute and try to get thing 0 and thing 1, because 1 is <= the thing count (1).
May the mass times acceleration be with you.
2005-01-11, 5:30 PM #3
I just figured it out...apparently MotS thought the array name MoveNode = crap bed immediately. I changed the name of the array variables to nodething and it worked fine. :rolleyes:

No idea...but I narrowed it down to that.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-12, 8:26 PM #4
Can I see the original cog with MoveNode (with symbols and everything)

I just ran a test with a variable MoveNode and it had no problems.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-01-13, 5:29 AM #5
Well I'm not sure the original cog still exists, but the varibles were in the structure:

int MoveNode0=-1 local
....
int MoveNode8=-1 local

It isn't really the 'standard' way LEC did it. (Usually something more along the lines of projectile, projectile2, projectile3, etc leaving the varibles values undefined/blank which is pretty much the format I changed too) But I've used it in other cogs fine so its still puzzling.

I thought maybe I had another movenode structure in the varibles (I did have a short array of EndMoveNode setup the same as I had MoveNode setup) but surely that wouldn't crash it.

I'll see if I have a backup when I get home.
-El Scorcho

"Its dodgeball time!" -Stormy Waters
2005-01-13, 6:02 AM #6
Wait, was it MoveNode0= or MoveNode=
if it was MoveNode0, I think that would cause the problem since arrays in JK arn't like C++ arrays. JK's arrays look for the variable name you give (MoveNode[x] would look for the variable MoveNode. MoveNode0[x] would look for the variable MoveNode0.) and if the variable isn't there I assume it would bork the cog.
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2005-01-13, 6:46 AM #7
Well, I was using MoveNode[x] not MoveNode0[x]. Although, even if it borked the cog it just wouldn't work. The whole game crashed right to the desktop. I've got no idea why...it must have been pulling some other variable or something.

Remarkably, after I got this part of the cog to stop crashing the rest of it appears to work fine after the first test. The rest of the cog was signifigantly more complicated and involved a lot of HeapGets() inside for loops.

Although I will have to do more testing to make sure its functionality is working as intended because the level I tested on was quite simple. (Its the A* pathfinding algorithm done in cog script, the first part just defines the node paths)

Thank god for the Heap.
-El Scorcho

"Its dodgeball time!" -Stormy Waters

↑ Up to the top!