Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
1 registered members (TipmyPip), 18,606 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
ENTITY* Array.. is that possible? #333321
07/15/10 19:06
07/15/10 19:06
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Hi,

I'm trying to use an array of entity pointer.
this is the declaration of it:
Code:
ENTITY* next1[50];


But this line makes a crash everytime:
Code:
while(next1[j].connected[i] != 0) { }


So my first question: Is it possible to use such an array?
If yes, is there something special with such an array?


Thanks for reading, thinking, answering wink
Re: ENTITY* Array.. is that possible? [Re: Toryno] #333322
07/15/10 19:13
07/15/10 19:13
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Yes it is possible.
There is one thing you might call special is that you have to create the entities in your arrays before using their pointers.

And if "connected" is a define for a certain skill, then remove the [i]. wink

Re: ENTITY* Array.. is that possible? [Re: Toryno] #333324
07/15/10 19:15
07/15/10 19:15
Joined: Sep 2009
Posts: 1,032
Budapest
Aku_Aku Offline
Serious User
Aku_Aku  Offline
Serious User

Joined: Sep 2009
Posts: 1,032
Budapest
Of course that array should work.
Perhaps your skill isn't defined well...
Should post relevant parts of your code.

Last edited by Aku_Aku; 07/15/10 19:15.
Re: ENTITY* Array.. is that possible? [Re: Lukas] #333325
07/15/10 19:23
07/15/10 19:23
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
Oh yes there is a define
Code:
#define connected skill


in the manual stands "skill70" can also be written so "skill[70]", so that won't be the problem. I use this in other functions too and they work fine.


Could it be that the line at the end of this post is the problem?
ent_tmp is a pointer to an entity, too.
Is this a misstake?

Code:
next1[0] = ent_tmp;



Last edited by Toryno; 07/15/10 19:47.

Thanks for reading, thinking, answering wink
Re: ENTITY* Array.. is that possible? [Re: Toryno] #333328
07/15/10 19:30
07/15/10 19:30
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
Alright, if that's how you define connect, then the [i] is justified. But be aware that skill70 is skill[69], not skill[70] (because it begins with skill[0] wink ).

If ent_tmp points to a valid entitiy it should work. To be totally sure, you should make all ENTITY* pointers be NULL when they don't point to an entity. Then you can alway check if(entitiy) to see if it's valid.

Re: ENTITY* Array.. is that possible? [Re: Toryno] #333329
07/15/10 19:30
07/15/10 19:30
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
look at your code!
Code:
#define connect skill
...
while(next1[j].connected[i] != 0) { }


it should be:
Code:
#define connect skill
...
while(next1[j].connect[i] != 0) { }


or
Code:
#define connected skill
...
while(next1[j].connected[i] != 0) { }




Visit my site: www.masterq32.de
Re: ENTITY* Array.. is that possible? [Re: MasterQ32] #333332
07/15/10 19:43
07/15/10 19:43
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
@Lukas: Now I make the whole array NULL and now it works. Know I will make it with EVERY variable, pointer, array or what ever. Thank you =D

@Richi007: I just wrote "#define connected skill" in the editor, only a typing mistake while i posted this post. I will change it if someone read this post later wink

Last edited by Toryno; 07/15/10 19:47.

Thanks for reading, thinking, answering wink
Re: ENTITY* Array.. is that possible? [Re: Toryno] #333367
07/15/10 22:21
07/15/10 22:21
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
I have another mysterious crash. Directly after the declaration of the array the lines work fine but later, when the array has changed always, I want to clear it with this lines but it crashes.

Code:
ENTITY* next1[50];

for(i = 0; i < 49; i++) {
	next1[i] = NULL; // no problem here
}
...
next1[0] = an_entity // example
...
for(i = 0; i < 49; i++) {
	next1[i] = NULL; // here it crashes
}



Last edited by Toryno; 07/15/10 23:03.

Thanks for reading, thinking, answering wink
Re: ENTITY* Array.. is that possible? [Re: Toryno] #333375
07/15/10 23:07
07/15/10 23:07
Joined: May 2007
Posts: 2,043
Germany
Lukas Offline

Programmer
Lukas  Offline

Programmer

Joined: May 2007
Posts: 2,043
Germany
First of all, use i<50 instead of i<49.
If the line you have pointed out is really the line where it crashes, the only thing I could imagine is that you may have changed next1 itself, like next1 = NULL; // without []-brackets

Re: ENTITY* Array.. is that possible? [Re: Lukas] #333380
07/16/10 00:03
07/16/10 00:03
Joined: Apr 2009
Posts: 138
Germany
T
Toryno Offline OP
Member
Toryno  Offline OP
Member
T

Joined: Apr 2009
Posts: 138
Germany
I don't know why, but after I changed some other things in my code, now this crash is away. Mysteroius! ^^ Sorry for steeling your time wink


Thanks for reading, thinking, answering wink

Gamestudio download | 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