dbuman
Member
|
Net Obj
How do you convert STRUCT(Player, Game.chr) to STRUCT(Player, Net.Obj)?
|
|
07-02-2011 02:29 AM |
|
yvanvds
Member
|
RE: Net Obj
You don't. :-)
I think you want to read up on c++ (multiple) inheritance.
STRUCT is just an esenthel macro. So STRUCT(Player, Game.chr) actually means:
struct Player : Game::chr {
};
It means you make structure called Player. Inside the structure you can put functions and variables related to this structure. On top of that, the structure also inherits the functions and variables that are declared in Game::chr.
If you'd like to add functions from Net::Obj, we're talking about MULTIPLE inheritance. So you define your struct as:
struct NetPlayer : Game::chr, Net::Obj {
};
I don't know how you do multiple enheritance with the new "esenthelspeak", but I guess the plain c++ syntax should also work.
That said, perhaps you do not need multiple inheritance at all. In my code I have a Player based on Game::chr in my client code, and a player based on Net::Obj in my server code.
But again, it will be much clearer if you actually read a few chapters in your c++ bible about inheritance.
Regards,
yvan
|
|
07-08-2011 11:27 PM |
|
dbuman
Member
|
RE: Net Obj
So with that said, how would you translate a player's actions to a server? Is it the same way its done with the chatbox code? or is it slightly different?
|
|
07-09-2011 12:37 AM |
|
yvanvds
Member
|
RE: Net Obj
I guess it's at least slightly different from a chatbox :-)
You just send over the network whatever you want the server to know. I guess at least the player position and rotation. Perhaps also the current animation, when he picks up and item or all kinds of actions you want in your game. If you really want to go the client-server way, it's worth its money to buy the personal license of the engine. You'll get the source code of the esenthel MMO. I did study that for a few days before I started on my client-server code. It really helps to see how it's done.
Keep in mind that client/server interaction is just one thing. If you want smooth multiplayer interaction you should also send position updates and such to nearby peers in the game. That's a lot to figure out all by yourself.
|
|
07-09-2011 12:57 AM |
|
dbuman
Member
|
RE: Net Obj
Well im quick to learn however I dont have the money to buy the license =/
|
|
07-09-2011 12:59 AM |
|
dbuman
Member
|
RE: Net Obj
Im curious what kind of code did you use to have the server retrieve the player's pos?
|
|
07-09-2011 04:19 AM |
|