GithubHelp home page GithubHelp logo

multiplayerbook's Introduction

Multiplayer Book

Welcome to the code repository for Multiplayer Game Programming: Architecting Networked Games. Here you will find all the code samples to accompany the code from the book.

Supported Platforms

The code has been tested and runs on Windows with Visual Studio 2013, and on Mac OS X with Xcode 7. Other platforms (including Linux) are currently not supported.

Installation

To install, clone the repository to your local computer.

For the examples in Chapter 13, you'll need Node.js installed from https://nodejs.org and you'll need to use a terminal or console window to switch to each of the subprojects in the Chapter 13 folder and type

npm install

That will grab all the necessary node modules and you'll be ready to go!

multiplayerbook's People

Contributors

chalonverse avatar joshuaglazer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

multiplayerbook's Issues

Education Material

Hey MGP Team and @JoshuaGlazer,

in the book it mentions that there would be "links PowerPoints slides and a sample syllabus for use in an academic setting" on this companion site.
What I (externally) found was : [https://web-app.usc.edu/ws/soc_archive/soc/syllabus/20133/31898.pdf]

Somehow, I did manage to find any academic material here, is it still available (if yes, could you, please, provide the direct link for this lost soul :D )?

In any event, thank you for the great book!
Fabio

Hello I have some questions about float synchronization in RoboCatRTS project.

Hello!!
The project and book were so impressive and helped me a lot!
I read the chapter "implementing peer to peer" and there were so many good skills introduced.
But I have some questions about float synchronization.

  1. Is this "RoboCatRTS" project implemented including perfect float synchronization?
  2. In the book, it introduced checksum(with CRC) at part "Verifying Game Synchronization".
    Does it have nothing to do with float synchronization?
  3. If not, is it impossible for achieve float synchronization except for using only integers?

I've searched a lot but couldn't find reasonable float by integer library.
I wonder how the games like "age of empires" achieved synchronization.
They wouldn't have done it only with integer, isn't it??

InputMemoryBitStream::CopyConstructor: Incorrect byteCount

Hello!

When you calculate byteCount by dividing mBitCapacity by 8, you lose 1 byte.

InputMemoryBitStream( const InputMemoryBitStream& inOther ) :
	mBitCapacity( inOther.mBitCapacity ),
	mBitHead( inOther.mBitHead ),
	mIsBufferOwner( true )
	{
		//allocate buffer of right size
		int byteCount = mBitCapacity / 8;
		mBuffer = static_cast< char* >( malloc( byteCount ) );
		//copy
		memcpy( mBuffer, inOther.mBuffer, byteCount );
	}

Link to the line in your repo

A solution would be adding the following code after int byteCount = ...

if (mBitCapacity % 8 != 0)
		byteCount++;

Best Regards

dyld: Library not loaded: @executable_path/libSDL2_ttf-2.0.0.dylib

I try run RoboCatRTS of chapter 6, archive the project, export with the option "Save Built Products" to Desktop, in terminal, try ./RoboCatRTS 45000 John,

Then got this error:
dyld: Library not loaded: @executable_path/libSDL2_ttf-2.0.0.dylib Referenced from: /Users/apple/Desktop/RoboCatRTS 2016-02-28 22-31-15/Products/usr/local/bin/./RoboCatRTS Reason: image not found

This is first time I archive c++ project in xcode, I don't sure whether those steps are right.

use of undeclared identifier 'close' / 'select'

Hi, I've downloaded the example code and attempted to compile on OSX with Xcode 7.3 and I get these same errors for the examples in every chapter. I can't find them defined anywhere. Am I missing something?

Unintentionally committed files

Hi there @JoshuaGlazer,

I've learned a lot from studying the code samples that go with your book, but I also noticed a couple of sublime-workspace files in the repository. Sublime text will include things like file history and autocompletion preferences in these files, it's best to stick them in .gitignore so that you don't dox yourself! I didn't see anything sensitive at a glance.

The two files:
https://github.com/MultiplayerBook/MultiplayerBook/blob/master/Chapter%2013/virtualMachineManager/virtualMachineManager.sublime-workspace

https://github.com/MultiplayerBook/MultiplayerBook/blob/master/Chapter%2013/localServerProcessManager/localServerProcessManager.sublime-workspace

Hello, I have a question in Chapter 6 RoboCatRTS again.

Thank you for giving answer for my question.
It greatly helped me to understand that source.

But I have more question in here.
In RoboCat class, in UpdateAttackState method, if statement.

if ( distSq <= kAttackRangeSq )
{
    ...
    GameObjectPtr me = NetworkManager::sInstance->GetGameObject( mNetworkId );
    ...
    yarn->InitFromShooter( me, mTargetCat );
}

I have question in here.

  1. Is there any reason for finding instance in map rather than using this pointer?
  2. Because of the name, I thought that "mNetworkId" was identifier that grouping entities by networks.
    But It seems like just entity id which is unique for query them. Is it right? or am I missing something?

Missing Assets

I'm trying to build the code on OSX 10.11 with XCode 7.2 and it's complaining of missing Assets directory.

The working directory "$(SRCROOT)/Assets" for scheme "Chapter3" doesn't exist.

It also says the build is successful, but there are 2 errors related to a bash script that is being run:

cp: Assets: No such file or directory
Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

Thanks.

If the client maliciously manipulate the input DeltaTime, won't it skew the simulation? (Speed hack)

I'm implementing a shooter based on the teachings of the book (I have a physical copy) and many other reading materials. The problem I'm facing now is that a malicious client can trivially manipulate the DeltaTime in the input packets resulting in a speed hack.

The way I've tackled this is by calculating/inferring the DeltaTime between input packets and punishing/kicking the player if it diverges too much from the self-proclaimed input DeltaTime.

This really feels like a hack though and can easily fall apart if the player is dropping packets as the inferred DeltaTime will be completely off.

Am I missing something? (I just checked the Chapter 8 code and it looks susceptible)

Cheers :)

Hello, I have a question in Chapter 6 RoboCatRTS

Hello, I have a question in Chapter 6 RoboCatRTS.
In class CommandList, there is no copy constructor defined.
But in class TurnData, it calls copy constructor of CommandList in TurnData's main constructor.
I don't understand the intend for this code.
Is there some kind of life cycle issue about CommandList?

RobocatRTS Lockstep algorithm bug when mTurnNumber=0

Hi, I was implementing the lockstep algorithm in my game, and I think I found a bug when mTurnNumber=0:

We first enter the TryAdvanceTurn function when mTurnNumber=0, but the conditional if ( mTurnData[ mTurnNumber + 1 ].size() == mPlayerCount ) will check the mTurnData array at index=1, not index=0.

ch3 p73: mac sockaddr size variable name

Preface

I am a Computer Science student and have been working my way through your Multiplayer Game Programming book. It is definitely one of the best networking resources I have found so far, especially given how up to date it is. I therefore want to take the time to help you improve it as best as I can.

The book mentions that errata would be posted in this repo, but I don't see any yet so please let me know if there is another location that might contain them so I don't accidentally post known errata.


The Issue

This may be being pedantic, but in the note section on page 73 of the book where you discuss how some platforms add a size variable on sockaddr structs. I think the name of the variable you mention in the provided example is incorrect.

You state "For instance, on Mac OS X, initialize a sockaddr_in named myAddr", which to me reads like we have a variable of type sockaddr_in, as follows:

sockaddr_in myAddr;

You then write that we can set the MacOSX-specific size variable with the line:

myAddr.sa_len = sizeof(sockaddr_in);

However this results in an error, because the name of the size variable would be sin_len if the type is sockaddr_in.

If the type was just sockaddr then the sa_len member variable would be correct. I think for consistency's sake you the type of the struct and the name of its variable should match up.

Proof (Tested with Clang 7.0.2 on Mac OS 10.10.5);
screenshot_2016-09-03_16 15 40

SocketUtil::Select error?

Just reading through the book and noticed what seemed like an error:

    fd_set *readPtr = FillSetFromVector( read, inReadSet, nfds );
    fd_set *writePtr = FillSetFromVector( read, inWriteSet, nfds );
    fd_set *exceptPtr = FillSetFromVector( read, inExceptSet, nfds );

Should those 3 reads instead be read,write, and except?

No default Port

There are no default args for IP address or Port address on Chapter 6 Xcode project's RoboCatClient.

I had to go to Product >> Scheme >> Edit Scheme, then select RoboCatClient and typed 127.0.0.1:45000. Until I did this the client would open but would only display a blue screen because it never connected to the server.

Anyone else just downloading the files would have to do the same to get the client working it looks like.

运行不起来

有人能跑起来吗?windows或者mac,反正我是没有。

Missing listen call?

Hi, in listing 3.11 (DoTCPLoop) shouldn't there be a "listen" call right after creating the listen socket and before the while loop?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.