Jump to content

  • Log In with Google      Sign In   
  • Create Account

Rasterman

Member Since 16 Jan 2006
Offline Last Active Jul 12 2013 03:27 PM

Posts I've Made

In Topic: Master Server How to ?

22 January 2013 - 08:32 AM

The first lobby I did in ASP and runs on IIS.  The second lobby I did in C++/enet and runs on a Windows VPS, you can get one for $20/month.


In Topic: How to find a host running the game?

21 December 2012 - 05:17 PM

Here are the broadcast util functions I made for my game, you should be able to add full LAN discovery with only a few additional lines of code.

	// http://lists.cubik.org/pipermail/enet-discuss/2009-March/001075.html
	
	// designed for LAN discovery of servers
	// sets up a socket to receive broadcast messages on the given port
	int enetutil_broadcast_setup_receive(int port)
	{
		ENetAddress address;
		address.host = ENET_HOST_ANY;
		address.port = m_iLANDiscoveryPort;

		// create UDP socket
		ENetSocket socket = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM);
		if(socket == ENET_SOCKET_NULL)
			return ENET_SOCKET_NULL;

		// allow multiple servers on the same computer to listen to same port
		enet_socket_set_option(socket, ENET_SOCKOPT_REUSEADDR, 1);

		// bind to the address to listen on after REUSEADDR has been set
		if(enet_socket_bind(socket, &address) < 0)
		{
			enet_socket_destroy(socket);
			return ENET_SOCKET_NULL;
		}

		// no blocking again
		enet_socket_set_option(socket, ENET_SOCKOPT_NONBLOCK, 1);

		return socket;
	}


	// designed for LAN discovery of servers
	// broadcasts the given data on the port specified
	// returns:  0 if would have blocked, -1 if socket could not be created, < 0 something went wrong, length on success
	int enetutil_broadcast_send(int port, void *data, int length)
	{
		ENetAddress address;
		address.host = ENET_HOST_BROADCAST;
		address.port = port;

		return enetutil_send(&address, data, length);
	}


	// returns:  0 if would have blocked, -1 if socket could not be created, < 0 something went wrong, length on success
	int enetutil_send(ENetAddress *address, void *data, int length)
	{
		// create UDP socket
		ENetSocket socket = enet_socket_create(ENET_SOCKET_TYPE_DATAGRAM);
		if(socket == ENET_SOCKET_NULL)
			return -1;

		// prevent send from blocking
		enet_socket_set_option(socket, ENET_SOCKOPT_NONBLOCK, 1);
		// allow the socket to send to the broadcast address
		if(address->host == ENET_HOST_BROADCAST)
			enet_socket_set_option(socket, ENET_SOCKOPT_BROADCAST, 1);

		ENetBuffer buf;
		buf.data = data;
		buf.dataLength = length;
		int err = enet_socket_send(socket, address, &buf, 1);
		if(err==0) { /* would have blocked, need to resend later */ return 0; }
		else if(err < 0) { /* something went wrong, error! */ return err; }

		enet_socket_destroy(socket);
		return length;
	}

In Topic: Proper way for server to save world data while active?

29 October 2012 - 02:19 PM

160MB isn't that much, just copy the memory, spin off a thread and write it to disk. worst case display 'saving world' to the players, if there are only 8 and it only takes a few seconds then no big deal. another option is to slowly copy all data to disk, tracking all changes after you started, then at the end apply all those changes together to the disk image, this is probably going to be a lot slower than just writing the whole file, but it won't use any memory.

In Topic: Allegro 5.1 vs SDL 2.0

15 October 2012 - 08:50 AM

I downloaded and tested SDL 2 with XCode 4.5 and it seems to be very much in development. Only half of the SDL tests compile and of those none actually run or do anything.

In Topic: Creating a Lua RPG rough timing?

12 October 2012 - 01:12 PM

Make it text/icon based, you can work on one of these until you are blue in the face. There is no point on competing on graphics since AAA games blow you away, so try to make it unique via the story, game mechanics, and characters. You can do all of this in a text/icon based game. If you find you are blowing through the game fast, then you can always add a beautiful graphical layer on top of the game engine, or better yet hire artists to do a professional job on it. It is also MUCH easier and faster to create assets for a completely specd out game than one in development.

PARTNERS