Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (1 invisible), 672 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 3 1 2 3
Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466063
05/23/17 15:26
05/23/17 15:26
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Normally you would use the "sizeof" macro to memcpy (or (sys_)malloc) stuff, like this:

memcpy(node_2_nodeCopy_i,node_to_node,999999*sizeof(var)); //
//wait(1); // is this because of the memcpy above? that's not necessary
memcpy(visited_i,visited,999999*sizeof(var)); //sizeof(var) = 4


Go ahead and please post in the pathfinding thread should you run into any troubles!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to save the contents of an array, WRS/resource [Re: Superku] #466064
05/23/17 15:49
05/23/17 15:49
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
that worked superku!!!! Thank you! Originally i did 4*999999, which worked i guess? But I tried the sizeof that you posted and that worked (im assuming better)

Can memcpy be run instantly? I put a wait in there because i thought it needed time to finish a huge array. But I dont need it, why is that?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466065
05/23/17 16:22
05/23/17 16:22
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Both should work, unless you write something like
var count = 999999;
memcpy(..., 4*count); // or sizeof(var) instead of 4
Then, at least I think so, would the calculation be treated as a var result (because of var times integer) and therefore be limited by the var range (or get negative to be more precise, or positive again but at a number way too low).


Don't write random waits into your code, that does more harm than any good. Everything you write gets executed instantly and in order, and the program only continues after the current instruction or calculation has been finished (in a single threaded program like the default acknex engine).
There are (and/ or were) only a few exceptions for which there were reasons or explanations, of course. For example level_load in old acknex versions (like A5, where it was executed not immediately but at the end of the frame => wait(1)), automatic bounding box initialization at the end of the frame for entities created by ent_create (therefore a wait(1) before c_setminmax() on animated models), DirectX initialization at the end of the frame or functions using wait themselves.

In general: Don't use wait unless you really have to, like for default entity loops.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: How to save the contents of an array, WRS/resource [Re: Superku] #466066
05/23/17 17:51
05/23/17 17:51
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
So if a function takes long to execute, the program will slow down or pause until that function completes, then moves to the next instruction?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466069
05/23/17 20:44
05/23/17 20:44
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
I have changed the arrays to:

int node_to_node[9999999]; // youll see that this is seven 9's!

The reason why I am trying this is to see how many nodes I can make, and how big the paths can get. This int works when my AIs are running around, after the level computes and fills this big array.

But saving the int Array and loading the int Array is where im running into problems again:

memcpy(node_2_nodeCopy_i,node_to_node,9999999); //saving

-------------

memcpy(node_to_node,node_2_nodeCopy_i,9999999); // loading


Do I need to add sizeof() again here? I tried 9999999*4, 9999999*sizeof(int), 9999999*sizeof(var), but none of these copy over correctly. What did I do wrong here?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466071
05/24/17 02:38
05/24/17 02:38
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
what does: int node_to_node[9999999]; do?

Does it create 9999999 different slots that each store regular VAR? Or does it create that many slots with 9999999 integers?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466085
05/24/17 13:56
05/24/17 13:56
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland
Try memcpy(node_to_node,node_2_nodeCopy_i,sizeof(node_to_node));

int node_to_node[9999999]; creates an uninitialized array of 9999999 integers.

You can create as many nodes as you like until your stack is full which will crash your game.

When a function was started the program will only jump to the following function/instruction after the current function is completely done, that's correct. If your function takes a lot of time your framerate will drop because acknex has to wait until all your functions are done to render the image to the screen.

Re: How to save the contents of an array, WRS/resource [Re: Ezzett] #466090
05/24/17 15:43
05/24/17 15:43
Joined: Apr 2002
Posts: 1,246
ny
jumpman Offline OP
Serious User
jumpman  Offline OP
Serious User

Joined: Apr 2002
Posts: 1,246
ny
Thank you Ezzett.

int node_to_node[9999999]; worked until I saved the game. GS ran out of memory lol.

How do I see the stack? Is that an allocated memory area I can monitor?

Re: How to save the contents of an array, WRS/resource [Re: jumpman] #466094
05/24/17 17:12
05/24/17 17:12
Joined: Aug 2003
Posts: 118
Deutschland
E
Ezzett Offline
Member
Ezzett  Offline
Member
E

Joined: Aug 2003
Posts: 118
Deutschland

Page 3 of 3 1 2 3

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1