Gamestudio Links
Zorro Links
Newest Posts
ZorroGPT
by TipmyPip. 02/27/26 22:06
WFO Training with parallel cores Zorro64
by Martin_HH. 02/26/26 16:03
Zorro version 3.0 prerelease!
by TipmyPip. 02/25/26 16:38
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (AndrewAMD, Quad), 5,104 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
the1, alx, ApprenticeInMuc, PatrickH90, USER0328
19200 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 | 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