|
0 registered members (),
1,738
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
my pointer, strange behavior
#231168
10/12/08 16:11
10/12/08 16:11
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Hi! I noticed that Lite-C handles my pointers total different than C-Script. 2 examples:
function blabla()
{
...
ent_create("test.mdl",nullvector,test);
...
}
function new_test()
{
my = 0;
}
function test()
{
new_test();
my.skill1 = 0; //Crash because my got invalid?!
}
In c-script the my pointer was still valid!
function blabla()
{
...
ent_create("test.mdl",nullvector,test);
...
}
function new_test()
{
my = ent_create("test2.mdl",nullvector,null);
my.skill1 = 1;
}
function test()
{
new_test();
if(my.skill1 == 1) {error("Test!");} //this if will be true because the my pointer suddenly points on the other entity ^^
}
To say it in one sentence: You can change the my pointer of a function from another function. Ok "can" is the wrong word, you have to, and this is realy anoying!!! I can't imagine that this should be like that, so I guess it's a bug (or a really anoying feature  ). Thanks! Dark_Samurai
Last edited by Dark_samurai; 10/12/08 16:16.
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: my pointer, strange behavior
[Re: Dark_samurai]
#231722
10/16/08 15:41
10/16/08 15:41
|
Joined: Jul 2000
Posts: 28,133 Frankfurt
jcl

Chief Engineer
|

Chief Engineer
Joined: Jul 2000
Posts: 28,133
Frankfurt
|
This is perfectly normal - it's the difference between global and local variables. See: http://manual.conitec.net/aarray.htm"my" is a global pointer, and when you call a function that changes it, it's changed. This is an example of a local pointer: function new_test() { ENTITY* ent = ent_create("test2.mdl",nullvector,null); ent.skill1 = 1; } Hope this helps...
|
|
|
Re: my pointer, strange behavior
[Re: jcl]
#231863
10/17/08 12:05
10/17/08 12:05
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Why the hell is my a global Pointer?????? My never was a global Pointer in c-script! My always was a local Pointer! Can you tell me whats the sense behind making my to a global Pointer? Just imagine this:
action rotate
{
while(1)
{
my.pan += 1*time_step;
wait(1);
}
}
If I would use my somewhere else, the my pointer would suddenly also point in the action to the other entity! Total unlogical if you ask me, because my should point to the entity which started the function! I realy have no clue why you changed this, and please note such important changes in the manual!!!! Dark_Samurai
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: my pointer, strange behavior
[Re: Dark_samurai]
#231864
10/17/08 12:07
10/17/08 12:07
|
Joined: Oct 2007
Posts: 5,211 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,211
İstanbul, Turkey
|
ecause my should point to the entity which started the function!
it already does this.
3333333333
|
|
|
Re: my pointer, strange behavior
[Re: Quad]
#231866
10/17/08 12:12
10/17/08 12:12
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
If it's a global Pointer, then it can only point on one Entity at the same time. So how should it point on hundreds of different entities at the same time???
I don't understand why it's not like in c-script? It was a local Pointer there!
edit: I think you know that a function is automatically stopped after the entity which started the function is removed. To avoid this, it was always possible to set my to NULL and now because of your clever desicion to change the behavior of the my pointer, you get a crash because suddenly all the other functions have a my pointer which points on nothing. NICE!
Dark_Samurai
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: my pointer, strange behavior
[Re: Dark_samurai]
#231869
10/17/08 13:02
10/17/08 13:02
|
Joined: Mar 2002
Posts: 1,774 Magdeburg
FlorianP
Serious User
|
Serious User
Joined: Mar 2002
Posts: 1,774
Magdeburg
|
my is a global pointer. C-Script just sets it at the start of an action to the entity - without explicitly overloading. That haven't changed in lite-c. edit: I think you know that a function is automatically stopped after the entity which started the function is removed. To avoid this, it was always possible to set my to NULL and now because of your clever desicion to change the behavior of the my pointer, you get a crash because suddenly all the other functions have a my pointer which points on nothing. NICE! I can't remember such a feature oO
Last edited by FlorianP; 10/17/08 13:06.
I <3 LINQ
|
|
|
Re: my pointer, strange behavior
[Re: FlorianP]
#231870
10/17/08 13:25
10/17/08 13:25
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
But if it's still the same like in c-script, why are the examples I posted in my first post handled different in lite-c and c-script? edit: I think you know that a function is automatically stopped after the entity which started the function is removed. To avoid this, it was always possible to set my to NULL and now because of your clever desicion to change the behavior of the my pointer, you get a crash because suddenly all the other functions have a my pointer which points on nothing. NICE! Because of this fact, I would love to see something like this: http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=230512#Post230512Dark_Samurai
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
Re: my pointer, strange behavior
[Re: jcl]
#231880
10/17/08 14:17
10/17/08 14:17
|
Joined: Jul 2005
Posts: 1,930 Austria
Dark_samurai
OP
Serious User
|
OP
Serious User
Joined: Jul 2005
Posts: 1,930
Austria
|
Ok, thanks for clearing that up!
Dark_Samurai
ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)! get free version
|
|
|
|