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
2 registered members (AndrewAMD, kzhao), 901 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Handling problem struct pointer. #439028
03/25/14 17:43
03/25/14 17:43
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
Hello guys, Simon again:

after solving one week Problems at my self, there's one wich makes me sleepless nights...
... I try to code an inventory System - included with an item System.
It's in the beginning. Please read this code and tell me why the engine tells my while pressing 't' "Engine Error in "give_item""
Code:
//includes
...

typedef struct ITEM
{
   int it_id;
   BMAP* it_bmap;
} ITEM;

ITEM* item_001 = malloc(sizeof(ITEM));
   item_001.it_id = 001;
   item_001.it_id = "item_001.png";

give_item()
{
   pan_inventory_slot.bmap = item_001.bmap;
}

void main()
{
   //Level and Game initalizing
   ...
   
   on_t = give_item;
}



Thanks for your help, maybe you can send me the link to an complete tutorial i Need to understand this? :-)

EDIT:

One more question:
Is it possible to give a struct pointer as Parameter to a function?

Last edited by Simon_Schwitzky; 03/25/14 17:45.

Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: Handling problem struct pointer. [Re: Simon_Schwitzky] #439030
03/25/14 17:57
03/25/14 17:57
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
Code:
typedef struct ITEM
{
   int it_id;
   BMAP* it_bmap;
} ITEM;

ITEM item_001; //No malloc needed, if you want to keep it, then keep it.. (dont forget malloc returns a POINTER)
item_001.it_id = 1;
item_001.it_bmap = bmap_create("item_001.png");

function give_item(ITEM *pItem)
{
   pan_inventory_slot.bmap = pItem.bmap;
}

void main()
{
   //Level and Game initalizing
   ...
   
   give_item(&item_001);
}


Last edited by Ch40zzC0d3r; 03/25/14 18:09.
Re: Handling problem struct pointer. [Re: Ch40zzC0d3r] #439032
03/25/14 18:20
03/25/14 18:20
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
1st: Thank you man! :-)
2nd: I tell you when it works!


Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: Handling problem struct pointer. [Re: Simon_Schwitzky] #439035
03/25/14 19:11
03/25/14 19:11
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
Ok it works.
But the Bitmap is not the correct one, i can click it but it is invisible :-O

Edit:
Maybe i shouldn't use the .jpg?

Edit 2:
I tried it with 32Bit.tga - same...
It is just invisible but activatet. Flags on Show.

Last edited by Simon_Schwitzky; 03/25/14 19:34.

Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs
Re: Handling problem struct pointer. [Re: Simon_Schwitzky] #439042
03/25/14 19:39
03/25/14 19:39
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
When it crashes in give_item that#s either because pan_inventory_slot is vagabonding or NULL or pItem. Please read through the tutorial! You're trying to execute code outside of functions. That won't ever work.


Always learn from history, to be sure you make the same mistakes again...
Re: Handling problem struct pointer. [Re: Uhrwerk] #439044
03/25/14 19:44
03/25/14 19:44
Joined: Oct 2011
Posts: 1,082
Germany
C
Ch40zzC0d3r Offline
Serious User
Ch40zzC0d3r  Offline
Serious User
C

Joined: Oct 2011
Posts: 1,082
Germany
you have to initialize the struct... man you cant execute any functions OUTSIDE of any other functions:
Code:
ITEM item_001;

function main()
{
     ...

     item_001.it_id = 1;
     item_001.it_bmap = bmap_create("item_001.png");

     give_item(&item_001);
}


Re: Handling problem struct pointer. [Re: Ch40zzC0d3r] #439045
03/25/14 19:46
03/25/14 19:46
Joined: Feb 2014
Posts: 35
Simon_Schwitzky Offline OP
Newbie
Simon_Schwitzky  Offline OP
Newbie

Joined: Feb 2014
Posts: 35
I. AM. STUPID.

thanks!


Die Menschen, die verrückt genug sind zu sagen, dass sie die Welt verändern werden, sind diejenigen, die es tuen!
-Steve Jobs

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