Like the world needed twitter. Jesus.
Not a Member? - Login or Create an Account...MC Offline
Wednesday the 28th of June 2017 @ 04:47am
Front Page Projects Your Profile About

Filed Under: Journal - Development - Game Development

Time to Catch Up

2003.01.11 03:53am

Well, we're now into 2003 and it would seem by all external accounts that I've once again stopped working. Alas my pets... I have not.

I've been busy, busy. There have been so many additions and changes to the library I don't even know where to start describing them. First I'll say that I've left OpenGL for a little while to attend to some other engine matters that need attention. The largest target of that attention has been the networking code.

After a few days of work I think I have it nailed down pretty good. It should be interesting to see how things hold out under any pressure, but for the time being everything seems nice and stable.

I've been putting lots of time into design for the actual GAME project and I'm getting pretty excited about it. I won't go too far into things for now. Soon enough there'll be a whole section of this site devoted to it, so no point in duplicating work. For the moment I'll first be focusing on smaller benchmarks. The first will be a simple multi-client chat server. It's going to be boring as hell to make, but it's a good way to test the networking code as well as create an arena for the construction of some character capturing routines.

After the chat server and client are done, a pong game is in the works. It's dumb and I hate to waste the time doing it, but I think it will be critical in shaking out any bugs in the networking layer, the graphics code, interface... everything. Most importantly I need to shake out some of the bugs floating around in me. I have many (at this point, while untested) brilliant ideas about how to arrange game structures and client interfaces so that networking, AI and local interfaces will be 100% abstracted. It should make for nice clean development.

To be honest though, I'm beginning to worry a little bit about the expense of some of these ideas. Data spends a lot of time just moving around and changing types. I'm wondering how that's going to play out when it comes down to a real game environment. Especially in a large scale RPG where lots of things are happening all the time. I know I constantly underestimate the processors abilities, but it still feels like a lot of work is going on that shouldn't be.

Well, regardless of all these wonderful issues - the largest issue at hand for me right now is to get to bed. This journal was started around 3:30 or so, but it's now 6:30 - and I have a very long day with a lot of work to be done tomorrow. I'm hopeful that I can have SOME kind of functional chat code working by the end of the weekend.

Things are moving along quite well. I'm getting pretty excited about the whole thing. I have to be honest. I just don't want to get too far ahead of myself.

We shall see.

As a last note, I'm going to leave behind two examples of the new networking code. The first requests google's homepage! Of course, it gets a redirect to the www.google.ca site, but it still completes the request perfectly. That's right. Five lines of code is all it takes.

0001 n2lStartup();
0003 cNetworkAddress google("www.google.com:80");
0004 cTCPSocket webHost(google);
0005 cNetworkMessage httpRequest("GET /index.html HTTP/1.0\r\n\r\n");
0006 cNetworkMessage httpResponse(4096);
0007 webHost << httpRequest >> httpResponse;
0009 n2lShutdown(); 

This example shows all that needs to be done to create a TCP server and client, connect them together and send "Hello?", then respond with "Hi!".

0001 n2lStartup();
0003 cNetworkAddress listenAddress( 63212 );
0004 cNetworkAddress connectAddress( "localhost:63212" );
0006 cTCPSocket listener(listenAddress);
0007 cTCPSocket connector(connectAddress);
0008 cAutoPtr<cTCPSocket> connected = listener.accept();
0010 cNetworkMessage request;
0011 cNetworkMessage response(1024);
0013 request = "Hello?";
0014 connector << request;
0015 *connected >> response;
0016 // response is now "Hello?"
0017 request = "Hi!";
0018 *connected << request;
0019 connector >> response;
0020 // response is now "Hi!"
0022 n2lShutdown(); 



Reader Comments

I knew that looked strange :)

2003.02.16 03:52pm
cNetworkMessage httpRequest("GET /index.html HTTP/1.0\n\r\n\r");

The HTTP line endings should be \r\n, not \n\r. For some reason I needed a good 15 seconds staring at that line to find out what was wrong about it :).

Some random comments:
Are these blocking sockets? They are not usually very good for games, unless you like threads (but then you would be crazy :)).

Did you consider making cNetworkMessage allocate buffers as needed instead of requiring the user to specify a size at construction?

About networking, AI and local interfaces being 100% abstracted, I'd recommend not going overboard. Some AIs need to cheat to be fun, and some networked games need to do client-side prediction/interpolation to feel responsive. This might not apply to a turn-based RPG though, I don't know.

Well that's it. Good luck with all that!

  • Re: I knew that looked strange :)

    2003.03.02 07:14pm
    Thanks for the info about the \r\n ordering. I couldn't remember, and thsi worked, so I assumed it was right. I guess Apache is tolerant.

    They are blocking sockets, but there is a container class which will do selects against them. The container also inherits from the Executor interface (which means nothing, because I haven't really talked about it) but executors can be either run with a thread (yup, crazy) or run on an oscillating timer. In either case using the sockets in THAT way doesn't block.

    As far as the AI comments go, I know what you mean, but I'm despirately striving not to build cheating AI's. Cheating AI's is one of my all time greatest hatereds about computer games. Maybe the time will come when that idea will have to change, but I'd like to progress as if I can avoid unhiding data that AI's shouldn't see.

    Thanks for the comments!

©2017 Aaron Cameron