Multiplayer and Netcodes
Displaying 1-4 of 4 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
x.mattv

I've recently slapped the client end of a multiplayer game (which isn't much of a game but is very multi-player) together in VergeC using the chat server released by vecna (with only one or two lines of code changed) and was interested in other peoples experiences, challenges, and results (however large or small) with the verge3 netcodes.

-MV

Posted on 2008-03-03 14:53:33

Code

I've also dabbled with that netcode a little and had some success. I used Zonker's Scrabbler as a template.
I was actually surprised by how easy it was to use. It's as simple as concatenating and parsing strings!

My netcode experiment
Start up the server, then start up two instances of the client and tell one to host, and the other to join, pointed at 127.0.0.1.

Posted on 2008-03-03 18:00:13

x.mattv

I was also surprised by how simply they had managed to make the handling of sockets, which I have had endless problems with in C previously.


void netconnect () {
// * Connect to Server
socket = Connect(server);
if (!socket) EXIT("Couldn't Connect");
string s = SocketGetString(socket);
if (!strcmp(s, "full")) {
Exit("SERVER IS FULL");
} else {
userid = s; // server provides userid
usernum = Val(right(userid, 1));
}

}

void netdata() {
// * Check Connection to Server
if (!SocketConnected(socket))
Exit("lost connection to server!!");
// * Recieve Exchange Data if Data Available
if (SocketHasData(socket)) {
exchange = SocketGetString(socket);
entity.x[client_player] = Val(GetToken(exchange, "|", 1));
entity.y[client_player] = Val(GetToken(exchange, "|", 2));
entity.specframe[client_player] = Val(GetToken(exchange, "|", 3));
}
}

void netsendpos() {
// * Send Exchange Data
exchange = str(usernum)+"|"+str(entity.x[current_player])+"|"+str(entity.y[current_player])+"|"+str(entity.frame[current_player]);
SocketSendString(socket,exchange);
}

void netsendevent(int eventid, string eventspec) {
// * Send non-positional event
exchange = str(usernum)+"|"+str(eventid)+"|"+eventspec;
SocketSendString(socket,exchange);
}

void nettimer() {
mytimer++;
netdata();
if (mytimer >= 10) {
mytimer = 0;
netsendpos();
}
}


This is the entire client side code for positioning chr's on a map. (2-Player in this example... but easily edited)

Posted on 2008-03-04 14:39:11 (last edited on 2008-03-04 14:40:51)

lynerd

I messed around making a server / client handler. The basic idea I had was to make the server program write the messages it received from the client to a file. Then another program could read the file and perform the needed actions. Sending messages back to clients worked the same way.
School ate up a lot of my time and thus never finished. I have it where the client can connect and if the client goes idle for too long or disconnects, the server will kick them from the server at a set amount of time.
Tried to comment my functions to the best of my memory.

http://verge-rpg.com/files/detail.php?id=721

Posted on 2008-03-16 04:19:35


Displaying 1-4 of 4 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.