• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
DrSuperSocks

Sending/Receiving the Game World

5 posts in this topic

Hi all, I've been working on a sort of side-scrolling, shoot em up, RTS game for the past few weeks and am now confronting the issue of sending the game world to the client when it logs in. Right now, when the player logs in, the entire game world is sent all at once (each object gets it's own packet) over reliable UDP (I'm using enet). Originally, I had the game world all in one packet, but the packet was too big to send in just one packet (it's like 50kb). Right now, it works fine if you have fast internet, but with slow internet (50 kilobytes per second) the client will hang there for a very long time receiving only a few game objects a second and never really receives the entire game world.

 

Any suggestions? I'm about to implement a system where it spreads the packets out over a few seconds, is that a good fix? Or are there fancy ways that would be better?

0

Share this post


Link to post
Share on other sites
How are you sending the data? And how do you go about receiving it? Transmitting 50KB of data even over a slow connection (barring dialup) should take less than a second.
1

Share this post


Link to post
Share on other sites

You don't need to send the whole world, just the area around the players location. Generally, an RTS game has both players starting together so there's no need to send any data initially. If you have a hot joinable game, then sending only the players immediate surroundings will help improve bandwidth. You should generally be sending delta's after the clients are synchronised. Perhaps expand on your requirements if that doesn't help?

 

But, as Apoch says, 50k should transfer pretty quickly.

 

n!

Edited by nfactorial
2

Share this post


Link to post
Share on other sites
If the problem is that Enet limits the number of packets per second (with a small send window, say) then you should cram as much as you can into each packet. Let's say Enet allows up to 1300 bytes per packet, then you should cram as many entity updates as you can into that one packet. 39 packets later, you will have sent everything.<br />
1

Share this post


Link to post
Share on other sites

Yes, it's a hot joinable game. Currently, each object get's it's own packet in the initial world send, and I mass send all of them at once.

 

Here is the relevant code:

 

void NetworkManager::send(sf::Packet &packet, int connectorID, int excludeID, bool reliable)
{
    sf::Packet finalPacket;
    //finalPacket << sf::Int8(0);
    finalPacket.append(packet.getData(), packet.getDataSize());

    // Create the enet packet
    unsigned int flags = 0;
    if (reliable)
        flags |= ENET_PACKET_FLAG_RELIABLE;

    ENetPacket *enetPacket = enet_packet_create(finalPacket.getData(), finalPacket.getDataSize(), flags);

    if (mType == NetworkType::CLIENT) // Clients send data to server only
    {
        enet_host_broadcast(mHost, 0, enetPacket);
    }
    else if (connectorID > 0) // It's a server and the client is specified. Tell only that client!
    {
        enet_peer_send(findConnector(connectorID)->mPeer, 0, enetPacket);
    }
    else // It's a server and the client is unspecified. Broadcast to everyone
    {
        if (excludeID > 0)
        {
            for (unsigned int i = 0; i < mConnectors.size(); i++)
            {
                if (mConnectors[i]->mID != excludeID && mConnectors[i]->mPeer)
                    enet_peer_send(mConnectors[i]->mPeer, 0, enetPacket);
            }
        }
        else
            enet_host_broadcast(mHost, 0, enetPacket);
    }
}

void NetworkManager::sendSceneCreation(int connectorID, int excludeID, bool reliable)
{
    for (unsigned int i = 0; i < SceneManager::get()->getCurrentScene()->getGameObjects().size(); i++)
    {
        if (SceneManager::get()->getCurrentScene()->getGameObjects()[i]->getSyncNetwork())
            sendGameObject(SceneManager::get()->getCurrentScene()->getGameObjects()[i], connectorID, excludeID, reliable);
    }
}

void NetworkManager::sendGameObject(GameObject *object, int connectorID, int excludeID, bool reliable)
{
    sf::Packet packet;
    packet << PacketType::CREATE_OBJECT;
    object->serialize(packet);

    send(packet, connectorID, excludeID, reliable);
}

 

 

Thanks for the suggestions, I'll cram stuff into bigger packets. Could you recommend a good maximum packet size? I'll make it adjustable and play with it, but I'd like a ball park biggrin.png This networking stuff is all very new to me.

 

And thanks, nfactorial, I've also given sending only immediate surroundings a thought, and that will be very easy since I already have stuff to detect which planet you are currently on (you fight across many 2D planets).

Edit: But also, in that regard, sending only the current surroundings is kind of the scenario at hand, since I only have 2 planets in the game right now. I plan on having around 100 planets in an actual match.

Edited by DrSuperSocks
0

Share this post


Link to post
Share on other sites
A good ball park number for maximum payload size is 1300 bytes. This works well with the vast majority of networks out there, and is big enough that the per-packet overhead won't be more than a few percent.
2

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0