• 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
DoubleDouble

Server-side inventory system, what to send over the network?

5 posts in this topic

I've looked on Google quite a bit, trying to search multiplayer inventories and such, but I'm mostly getting results related to databases or minecraft. So while I am asking here, in addition to answering my questions, I will happily look at any links you may find useful to my situation. I am programming in c#, but I can at least understand code in whatever you guys throw at me.

I'm working on a multi-player rpg that has an inventory system similar to Diablo's in that the player has many "slots" they can store items in, and some items take up more than one slot.

Currently, my intention is to set it up like so:

Inventory: 20 x 20 (400) slots

Server: int array[400] playerInventory. //Stores item id's
Sends the array to the client

Client:
receives array of itemIDs,
sends any player input, //clicked an item? //moving an item?

so, my Questions:
In case it is relevant, I am using C# with XNA, Lidgrens

1) What should I use as the array? ints are much larger than something else I could use, yes?

2) How often should I send such a large amount of info? 400 itemIDs seem like a bad amount to send. I was thinking of having a game state monitor, which would let the server know when the player is looking at his inventory screen and only then send all the itemID's, I dislike that solution because I feel there are better ways. Help?

3) How should I send the player input? If a player clicked the item in slot 123 (to pick it up / hold it with mouse) should I send: playerID, actionType, itemSlot. Are there any bugs that I need to be aware of if I do it this way? (latency bugs, possible item dupes?)

In conclusion, I want the inventory server-side so it eliminates hacks related to items and inventorys, but I am aware of networking limitations (aware they exist, not what they are) as far as sending and receiving data. My current solution seems like it would send/receive too much, and I am trying to optimize that interaction between client and server. Any help is appreciated.
0

Share this post


Link to post
Share on other sites
I would store each item in inventory, together with the position of the top/left coordinate of the item. This only needs 10 bits per item (5 bits for X, 5 bits for Y.) The size of the item should already be known by the client based on the item type.
I would send the full inventory on connect, and only send delta updates when the inventory changes, to minimize traffic. Edited by hplus0603
2

Share this post


Link to post
Share on other sites
I have it working currently by the client sending 9 bits on each update, 1 whether he clicked or not and a byte for a position
(I decided since I am coming up with an arbitrary number of inventory slots it might as well be 255 slots instead)

The server then does what needs to be done with that position and any item the player is holding.
Currently, it then sends back the entire inventory array. (255 * 1 byte)

You are saying I could send back (1byte position, 1byte itemID) instead... that would be quite good [img]http://public.gamedev.net//public/style_emoticons/default/biggrin.png[/img]
I may bring it back to 400 slots if its only two more bits, I'm starting to better understand how to get the most out of each bit.
As an afterthought, I can also save the bit on whether the player has clicked and just send the item position when the player clicks couldn't I?

Thanks for the response, the help is much appreciated and every little "bit" helps. [img]http://public.gamedev.net//public/style_emoticons/default/happy.png[/img]
0

Share this post


Link to post
Share on other sites
Wouldn't it be better to send player requests instead of "clicks"? ie: if user clicks an item, you pick it up locally, drag it around and drop it in slot. You then send a message to the server: user X, move item from XY to ZW; at this point it would be wise to lock the moved item and both slots until server responds. As for packing info, if you don't have multiple avatars in your party, you do not need to send "who" as server knows from which client he got message and for coordinates I'd rather send just index with the required number of bits (400 -> 9bits (512)) , so you just need two index values (from - to). Server then responds only with a confirmation and the client unlocks item and slots. If the server doesn't respond in timely fashion, you revert the whole action (move item back, unlock everything).
This is safe, but induces lag when user is doing stuff in inventory.
0

Share this post


Link to post
Share on other sites
Assuming your game logic doesn't depend on where the item is in inventory, why even manage the positions of items in inventory on the server? Simply let the user do what they want, and after a user adds inventory, the server calculates how many inventory slots the user has and is using, if they are using more then they have then you need to do an inventory audit of the user.
0

Share this post


Link to post
Share on other sites
[quote]why even manage the positions of items in inventory on the server?[/quote]

Because the next time the player logs on, it may not be from the same machine, or it may be from a restored backup, or similar. Server-side state for non-local things is one of the benefits of online games! (A draw-back is that you can't play if the intertubes are clogged...)
0

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