1 registered members (1 invisible),
672
guests, and 0
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: jumpman]
#466027
05/22/17 00:48
05/22/17 00:48
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
Any. Binary files are an obscure Windows concept which doesn't exist on virtually any other OS (as in, all files are binary, cause that's what they are!).
In any case, there is no such thing as a file type. You can write jpeg data into a word file, because files are just binary data on disk. Windows tries really really hard to tell you that file types are a thing via extensions, but again, you can write binary data in a .txt file just fine. Obviously, users might expect certain conventions, eg that txt files contain readable text and not random binary nonsense. But who cares, it's not like anyone is going to drag you in front of the file system court.
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: WretchedSid]
#466028
05/22/17 02:09
05/22/17 02:09
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
I.....did not know that. Well I knew, but I didn't know you could just save it out like that in gamestudio. So I made up an extension and saved it out, and was able to open and read it So I could also bind these in a wrs, so they aren't seperate files correct? Thank you wretchedsid!!!!
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: Superku]
#466040
05/22/17 15:39
05/22/17 15:39
|
Joined: Dec 2011
Posts: 1,823 Netherlands
Reconnoiter
Serious User
|
Serious User
Joined: Dec 2011
Posts: 1,823
Netherlands
|
Go to GStudio8 -> data -> options.scr, open it with a text editor, find EXCLUDE_RESOURCE = "WRS;TMP;AVI;MPG;MOV;DLL;C;H;XML;LOG;TXT;PNG" , for me personally this is already correct (maybe I changed it earlier or cause of new version, cannot remember). Also kindy funny that you can remove wrs from it, so you can have wrs files within your wrs files.
Last edited by Reconnoiter; 05/22/17 15:40.
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: Reconnoiter]
#466044
05/22/17 19:30
05/22/17 19:30
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Hi friends. A small update. I was having alot of trouble when it came to pathfinding and reading values from an array. When the level computes the paths in the beginning and fills the array, the AI's move normally But when I saved out this same array to a txt file, thats where things got bad. (I wanted to save to TXT to save from having to compute the A* every time the level is loaded) When my AI's were using the array that was filled from a TXT file, they glitched out and gave me a bunch of errors I've been wracking my brain trying to figure out. Tried alot of different things and still couldnt get it to work. Making sure it was filling the correct values, looking at huge notepads with too many numbers, seeing if the index was off etc etc But then I tried game_save! with SV_INFO as the flag, and then renaming this big path array with an _i at the end, I was able to load the saved array into the level using memcpy, without having to reload the level. I will do more testing, but here is pseudo code of what I plan to do: main() 1.find the level_name of the level 2.see if there is a saved Node.sav that matches the level name 3.if there is a save file that exists, that means the paths were computed 4.Load the .sav game then memcpy the path array into the working path array 5.Run level 6.If there is no save file that matches the level name 7.Run path calculation and fill the array 8.Create a save file and save the _i arrays 9.Run level The initial TXT file was also pretty big. I made a worse case scenario, with an array of 999999, with a 0 in every slot, and this txt file came out to be around 5 megs. But saving these arrays in a .sav, the .sav comes out to be only 461 kilobites! The manual says .savs are compressed
Last edited by jumpman; 05/22/17 19:35.
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: jumpman]
#466048
05/23/17 02:30
05/23/17 02:30
|
Joined: Apr 2007
Posts: 3,751 Canada
WretchedSid
Expert
|
Expert
Joined: Apr 2007
Posts: 3,751
Canada
|
@jumpman that doesn't sound right, can you show us some code?
Shitlord by trade and passion. Graphics programmer at Laminar Research. I write blog posts at feresignum.com
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: WretchedSid]
#466050
05/23/17 04:24
05/23/17 04:24
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
OP
Serious User
Joined: Apr 2002
Posts: 1,246
ny
|
Hi wretchedsid: //----------------These 2 arrays are the "working" arrays var node_to_node[999999]; var visited[999999]; //----------------These 2 arrays are the ones saved in a .Sav file var node_2_nodeCopy_i[999999]; var visited_i[999999];
memcpy(node_2_nodeCopy_i,node_to_node,999999); //
wait(1);
memcpy(visited_i,visited,999999);
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: jumpman]
#466060
05/23/17 14:12
05/23/17 14:12
|
Joined: Oct 2011
Posts: 1,082 Germany
Ch40zzC0d3r
Serious User
|
Serious User
Joined: Oct 2011
Posts: 1,082
Germany
|
memcpy copies byte wise, var is 4 bytes. You have to multiply the memcpy size by 4 => sizeof(var) to copy the whole array.
Last edited by Ch40zzC0d3r; 05/23/17 14:13.
|
|
|
Re: How to save the contents of an array, WRS/resource
[Re: Ch40zzC0d3r]
#466061
05/23/17 14:46
05/23/17 14:46
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
Yes, it can deal with 3D stuff and multiple floors and stairs, as long as you set it up correctly (WED paths and regions - the region system is for bigger levels or when you know enemies won't leave that area - if they are supposed to move between different regions then there cannot be obstacles, think open world for example where regions are placed around houses or villages or forests). The number of nodes is not limited by my code, instead by Gamestudio limits/ max_paths or what that stuff is called (you would probably never hit that limit). It finds the correct path in linear time so it's fine to use paths with a big number of nodes, however not necessarily the shortest path (in quants). It calculates the shortest path based on the number of nodes instead. Just place some extra nodes on long edges to equalize their "weight" in the pathfinding algorithm (- as a result you can make enemies avoid certain dangerous paths by placing extra nodes there).
Whoever thinks that's not acceptable that the path might not be the shortest 100% of the time... then you're probably not a game dev to begin with, at least not someone who fill finish and release a game. (which I know you are and you do, @jumpman - I got that feedback before though)
Last edited by Superku; 05/23/17 14:48.
"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: jumpman]
#466065
05/23/17 16:22
05/23/17 16:22
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
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: jumpman]
#466069
05/23/17 20:44
05/23/17 20:44
|
Joined: Apr 2002
Posts: 1,246 ny
jumpman
OP
Serious User
|
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?
|
|
|
|