Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood), 1,268 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19053 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Weird ptr_for_handle behavior on valid handles #338912
08/22/10 17:34
08/22/10 17:34
Joined: Mar 2009
Posts: 23
S
Siegewolf Offline OP
Newbie
Siegewolf  Offline OP
Newbie
S

Joined: Mar 2009
Posts: 23
I had a problem:

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=338835&#Post338835

Saturnus and EvilSOB have kindly reduced it to a small test case. This was my code:

Code:
#include <acknex.h>
#include <default.c>


ENTITY* plane_player;


#define TEXT_HANDLE skill73
#define ALIVE skill90


PANEL* main_menu_pan =
{
	pos_x = 520;
	pos_y = 500;

	layer = 2;
	alpha = 100;
}

TEXT* comm_speech_txt =
{
	pos_x = 100;
	pos_y = 150;
	
	string("");
	
	layer = 10;
	alpha = 100;
}


function set_text(TEXT *text, int ncol, STRING* s)
{
	str_cpy((text.pstring)[0], s);
}


action player_action()
{
	me.ALIVE = 1;
	
	player = me;
	
	wait(1);
	while(me.ALIVE)
	{
		wait(1);
	}
}

action enemy_action()
{
	me.ALIVE = 1;
	
	TEXT* comm_speech_npc_txt = txt_create(1,10);
	me.TEXT_HANDLE = handle(comm_speech_npc_txt);
	
	comm_speech_npc_txt.red = 135;
	comm_speech_npc_txt.green = 155;
	comm_speech_npc_txt.blue = 253;
	comm_speech_npc_txt.alpha = 70;
	comm_speech_npc_txt.flags = VISIBLE | TRANSLUCENT | SHADOW;
	
	wait(1);
	
	while (me.ALIVE)
	{
		wait(1);
	}
}


function conversation_01(ENTITY* air1, ENTITY* air2, ENTITY* air3)
{
	TEXT* text1 = ptr_for_handle(air1.TEXT_HANDLE);
	TEXT* text2 = ptr_for_handle(air2.TEXT_HANDLE);
	TEXT* text3 = ptr_for_handle(air3.TEXT_HANDLE);
	
	comm_speech_txt.red = 255; comm_speech_txt.green = 255; comm_speech_txt.blue = 255;
	comm_speech_txt.flags = VISIBLE | TRANSLUCENT | SHADOW;
	set_text(comm_speech_txt, 35, "blah1");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 0; comm_speech_txt.blue = 0;
	set_text(comm_speech_txt, 35, "...");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 255; comm_speech_txt.blue = 255;
	set_text(comm_speech_txt, 35, "blah2");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 0; comm_speech_txt.blue = 0;
	set_text(comm_speech_txt, 35, "...");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 255; comm_speech_txt.blue = 255;
	set_text(comm_speech_txt, 35, "blah3");
	wait(-1);
	text2.red = 150; text2.green = 150; text2.blue = 150;
	set_text(text2, 35, "blah4");
	wait(-5);
	set_text(comm_speech_txt, 35, "blah5");
	wait(-1);
	text3.red = 150; text3.green = 150; text3.blue = 150;
	set_text(text2, 35, "");
	set_text(text3, 35, "blah6");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 0; comm_speech_txt.blue = 0; // Osavolk
	set_text(comm_speech_txt, 35, "blah7");
	wait(-1);
	text1.red = 150; text1.green = 150; text1.blue = 150;
	set_text(text3, 35, "");
	set_text(text1, 35, "...");
	wait(-5);
	comm_speech_txt.flags = 0;
	set_text(text1, 35, "blah8");
	wait(-5);
	set_text(text1, 35, "blah9");
	wait(-5);
	set_text(text1, 35, "");
	set_text(text2, 35, "blah10");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 0; comm_speech_txt.blue = 0;
	comm_speech_txt.flags = VISIBLE | TRANSLUCENT | SHADOW;
	set_text(text2, 35, "");
	set_text(comm_speech_txt, 35, "blah11");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 255; comm_speech_txt.blue = 255;
	set_text(comm_speech_txt, 35, "blah12");
	wait(-5);
	set_text(comm_speech_txt, 35, "blah13");
	wait(-5);
	comm_speech_txt.red = 255; comm_speech_txt.green = 0; comm_speech_txt.blue = 0;
	set_text(comm_speech_txt, 35, "blah14");
	wait(-3);
	set_text(comm_speech_txt, 35, "blah15");
	wait(-5);
	comm_speech_txt.flags = 0;
}


function level_01()
{
	level_load ("");
	
	ENTITY* air1; ENTITY* air2; ENTITY* air3;
	
	air1 = ent_create(CUBE_MDL, vector(camera.x + 200, camera.y + 1400, camera.z + 200), enemy_action);
	air2 = ent_create(CUBE_MDL, vector(camera.x + 250, camera.y + 2200, camera.z - 100), enemy_action);
	air3 = ent_create(CUBE_MDL, vector(camera.x + 200, camera.y + 600, camera.z - 100), enemy_action);
	
	plane_player = ent_create(CUBE_MDL, vector(0, 0, 9800), player_action);
	plane_player.skin = 2;
	plane_player.pan = 180;
	
	wait(-4);
	
	conversation_01(air1, air2, air3);
	wait_for(conversation_01);
}


function main()
{
	video_mode = 9;
	video_screen = 1;
	wait(1);
	
	level_01();
}



and this is the reduced test case:

Code:
#include <acknex.h>

PANEL* pnl1 =
{
	layer = 2;
}

void main()
{
	level_load(NULL);
	
	int i;
	for (i = 0; i < 3; i++)
	{
		TEXT* my_txt = txt_create(1,10);
		var my_handle = handle(my_txt);
		my_txt = ptr_for_handle(my_handle);
		
		if (!my_txt)
		{
			printf("NULL pointer (handle: %i | hbyte: %i)",
				my_handle, my_handle >> 14);
		}
		else
		{
			printf("pointer OK (handle: %i | hbyte: %i)",
				my_handle, my_handle >> 14);
		}
	}
}



In both codes, ptr_for_handle sometimes fail to return the pointer for valid handle.

Gamestudio 7.82 (tried 7.85 too)
Windows XP SP3
ATI Radeon & catalyst 10.6

Re: Weird ptr_for_handle behavior on valid handles [Re: Siegewolf] #340621
09/06/10 08:53
09/06/10 08:53
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Thanks! This was indeed a bug. It will be fixed in the next version.


Moderated by  jcl, Nems, Spirit, Tobias 

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