Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (AndrewAMD, monk12, TipmyPip, Quad, aliswee), 1,029 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
[SOLVED]empty pointer error #450685
04/20/15 19:03
04/20/15 19:03
Joined: Oct 2013
Posts: 31
JerahYalyn Offline OP
Newbie
JerahYalyn  Offline OP
Newbie

Joined: Oct 2013
Posts: 31
I made a simple 3x3 ocean tile by creating a main hmp terrain and adding the action water_prop()

Code:
//create main body of water in the center
ENTITY* water = ent_create("map_models\\water.hmp",vector(0,0,0),water_prop);



and the water_prop action
Code:
action water_prop()
{
        Water_shaders
        //create tile water terrains
	VECTOR* temp1,temp2;
        var water_len;
	//get the length of the 32x32 vertex hmp
	vec_for_vertex(temp1, me, 1);
	vec_for_vertex(temp2, me, 32);
	water_len = vec_dist(temp1,temp2);

	//create 8 more terrain to tile
	ENTITY* water1 = ent_create("map_models\\water.hmp",vector(0,water_len,0),Water_shaders);
	ENTITY* water2 = ent_create("map_models\\water.hmp",vector(water_len,0,0),Water_shaders);
	ENTITY* water3 = ent_create("map_models\\water.hmp",vector(0,-water_len,0),Water_shaders);
	ENTITY* water4 = ent_create("map_models\\water.hmp",vector(-water_len,0,0),Water_shaders);
	
	ENTITY* water5 = ent_create("map_models\\water.hmp",vector(water_len,water_len,0),Water_shaders);
	ENTITY* water6 = ent_create("map_models\\water.hmp",vector(-water_len,water_len,0),Water_shaders);
	ENTITY* water7 = ent_create("map_models\\water.hmp",vector(water_len,-water_len,0),Water_shaders);
	ENTITY* water8 = ent_create("map_models\\water.hmp",vector(-water_len,-water_len,0),Water_shaders);
}



It returns error W1501 Empty pointer in water_prop.

I run the code line by line by adding the line one by one and I get the error when I add vec_for_vertex(temp2, me, 32).
however when I one or two water hmp error doesn't show unless I add another hmp. Which kinda confuses me. without adding hmp error is with vec_for_vertex and when I add more than 2 error is on the next ent_create. Can anyone enlighten me?

thanks!

Last edited by JerahYalyn; 04/24/15 18:16.
Re: empty pointer error [Re: JerahYalyn] #450686
04/20/15 19:10
04/20/15 19:10
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
You are using invalid VECTOR* pointers, i.e. temp1 and temp2. Just remove the * and you will be fine, and make sure you understand why and where the difference lies!


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: empty pointer error [Re: Superku] #450688
04/20/15 19:28
04/20/15 19:28
Joined: Oct 2013
Posts: 31
JerahYalyn Offline OP
Newbie
JerahYalyn  Offline OP
Newbie

Joined: Oct 2013
Posts: 31
Woops, forgot it was local. Sorry about that. XD

Re: empty pointer error [Re: JerahYalyn] #450689
04/20/15 19:38
04/20/15 19:38
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
(Writing VECTOR* locally or globally, meaning outside of the function, doesn't make any difference here, if that is what you mean.)


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: empty pointer error [Re: Superku] #450705
04/21/15 02:28
04/21/15 02:28
Joined: Oct 2013
Posts: 31
JerahYalyn Offline OP
Newbie
JerahYalyn  Offline OP
Newbie

Joined: Oct 2013
Posts: 31
tongue then what is the difference of pointer VECTOR and normal vector. Strange because even though the pointer is invalid it was able to align the hmp for the first two entity before realizing the pointer was invalid.

Last edited by JerahYalyn; 04/21/15 02:28.
Re: empty pointer error [Re: JerahYalyn] #450706
04/21/15 02:46
04/21/15 02:46

M
Malice
Unregistered
Malice
Unregistered
M



I will take a guess, VECTOR* is a point to a struct VECTOR is a copy of a struct and vector() is a engine function.

Also VECTOR is not a object, I think like a ENTITY* or PANEL*

Last edited by Malice; 04/21/15 02:49.
Re: empty pointer error [Re: ] #450711
04/21/15 04:08
04/21/15 04:08
Joined: Oct 2013
Posts: 31
JerahYalyn Offline OP
Newbie
JerahYalyn  Offline OP
Newbie

Joined: Oct 2013
Posts: 31
Nevertheless it works now. Except for a small issue that the terrain disapear when I leave the main water hmp.

Re: empty pointer error [Re: JerahYalyn] #450714
04/21/15 05:53
04/21/15 05:53
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Originally Posted By: JerahYalyn
Strange because even though the pointer is invalid it was able to align the hmp for the first two entity before realizing the pointer was invalid.

This is not anything you should read into. Passing uninitialized references (pointers) as value arguments is a terrible mistake that can result in all kinds of unusual behavior, though it usually manifests as a simple crash like what you experienced. Also, any better compiler would've smacked you for that, but Lite-C doesn't because it's a bit shite.

And if you don't understand the difference between a normal variable and a pointer, I implore you to read about it and figure it out, not only because pointers are extremely important and useful in their own right, but because the difference between VECTOR and VECTOR*, var and var*, and int and int* is huge and you will run into countless problems if you use them interchangeably like that.


Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: empty pointer error [Re: Redeemer] #450725
04/21/15 13:04
04/21/15 13:04
Joined: Apr 2015
Posts: 20
Vietnam
F
Florastamine Offline
Newbie
Florastamine  Offline
Newbie
F

Joined: Apr 2015
Posts: 20
Vietnam
A pointer is not the same as a normal variable. A pointer points to something (variables). You can reference to the variable's value through that pointer.

A pointer contains the address of the variable it points to. While a variable contains the actual value.

So, your VECTOR * points to nothing, and thus yield "W1501 Empty pointer". You have to create a VECTOR struct and make the pointer points to that struct:
Code:
VECTOR v;
v.x = 5;
v.y = 2;
v.z = 1;

VECTOR *vp = &v; /* makes vp points to v */
<...>
vec_set(vp, ..);
vec_add(vp, ..);
<...>



Or, use the pointer directly:
Code:
VECTOR *vp = malloc(sizeof(VECTOR)); /* Allocates the memory needed for a VECTOR struct where vp will point to */
vec_set(vp, vector(5, 2, 1));



grin

Last edited by Florastamine; 04/21/15 13:06.
Re: empty pointer error [Re: Florastamine] #450850
04/23/15 19:26
04/23/15 19:26
Joined: Oct 2013
Posts: 31
JerahYalyn Offline OP
Newbie
JerahYalyn  Offline OP
Newbie

Joined: Oct 2013
Posts: 31
I don't want to open another topic for another problem. Any one can tell me what I'm doing wrong in using c_scan? Basically I run c_scan to and try to get the nearest vertex to the contact point and get its coordinates. I'm scanning a terrain hmp.

my code for scanning terrain with c_trace
Code:
var vi;
void camera_scan()
{
        
	VECTOR tempv,temp;
	while(1)
	{
                
		if(mouse_left) //scan while left mouse if pressed
		{
		   tempv.x = mouse_pos.x;
		   tempv.y = mouse_pos.y;
		   tempv.z = 2000;
		   vec_for_screen(tempv,camera);
		   c_trace(camera.x, tempv, IGNORE_ME);
                   //get vertex coordinate with vec_for_vertex
		   vec_for_vertex(temp,hit.entity,hit.vertex); //if fails to return hit.vertex
	           vi = hit.vertex; //store it for panel
                  //Debugging draw point of contact and nearest vertex then draw a line between.
                  draw_point3d(temp.x,vector(0,0,255),100,300);
	          draw_point3d(vector(hit.x,hit.y,hit.z),vector(0,0,255),100,300);
                  draw_line3d(vector(hit.x,hit.y,hit.z),vector(0,0,255),100);
                 draw_line3d(temp.x,vector(0,0,255),100);
			
		}
		wait(1);
	}
}



The problem is with hit.vertex returning nothing and vec_for_vertex always returns the coordinate of the first vertex regardless of the hit position. What am I doing wrong?

here is how it look in my test. Ignore the float in vertex index, I forgot to change the format. But clearly vertex index never updated.


Last edited by JerahYalyn; 04/23/15 19:36.
Page 1 of 2 1 2

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