Yobi_Gochida

Housing

Sep 16th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.50 KB | None | 0 0
  1. Simplify everything as best you can on the backend. I reduced skills to numbers stored in arrays as a fairly naive but compact way to keep a skill bar. All you need to do to load them is look up what number is what skill - which isn't that hard at all computation wise.
  2.  
  3. So how about a player house? Lets use the personal room as an example. Max items in the room is 50, plus wall decor and flooring
  4. You have a set room, so we already know the width and depth of the room (for purposes of placing furniture). We save that value once and apply it on all instances of housing. Lets be silly and use two whole integers, that's 64 bits one time. We'll use that any time we need to do bounds check when a player tries to drop a piece of furniture in their room.
  5.  
  6. Now, saving furnishings.
  7. Assign all furniture, past and future, an item ID. (I'm assuming there is something like this in place now so use that).
  8.  
  9. For each furnishing you place down, it counts to your max of 50. Lets make this an array of 50 'items'.
  10.  
  11. An 'item' will be a struct, and holds: position as a float, rotation as a float, item ID as an integer, dye color as an integer.
  12. A room will also be a 'struct' and will track the items and other values we put in it.
  13.  
  14. The size of each 'item' will be: 32 + 32 + 32 + 32. That's 128 bits or 16 bytes.
  15.  
  16. We have 50 items max in our house, so we'll need at most 800 bytes. (50 * 16)
  17. I mentioned a flooring and wallpaper option before. These have no position or rotation, so we cut it down to 8 bytes each. So another 16 bytes total.
  18.  
  19. That gives us a player room costing 816 bytes to track 50 items, their wallpaper and their flooring options.
  20.  
  21. Lets assume our player ID is attached to the room in the form of an integer. We're up to 848 bytes. That's not even a kilobyte of data!
  22.  
  23. We have to manage 20k players? That's 16,960,000 bytes. Or 16960kB. Or 16.96mB per server. You want 40k players? Double it. We could safely say 1GB of data will track more player houses on a server than we may ever need. We could add some extra stuff to our initial housing struct to track things like 'where is your house entrance' or 'what BGM do you want to play' easily by adding values onto the 'Room' struct.
  24.  
  25. Go ahead and check my math on that, I'm by no means perfect. But I shouldn't be off by much.
  26.  
  27. Remember that one kilobyte is 1,000 bytes. A megabyte is 1,000 kilobytes or 1,000,000 bytes.
  28.  
  29. (This post works under the assumption a C or C based language was used. I'm by no means an expert programmer, but play one on the internet)
Advertisement
Add Comment
Please, Sign In to add comment