#ifndef UDPNETWORKUTILITY_HPP_
#define UDPNETWORKUTILITY_HPP_

#include "SDL_net/SDL_net.h"

class UDPNetworkUtility {
public:
	UDPNetworkUtility() = default;
	~UDPNetworkUtility() = default;

	void Open(int port, int packSize);
	void Close();

	//bind to an available channel
	int Bind(const char* ip, int port) {
		Bind(ip, port, -1);
	}
	int Bind(IPaddress add) {
		Bind(add, -1);
	}

	//bind to certain channel
	int Bind(const char* ip, int port, int channel);
	int Bind(IPaddress add, int channel);
	void Unbind(int channel);

	IPaddress* GetIPAddress(int channel) {
		return SDLNet_GetPeerAddress(socket, channel);
	}

	int Send(int channel, void* data, int len);
	int Receive();

	void* GetOutData() const {
		return reinterpret_cast<void*>(packOut->data);
	};
	void* GetInData() const {
		return reinterpret_cast<void*>(packIn->data);
	};
	void* GetOutPacket() const {
		return packOut;
	}
	void* GetInPacket() const {
		return packIn;
	}
private:
	UDPsocket socket = nullptr;
	UDPpacket* packOut = nullptr;
	UDPpacket* packIn = nullptr;
};

#endif

OK, so this is pretty simple, but to help my project, I’ve actually modified SDL_net slightly: a trivial modification of some preprocessor macros.

SDL_net has a channel system which it uses to manage various different IP addresses with UDP. I increased the maximum channels from 32 to 150, and reduced the max number of addresses per channel from 4 to 1. This should give me a pretty straight forward working UDP system.

Hopefully, this works out ok. Each internal player container in the server will have a channel value, which will help to reduce the amount of finicky code I have to deal with.

My Kickstarter

OK, so I’ve calculated that when I run a kick starter, I’ll have a goal of $15,600. This number comes from 1 year of development time, with $250 per week for food, board, etc. and an extra 20% margin for emergencies (like my computer suddenly dying). I’d also need a private GitHub repo, advertisements, greenlight fee, etc. These sorts of expenses will come out of my weekly allowance, of course, but all of this isn’t counting any sort of tax.

For reward tiers, I’ll have something like this:

  • $10: Access to the game on completion (pre-order)
  • $25: Access to the most recent stable build (closed alpha & beta)
  • $50: Get your name in the game (NPC)
  • $100: Horse Armour (DLC)
  • $200: Access to the source code and assets (bleeding edge)

Anyway, this is pretty basic. Any feedback is welcome.

Edit: I might need to raise that number, depending on what the future holds.

I can’t get the makefile/submodule system working, so I guess I’ll just have to include the raw Codebase files into the Tortuga repo. Probably better this way, since I’ve had trouble recompiling past projects whose engine evolved after it’s development ended.

It’s official, I’m doing a kickstarter when I’ve finished the prototype.

I’ve Discovered Rebasing!!

Or at lest, I’ve started using it; I’ve known about it for a while. Anyway, I’ve created a wiki for Tortuga on GitHub to help me convery what I’m actually doing, since I’m doing much as far as in-code commenting.

I’d love some feedback if you have the time, here’s the wiki.

train of thought

Oh crap, I don’t remember anything about networking.

Help!! What should I do for this?

(more to come…)

OK, so UDP sends a message, but doesn’t concern itself if it reaches the destination or not. IT can only use a fixed size of packet, and I’m pretty sure I can put together a manager class for this, if I can just remember enough about it.

TCP is slower, but it always reaches it’s destination in the correct order. There’s to predefined size, and it’s secure. I don’t think I’ve used this much in the past, but I need to figure out which is the better option for this game.

The networking class and the list of clients should probably be separate.

TCP and UDP sockets can only work with their respective systems, so I might as well roll the socket lists into the managers.

I need to use socket sets, even though looking at them makes me want to skip over them.

From what I can tell, it’s impossible to check how many sockets in a socket set.

“Expand Alone” formats, like Far Cry 3: Blood Dragon, if this sells well, will hopefully be the beginning of a new scene of games.

Question: in a client-server game, should the server hold an instance of the world i.e. handle the collisions of players with objects, etc. This would make the clients into thin clients.

Answer: Depends on the game. Damn.

This is what I’m working on right now. I’m writing the graphics systems of Tortuga. It’s a start, at least. Any input would be appreciated.

If the link doesn’t work, it means I’ve deleted this branch (which will happen when I’m finished, so hopefully soon). In which case, here is the master branch.

Here’s a piece of history I didn’t know about: Activision was formed from disgruntled Atari employees.