Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 20:05
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
1 registered members (AndrewAMD), 1,392 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problems with structs #239385
12/04/08 12:49
12/04/08 12:49
Joined: Oct 2008
Posts: 10
Italy
Romeoxbm Offline OP
Newbie
Romeoxbm  Offline OP
Newbie

Joined: Oct 2008
Posts: 10
Italy
Hi all!!!
I've got a problem with two nested structs...declared in this way:

Code:
typedef struct 
{
	ENTITY* character;
	STRING* sentence_content;
	STRING* oggFile;
} *sentence;

typedef struct
{
	STRING* dialogueName;
	int sentenceCount;
	sentence sentenceArray[100];
} *dialogue;


int dialoguesCount = 1;
dialogue dialoguesArray;


I've got a crash into this function:

Code:
function dialogues_init()
{
	if (Character1 == NULL)
		Character1 = ent_create("sf_alien.mdl", vector(-50,0,0), NULL );
	
	if (Character2 == NULL)
		Character2 = ent_create("marine.mdl", vector(50,100,0), NULL );
		
		
	dialoguesArray = (dialogue*)malloc(dialoguesCount*sizeof(dialogue));
	
	dialoguesArray[0].sentenceCount = 3;
	dialoguesArray[0].dialogueName = str_create("testDialog");
	
	dialoguesArray[0].sentenceArray[0].sentence_content = str_create("Jack - Hi!");
	dialoguesArray[0].sentenceArray[0].oggFile = str_create("dialog00.ogg");
	dialoguesArray[0].sentenceArray[0].character = Character1;
	
	dialoguesArray[0].sentenceArray[1].sentence_content = str_create("John - Hi Jack!! What's up?");
	dialoguesArray[0].sentenceArray[1].oggFile = str_create("dialog01.ogg");
	dialoguesArray[0].sentenceArray[1].character = Character2;
	
	dialoguesArray[0].sentenceArray[2].sentence_content = str_create("Jack - Fine");
	dialoguesArray[0].sentenceArray[2].oggFile = str_create("dialog02.ogg");
	dialoguesArray[0].sentenceArray[2].character = Character1;
}


precisely, i've got (Error E1513 crash in dialogues_init) in the following code line:

Code:
dialoguesArray[0].sentenceArray[1].sentence_content = str_create("John - Hi Jack!! What's up?");


Re: Problems with structs [Re: Romeoxbm] #239408
12/04/08 15:33
12/04/08 15:33
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
na mach mal den typedef ... *sentence zu typedef ... sentence. Ich glaube du allokierst nur Pointer.

Re: Problems with structs [Re: Joey] #239422
12/04/08 16:16
12/04/08 16:16
Joined: Jul 2008
Posts: 27
Italy, Sicilia, Palermo
Azrael85 Offline
Newbie
Azrael85  Offline
Newbie

Joined: Jul 2008
Posts: 27
Italy, Sicilia, Palermo
please can you tell us in english?

Re: Problems with structs [Re: Azrael85] #239470
12/04/08 20:56
12/04/08 20:56
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
Joey said that you don't have to write stars in front of the struct definition name, so it should be "typedef struct { ... } dialog;" and "typedef struct { ... } sentence;".


Always learn from history, to be sure you make the same mistakes again...
Re: Problems with structs [Re: Uhrwerk] #239483
12/04/08 22:04
12/04/08 22:04
Joined: Jan 2003
Posts: 4,615
Cambridge
Joey Offline
Expert
Joey  Offline
Expert

Joined: Jan 2003
Posts: 4,615
Cambridge
sorry for not writing in english, i oversaw that the thread wasn't in german. just follow uhrwerk's translation (thanks uhrwerk).


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