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 → cog memory limit
cog memory limit
2002-11-10, 4:14 AM #1
can i make a cog with 9 * arrays[50]?

I did it it crashed me. (i dont think there is any number errors, i "generated" the names with excel)

I just read there is things to allocate memory :

***
HeapFree
Frees the allocated heap array for a certain cog. HeapFree(); Note: The heap verbs allocate memory to a system, making it possible to accomplish complex tasks via cog. The heap verbs may not be retained in singleplayer saved game files.

HeapGet
Returns the allocation of a heap. int = HeapGet(int_heap);
HeapNew Allocates memory elements of any size (the largest size being a vector) to a cog. HeapSet(Int_Size);

HeapSet
Sets a heap size to a certain heap. HeapSet(int_heap, int_value);
***

How does it work exaclty ?
2002-11-10, 8:44 AM #2
The most you could have would be 4 [50] arrays. The symbols sections incog is limited to some 200 sybmols, as near as I can tell.


As for the heap verbs . . . well . . take a peek at this cog . . .

Code:
# Simple script to change all of a level's materials to dflt, then back again.
#
# 09/2002 GBK - Packman573@aol.com
#==============================================================#
symbols

message   Startup
message   Activated

material  M=gbk_dflt.mat   local

int       I=0              local
int       P=0              local
int       H=0              local

end
#==============================================================#
code
#------------------------------------------------------
startup:
	P = 0;
	H = 0;

Stop;
#------------------------------------------------------
activated:
	if(!P)
	{
		if(!H)
		{
			H = 1;
			Print("Saving original mats...");
			HeapNew(0, GetSurfaceCount() + 1);
			for(I = 0; I <= GetSurfaceCount(); I = I + 1)
			{
				if(GetSurfaceMat(I) < 0) HeapSet(I, M);
				else HeapSet(I, GetSurfaceMat(I));
			}
		}
		Print("Setting dflt material...");
		P = 1;
		for(I = 0; I <= GetSurfaceCount(); I = I + 1) SetSurfaceMat(I, M);
	}
	else
	{
		Print("Setting original mats...");
		P = 0;
		for(I = 0; I <= GetSurfaceCount(); I = I + 1) SetSurfaceMat(I, HeapGet(I));
	}

Stop;
#------------------------------------------------------
end


Its been Scribed so you can read it easier . .. the cog is an inv cog that changes all the mats in a level to dflt.mat, and back again . .

------------------
I used to believe that we only want what we can't have. I was wrong. The truth is, the wonderful truth is, we only want what we think we can't have.

GBK oNline. Cogs, tuts, and total w00tage.
And when the moment is right, I'm gonna fly a kite.
2002-11-11, 12:00 AM #3
ok thx.

Currently i have this pb :


i have 3 arrays[30] (well 4*3[15-30])

and when i do

arrays1[27] for ex, it returns me a value from arrays2 and stuffs like that

Can you guarantee me that if i do a things like that

HeapNew(6000)

that i manage like 30*arrays[200]

It will work fine ?


(please guarantee me , i dont want to spend hours changing it, and having the same pb)

[http://forums.massassi.net/html/confused.gif]
2002-11-11, 6:49 AM #4
Well, let me put it this way. Esther has over 20,000 surfaces, and the heap in my example cog easily allots a slot for each.


So, yes, you could do up to and past Array0[20000] without difficulty.


As for your array problems .. well, it might help if you post the cog.
And when the moment is right, I'm gonna fly a kite.
2002-11-11, 1:20 PM #5
It sounds like it might be a whopper.
Cordially,
Lord Tiberius Grismath
1473 for '1337' posts.
2002-11-12, 6:02 PM #6
Heap verbs == good

Over 100 elements in an array just to hold a number == bad

Heap good, Elements bad.
-Hell Raiser

↑ Up to the top!