Gamestudio Links
Zorro Links
Newest Posts
M1 Oversampling
by 11honza11. 04/26/24 08:32
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (Quad, EternallyCurious, RealSerious3D, 1 invisible), 839 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
is Vector must be ptr_remove? #470657
01/29/18 06:22
01/29/18 06:22
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Code:
VECTOR* tarPos = vector(x,y,0);
ptr_remove(tarPos);//is tarPos must be ptr_remove?any one know that?



development 3d game is interesting!
Re: is Vector must be ptr_remove? [Re: frankjiang] #470658
01/29/18 07:12
01/29/18 07:12
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
No, vector() returns a temporary vector, which means, it cycles through 64 pre-created vectors and returns a pointer to one of them (round robin style)

so if you remove a vector, you will most likely get a crash, but even if not, you won't get predictable behaviour and bugs one cannot comprehend

the function most likely looks something like this:

Code:
VECTOR storage[64];
int index = 0;

VECTOR * vector(var x, var y, var z)
{
    VECTOR * vec = &storage[index];
    index += 1;
    if(index >= 64)
        index = 0;
    vec->x = x;
    vec->y = y;
    vec->z = z;
    return vec;
}



Visit my site: www.masterq32.de
Re: is Vector must be ptr_remove? [Re: MasterQ32] #470659
01/29/18 07:24
01/29/18 07:24
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Originally Posted By: MasterQ32
No, vector() returns a temporary vector, which means, it cycles through 64 pre-created vectors and returns a pointer to one of them (round robin style)

so if you remove a vector, you will most likely get a crash, but even if not, you won't get predictable behaviour and bugs one cannot comprehend

the function most likely looks something like this:

Code:
VECTOR storage[64];
int index = 0;

VECTOR * vector(var x, var y, var z)
{
    VECTOR * vec = &storage[index];
    index += 1;
    if(index >= 64)
        index = 0;
    vec->x = x;
    vec->y = y;
    vec->z = z;
    return vec;
}



so your means is not need to ptr_remove?


development 3d game is interesting!
Re: is Vector must be ptr_remove? [Re: frankjiang] #470678
01/30/18 07:06
01/30/18 07:06
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline
Expert
MasterQ32  Offline
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
yes, don't ptr_remove. if you do, your program will have horribly bad errors, most probably in other parts of your code


Visit my site: www.masterq32.de
Re: is Vector must be ptr_remove? [Re: MasterQ32] #470686
01/30/18 13:10
01/30/18 13:10
Joined: Dec 2009
Posts: 128
China
frankjiang Offline OP
Member
frankjiang  Offline OP
Member

Joined: Dec 2009
Posts: 128
China
Ok ,i see,thank for your answer.


development 3d game is interesting!

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