Software:Main
From NetRace
This page contains all of the tasks that we need to do disscuss, design and build for the game
Home | Schedule | Documents | Game Design | Art and Media
| Table of contents |
Coding Conventions
Virtual-Key Codes
KeyCodes This is a list of all the Key codes you can used by the DXUTIsKeyDown Function.
Mouse Buttons
vButton
[in] Virtual key code of a mouse button. Allowed values are VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, and VK_XBUTTON2.
Networking Discussion
- Connect / Disconnect
- Needs to be hooked into the networking menus
- Chat
- Vehicle Location
- Player 1's client process -
- Player 1's car has havok geometry
- Controls his vehicle normally
- Sends vehicle input (acceleration, braking, turning) to server
- Player 2's client process -
- Player 1's car does not have havok geometry
- Player 1's car's position is received from server
- Server process -
- Server contains havok geometry for all vehicles
- Server receives Player 1's vehicle input and processes phyics
- Server sends out Player 1's position to Player 2's process
- Server sends out corrective positions to Player 1 so that Player 1's process contains accurate info
- Server sends out Player 1 collisions to Player 2's process as an event.
- Server always authoratative on all vehicle positions in the world.
- Player 1's client process -
Networking Protocol
I defined the unique race game ID as: #define RACE_GAME_ID 104
These are the structures that we are using for the Network Protocol, let me know if we need to change them.
Here are the packet types: // The packet type is a Byte 0-255 are legal values enum p_PacketType { CONNECT_REQ_PKT = 0, CONNECT_ACK_PKT = 1, CONNECT_REJ_PKT = 2, DISCONNECT_PKT = 3, CHAT_PKT = 4, ADD_PLAYER_REQ_PKT = 5, ADD_PLAYER_PKT = 6, ADD_PLAYER_REJ_PKT = 7, INPUT_UP_PKT = 8, LOCATION_UP_PKT = 9, LOAD_LEVEL_PKT, LOAD_LEVEL_ACK_PKT, TIME_PKT, PING_PKT, PING_ACK_PKT, START_RACE_PKT, FINISHED_RACE_PKT, PLAY_SND_PKT,
PACKET_SNIFF_PKT = 255 };
Here are the packet structures:
/ Game Packet header for all packets
typedef struct {
BYTE ident; // unique identifier to identify our game from others. ULONG timestamp;
} GamePacketHeader;
// This is a special packet that I use to figure out what the packet type is when it comes over the network typedef struct {
GamePacketHeader header; BYTE type; // packet type
} PACKET_SNIFF;
// Here we list all of the game packet types
typedef struct {
GamePacketHeader header; BYTE type; // packet type
} CONNECT_REQ;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID;
} CONNECT_ACK;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE code;
} CONNECT_REJ;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID;
} DISCONNECT;
typedef struct {
GamePacketHeader header; BYTE type; // packet type
//BYTE size; //CHAR *msg;
wchar msg[ 256 ];
} CHAT;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE modelID; BYTE size; CHAR *name;
// wchar name[ 256 ]; } ADD_PLAYER_REQ;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID; BYTE entityID; BYTE size; CHAR *name;
// wchar name[ 256 ]; } ADD_PLAYER;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE code;
} ADD_PLAYER_REJ;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID; FLOAT turning; FLOAT acceleration; BYTE handbrake;
} INPUT_UP;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID; BYTE entityID; FLOAT locationX; FLOAT locationY; FLOAT locationZ; FLOAT rotation; FLOAT velocity;
} LOCATION_UP;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE mapID;
} LOAD_LEVEL;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID;
} LOAD_LEVEL_ACK;
typedef struct {
GamePacketHeader header; BYTE type; // packet type FLOAT time;
} TIME;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE data;
} PING;
typedef struct { GamePacketHeader header; BYTE type; // packet type BYTE data; } PING_ACK;
typedef struct {
GamePacketHeader header; BYTE type; // packet type FLOAT atTime;
} START_RACE;
typedef struct { GamePacketHeader header; BYTE type; // packet type BYTE clientID; BYTE entityID; FLOAT atTime; } FINISHED_RACE;
typedef struct {
GamePacketHeader header; BYTE type; // packet type BYTE clientID; BYTE entityID; FLOAT sndID;
} PLAY_SND;
Low Level Networking Discussion
- Single Threaded Method
- On the server:
- socket()
- bind()
- listen()
- Each frame:
- select() time: {0,0} (poll)
- if returns "ready" then:
- accept() (creates client socket, will return immediately)
- With each client socket:
- select() on receive - time: {0,0} (poll)
- if returns "ready" then:
- recv() (returns immediately)
- send() as needed
- On the client:
- socket()
- connect() (connects to server)
- Each frame:
- select() on receive - time: {0,0} (poll)
- if returns "ready" then:
- recv() (returns immediately)
- send() as needed
- On the server:
- OK so I didn't follow this when I changed the Network code to C++. I added Asynchronous Socket connections.
I can easily change that back to the polling way. Maybe we can do some timing on it to see what the difference is or how many packets get lost.
Here is some more discussion about packets, more questions then answers right now:
What do you want for Packet messaging?
Create Packets
Take a structure like so (Are these structures ok, or do they need changes?):
// Game Packet header
typedef struct {
BYTE ident; // unique identifier to identify our game from others. ULONG timestamp;
} GamePacketHeader;
// Here we list all of the game packet types typedef struct { GamePacketHeader header; BYTE type; // packet type } CONNECT_REQ;
typedef struct { GamePacketHeader header; BYTE type; // packet type BYTE clientID; } CONNECT_ACK;
How to turn that into a packet to send on a socket.
This has to be a string or an array of char[] What will this look like when it is put into the string. What are the best functions to use for putting it into a string, what kind of string should it be? Should we use the StrUtil::Format function?
What is all this stuff you said about byte ordering and compressing?
Here is the send function:
numSent = send( clientSock[i], (char *)fdata.c_str(), fdata.length(), 0 ); sending is easy once the message has been formatted.
What kind of accessor functions should we have for the network class for this? Where will the packets be built, in the network code or somewhere else?
Parse Packets
to parse the packets the best way to to create a function that will read in the header and packet type then compute or lookup from a table the size of the structure to know how many more bytes to read. Read the rest of the bytes and send that to a function to parse.
What is this about setting up a queue? Do we need to have that for this program?
What is the best way to extract out the data from the stream?
Create some small functions that will parse each of the data types and return it’s value.
Char to Int,
Char to float
what else do we need?
Here is the receive function:
char data[ 256 ]; int numRecv = recv( wParam, data, 256, 0 );
What is a good data size to receive? Will it always read that many bytes or can you stop at any time? If you read more then you should then what? How do you know when the end of the packet has arrived? Where will the packets be assembled in the Network code or somewhere else?
Ed
- Graphics
- Will be using DXUT classes for doing most of the graphics work. It is a framework wrapper around D3D and D3DX that provides many of the things you need in order to get a game up and running quickly.
- Physics
- Will be using Havok for game physics. Havok has a vehicle simulation that provides a quick and easy way to create vehicles with full functioning vehicle dynamics.
- GUI
- DXUT also provides user-interface classes. We'll be using this to quickly develop menu screens and huds.
- Camera system
- Racing cam, no object-on-a-stick.
- Develop GOCs
- Physics GOCs, Render GOCs, Mesh GOCs, etc
Paul
- Game Object System
- The Game Object System is based of the work Scott Bilas did in the game Dungeon Siege. He has an introduction to the Game Object system on his site: A Data-Driven Game Object System GDC 2002 (http://www.drizzle.com/~scottb/gdc/game-objects_files/frame.htm)
- Game Object System is comprised of 3 main objects. The World List contains a list of all the Game Objects (GOs) in the world. We will use this list for updating and rendering the GOs. A Game Object is a list of Game Object Components (GOCs). A Game Object Component is a lightweight component that performs a specific function, or holds a specific collection of data. The idea being that any given GO is simply comprised of any given number of GOCs. This, hopefully, eliminates the problems you experience when you design a hierarchical based object system. (Every object in the game derives off a base object, and you create a deep and elaborate object hierarchy).
- Develop GOCs
- Position GOC, Gameplay GOCs, Light GOC, etc
Patrick
- Input
- Will add the DirectInput stuff or use DX utilities for joystick and keyboard
- Sound
- Single-shot
- Load(), Play(), Pause(), Stop()
- SetPosition(), Localize sound (must keep a sound cookie around to reference the sound)
- SetPitch(), looping engine sound, adjust pitch based on car rpms
- Streaming
- Use DShow for loading, playing mp3s
- Use hard-coded sound references for now, eventual goal is to have a sound manager to keep track of loaded sounds
- Single-shot
- Screen-shot code
- Logging code
- Can this be adapted for replays, ghosting?
- Collect more reference material
- Develop GOCs
- Sound GOC, Gameplay GOCs, etc
Game Play
Some desireable gameplay features -
- Intro flybys
- Race Countdown
- Race Timers
- Winner flyby
- Winning lap
- Ghost drivers (from previous lap)
- Collecting powerups
- Weapons
- Jumps
- Bridges
- Split screen multiplayer (same process)
- One player drives, other player controls the turret
- Rear-view mirror
- Localized radio music in the car. Able to hear radio from other cars as they approach.
- Boost strips
Rendering
Physics
Collision Detection
Input
Game Object System
Sound
Chatting System
Text
Voice
Authentication Lobby Server
Networking
Network protocol design
Packet network protocol –
- Trigger Sound packet
- Obj location and Position
- Start game, end game
- Start level, end level
- Player alive, player dead
- Chat text
- Voice packet
- Collision detection
- Dead reckoning
- Sending terrain and maps
- Map loads
- Time stamp
- Priority
- Data
- Critical or not
Peer to Peer
Client-Sever
Profiling and Logging
Menu Screens
- Title screen (intro fmv if we can find one)
- Main Menu
- Single Player <<< Net Racing Game >>>
- Host Game
- Join Game (cool picture of car)
- Settings
- Quit << Prev >> Pick Your Car << Next >>
- Host Game Lobby
Players joined Chat
* Ed - <Paul> Let's start already!
* Patrick - <Ed> I thought we were waiting?
* Paul - <Patrick> No, we're ready, let's go!
-> __________________________________
<< Start Game >> << Leave Lobby (disconnect) >>
- Join Game - List of Games
Games waiting for Players
* 192.168.0.10 << Join Game >>
* 192.168.0.11 <-- selected
Game Info Players Waiting
Server: 192.168.0.10 * Patrick (server)
* Ed
* Paul
- Join Game Lobby
Players joined Chat
* Ed - <Paul> Let's start already!
* Patrick - <Ed> I thought we were waiting?
* Paul - <Patrick> No, we're ready, let's go!
-> __________________________________
<< Leave Lobby (disconnect) >>
