Jump to content

Struct + [] variable


f13rce
 Share

Recommended Posts

Hey there LE community :) ,

 

Yeah I'm enjoying my time in France. Now that I'm trying to finish the networking here using 39dll I got stuck with a problem.

 

I'm trying to make a player object when someone joins. I have made a struct for the Players (named players) and if someone joins we get his playerid. piece of code:

 

players[playerid] = readbyte(0);

 

This all goes well untill I want him to assign an X, Y or Z coordinate:

 

players[playerid].X = 1000;

 

The compiler claims I haven't initialized the X of players yet while players.X=<number>; works.

I've checked the C2228 page a LOT and I wasn't able to fix this, hereby this thread.

 

Does anybody have experience with this or does know what could be the problem? A small tutorial how to initialize a struct with []'s would also work ;)

 

Thanks and greetings from France,

 

Ivar / Evayr

Using Leadwerks Professional Edition (Beta), mainly using C++.

Windows 10 / Linux Mint, Visual Studio 2017. GPU: NVidia GeForce GTX970, CPU: Intel i7 7700K @ 4.20 GHz

Previously known as Evayr.

Link to comment
Share on other sites

I'm trying to make a player object when someone joins. I have made a struct for the Players (named players) and if someone joins we get his playerid. piece of code:

 

players[playerid] = readbyte(0);

I'm not at all sure what it is you are attempting to do in this line of code.

 

If players is an array of structs then you appear to be assigning this particular struct in it's entirety to some value readbyte(0) as you are not referencing any member of the structure in your assignment. players[playerid] will simply point to the start of that instance of the structure in memory. Is this really what you are meaning to do? Without seeing the struct definition and the rest of the code it's not easy to determin if this is valid or not.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...