Gamestudio Links
Zorro Links
Newest Posts
[MED] Import from FBX (2010) missing!!!
by USER0328. 09/03/26 18:03
Purchase A8 full licence version
by ukgamer. 08/30/26 14:27
ZorroGPT
by TipmyPip. 08/29/26 06:56
Retrieve optimize() variables order (edited)
by NorbertSz. 08/25/26 13:24
Max Number of Strategies in /Strategy folder
by Martin_HH. 08/17/26 07:54
Pause button for evaluation shell?
by AndrewAMD. 08/13/26 17:16
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 08/10/26 12:46
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
0 registered members (), 1,738 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
riggi89, shuhari, KD1990, Student_64151, Koti
19230 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
my pointer, strange behavior #231168
10/12/08 16:11
10/12/08 16:11
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline OP
Serious User
Dark_samurai  Offline 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:

Code:
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!

Code:
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 wink ).

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 Offline

Chief Engineer
jcl  Offline

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 Offline OP
Serious User
Dark_samurai  Offline 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:

Code:
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 Offline
Senior Expert
Quad  Offline
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 Offline OP
Serious User
Dark_samurai  Offline 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
F
FlorianP Offline
Serious User
FlorianP  Offline
Serious User
F

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.

Originally Posted By: Dark_samurai
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 Offline OP
Serious User
Dark_samurai  Offline 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?

Quote:
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#Post230512

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] #231872
10/17/08 13:38
10/17/08 13:38
Joined: Jul 2000
Posts: 28,133
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 28,133
Frankfurt
To answer your question: The reason is that lite-C was designed to be C compatible.

In C, variables defined outside a function are global. That includes all engine variables listed in avars.h, including the my and you pointers.

The C-Script language contained some 'gaps' with undefined behavior. For instance, it was undefined whether variables saved together with functions - such as my and you - could be changed by calling a subfunction. In fact they couldn't. So that was an exception to the global variable rule. lite-C behaves more logical in that regard.

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 Offline OP
Serious User
Dark_samurai  Offline 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

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

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