Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,135 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Player Entity pointer is sometimes NULL after setting. #207821
05/22/08 13:18
05/22/08 13:18
Joined: Oct 2003
Posts: 130
Wollongong Australia
J
Jethro Offline OP
Member
Jethro  Offline OP
Member
J

Joined: Oct 2003
Posts: 130
Wollongong Australia
A7.07 Pro.
Heres another weird problem after upgrading from A6.314 to A7.07, this fault is also in A6.60.

In 2 functions in my code, the Engine defined Player Pointer is NULL even after it is set with Player = ME in our main player movement routine.
In many other functions in the code Player is infact set to a valid entity, and lets my code past the
While (Player==NULL) {Wait(1);} varification loop.

So to fix the broken functions, I use MY_Player=ME; and PLAYER=ME; to set the pointer, and use
While (MY_Player==NULL) {Wait(1);} to wait until it is set
if vec_dist(my.x,MY_player.x)<200 etc.....
This all works fine, what could be reason for flakey Player pointer.

Jethro ...

Re: Player Entity pointer is sometimes NULL after setting. [Re: Jethro] #207829
05/22/08 14:16
05/22/08 14:16
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
If I understood you right, the player pointer in your code was NULL and you solved this by setting it. This is certainly a correct and valid solution, however I'm not sure why you're posting this in "bugs" - what can we do to help?

Even if it might sometimes seem that goblins are changing pointers behind your back ;), I can assure you that pointers only get changed when you set them or when something happens to the object they point to. But if you have problems with an entity pointer in your code, just use the 'watched' variable for observing it.

Re: Player Entity pointer is sometimes NULL after setting. [Re: Jethro] #207902
05/23/08 00:22
05/23/08 00:22
Joined: Oct 2003
Posts: 130
Wollongong Australia
J
Jethro Offline OP
Member
Jethro  Offline OP
Member
J

Joined: Oct 2003
Posts: 130
Wollongong Australia
Sorry there must be a communications breakdown.

1 - I set Player = ME in main movement routine for player!
2 - Many functions in the game recognise this, 500 enemies are happy that the player pointer is set. Every tick these guys are doing a vec_dist with the player pointer with no problems.
3 - Another function DOES NOT get past the
While (Player==NULL) {Wait(1);}

The fix to this was make a new Entity Pointer MY_Player and monitor for that in the broken function with:-
While (My_Player==NULL) {wait(1);}
Continue here ....

I have been using this engine since A3.9 have 15 published games, this is my full time occupation, and I don't believe in goblins. I have developed an in game editor, 3d Text routines and games of every description with this brilliant engine.

In a nutshell there are a 2 functions since converting to A7.07 from A6.314, that simply don't see the correct status of the player Pointer. Note A6.6 also exhibits this anomoly, not sure about A6.4.

Our code base is huge with 40 included code files (.wdl) some of these files have over 8000 lines of code.
Could I have overflowed something?

The weird thing is this problem was NON EXISTANT IN A6.314!

Jethro.

Re: Player Entity pointer is sometimes NULL after setting. [Re: Jethro] #208027
05/24/08 09:40
05/24/08 09:40
Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,140
Baunatal, Germany
The player pointer is a global pointer and global pointers can not be NULL for one function and non NULL for another, because they are either NULL for all functions, or non NULL for all functions.

As a programmer I know the problem with the goblins and this sounds like one. Such problems always turn out to be a missing semicolon or setting something at the wrong moment or a = instead of == or the like. I think you can easily find out whats happening when you put a breakpoint in the function that does not get the player pointer correctly, and debug it single step wise.



Re: Player Entity pointer is sometimes NULL after setting. [Re: Tobias] #208046
05/24/08 12:24
05/24/08 12:24
Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
C
Christian__A Offline
User
Christian__A  Offline
User
C

Joined: Oct 2002
Posts: 799
Germany->Bavaria->Nuremberg
Search for all "player =" or "player=" in your code. I'm sure you will find a line in which you typed if (player=XYZ) instead of if (player==), as tobias said.


MfG, Christian__A. Visit my Site: www.chris-a.de


Re: Player Entity pointer is sometimes NULL after setting. [Re: Christian__A] #208064
05/24/08 14:21
05/24/08 14:21
Joined: Oct 2004
Posts: 262
Augsburg,Bayern
A
ARAS Offline
Member
ARAS  Offline
Member
A

Joined: Oct 2004
Posts: 262
Augsburg,Bayern
Hello Jethro,

i also have this problem. But i fixed it.

In your main-wdl you must first include the wdl-script with the "player = me" action.
And than include the other wdl-scripts with the "while(player==NULL)" loops.

Sometimes it helps.

MFG

aras

Re: Player Entity pointer is sometimes NULL after setting. [Re: ARAS] #208344
05/26/08 19:17
05/26/08 19:17
Joined: May 2008
Posts: 73
Richmond, VA (USA)
coma_dose Offline
Junior Member
coma_dose  Offline
Junior Member

Joined: May 2008
Posts: 73
Richmond, VA (USA)
I had a strange experience with a pointer, let's see if this occurance belongs in the bug hunt section:

An entity action was referring to itself using "my" like so.

Code:
while(me)
{
   my.pan -= 90;
   wait(1);
}


I start the game and I get an empty pointer error. Eh? So what I did was I inserted a beep; before and after the loop, and one at the beginning for good measure. Upon restarting the test run, I got two beeps; one at the beginning and one right before the loop, the third beep did not occur because the loop was running and therefore, "my" was a valid pointer. Needless to say I also got the empty pointer error as well.

How can a "while(me)" loop be running and at the same time the "my" pointer be empty, within an action assigned to an entity? There were no other bits of code setting "me" to null and the entity was not being removed. I clicked "OK" and continued to see my entity on screen, the FPS was seriously hit as usual when you "OK" past a script error on a test run.

How did I resolve this? I didn't; I removed the beep; functions and tested again and it worked fine.

Last question: How can the beep; function be the cause of an empty "my" pointer when the error occured before (and after, meaning it had its origins elsewhere)I placed the beep; function in the action? This was the most strange A7 goblin that I have ever seen.


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