|
Handling problem struct pointer.
#439028
03/25/14 17:43
03/25/14 17:43
|
Joined: Feb 2014
Posts: 35
Simon_Schwitzky
OP
Newbie
|
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""
//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: Ch40zzC0d3r]
#439032
03/25/14 18:20
03/25/14 18:20
|
Joined: Feb 2014
Posts: 35
Simon_Schwitzky
OP
Newbie
|
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
OP
Newbie
|
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
Expert
|
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...
|
|
|
|