Hello,
As you can see below, the program will hold the account data in one structure and then the character data in another structure. Eventually, 'player_data' will contain more structures to other parts of the program (but that's not the case). For some reason I cannot access the 'player_data' structure through the 'account_data' structure.
This is what my current code looks like (for testing purposes).
Code:
int main(int argc, char *argv[])
{
acc_data[0].player[0]->class_id = 10;
printf("class id: %d\n", acc_data[0].player[0]->class_id);
system("PAUSE");
return 0;
}
And here's the structures.
Code:
struct account_data
{
char user[NAME_LENGTH];
char pass[NAME_LENGTH];
struct player_data *player[MAX_CHARACTERS];
char *buffer;
char *incbuffer;
short char_id;
short char_num;
short ingame;
long attack_timer;
long data_timer;
long data_bytes;
long data_packets;
long party_player;
short in_party;
short target_type;
short target;
short casted_spell;
short party_starter;
short getting_map;
} acc_data[100];
struct player_data
{
char name[NAME_LENGTH];
short sex_id;
short sprite_id;
short class_id;
short access_id;
short level;
long exp;
short pk;
short guild;
long hp;
long mp;
long sp;
short str;
short def;
short spd;
short mgc;
short pnts;
short slot_armor;
short slot_weapon;
short slot_helmet;
short slot_shield;
int map_id;
short coord_x;
short coord_y;
short dir;
};
What am I doing wrong, because every time I use printf, the program crashes? I want to constantly add, change, and remove data in certain situations.
EDIT: And is there a way to shorten a structure check using the array requested?