root/cafu/trunk/Games/PlayerCommand.hpp

Revision 457, 3.9 KB (checked in by Carsten, 4 months ago)

Using UltraEdit's multi-line search-and-replace-in-files feature, replaced


^#ifndef _(CAFU|CF|CFS|CA)_(.*)_$
^#define _\1_\2_$

with

#ifndef CAFU_\2_INCLUDED
#define CAFU_\2_INCLUDED

and


^#ifndef _(.*)_HPP_$
^#define _\1_HPP_$

with

#ifndef CAFU_\1_HPP_INCLUDED
#define CAFU_\1_HPP_INCLUDED

Closes #91.

Line 
1/*
2=================================================================================
3This file is part of Cafu, the open-source game engine and graphics engine
4for multiplayer, cross-platform, real-time 3D action.
5Copyright (C) 2002-2012 Carsten Fuchs Software.
6
7Cafu is free software: you can redistribute it and/or modify it under the terms
8of the GNU General Public License as published by the Free Software Foundation,
9either version 3 of the License, or (at your option) any later version.
10
11Cafu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13PURPOSE. See the GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with Cafu. If not, see <http://www.gnu.org/licenses/>.
17
18For support and more information about Cafu, visit us at <http://www.cafu.de>.
19=================================================================================
20*/
21
22/**********************/
23/*** Player Command ***/
24/**********************/
25
26#ifndef CAFU_PLAYERCOMMAND_HPP_INCLUDED
27#define CAFU_PLAYERCOMMAND_HPP_INCLUDED
28
29
30// Player command key flags
31const unsigned long PCK_MoveForward =0x00000001;
32const unsigned long PCK_MoveBackward=0x00000002;
33const unsigned long PCK_TurnLeft    =0x00000004;
34const unsigned long PCK_TurnRight   =0x00000008;
35const unsigned long PCK_StrafeLeft  =0x00000010;
36const unsigned long PCK_StrafeRight =0x00000020;
37const unsigned long PCK_LookUp      =0x00000040;
38const unsigned long PCK_LookDown    =0x00000080;
39const unsigned long PCK_CenterView  =0x00000100;
40const unsigned long PCK_Jump        =0x00000200;    // Jump
41const unsigned long PCK_Duck        =0x00000400;    // Duck
42const unsigned long PCK_Walk        =0x00000800;    // Walk (slower than normal)
43const unsigned long PCK_Fire1       =0x00001000;    // Primary   Fire (also used e.g. for "Respawn")
44const unsigned long PCK_Fire2       =0x00002000;    // Secondary Fire
45const unsigned long PCK_Use         =0x00004000;    // Use
46// Bits 28-31 are reserved for selecting the weapon slot!
47
48
49// Commonly used data structure to store and pass around player commands.
50// Shared among the game DLLs, the client and the server code.
51struct PlayerCommandT
52{
53    // 'Nr' is the consecutive number of this 'PlayerCommandT'.
54    // It can be thought of as the clients frame number, or the sequence number of the packet with which this
55    // 'PlayerCommandT' is sent to the server.
56    // The main property is that a human player entity never sees the same number twice ('Nr' is counted up).
57    // (However, 'PlayerCommandT's arriving at the server from *different* human player entites can well contain the same
58    //  numbers at a time. In such cases, even the enitre sequence of 'Nr's in consecutive 'PlayerCommandT's is identical,
59    //  because they are all treated likewise. Fortunately, that's not a problem:
60    //  Clients usually join the game at different times (yielding different starting numbers),
61    //  they have different FPS (the sequence of 'PlayerCommandT's advances at a different pace),
62    //  and finally different human player entities use the numbers entirely different.)
63    // The main purpose is to give the human player entity in the game DLL a way to derive pseudo random numbers
64    // (by using 'Nr' as table index) that also work in the presence of "client prediction".
65    float          FrameTime;
66    unsigned long  Keys;
67    unsigned short DeltaHeading;
68    unsigned short DeltaPitch;
69    unsigned short DeltaBank;
70    unsigned long  Nr;
71
72    PlayerCommandT(float FrameTime_=0, unsigned long Keys_=0, unsigned short DeltaHeading_=0, unsigned short DeltaPitch_=0, unsigned short DeltaBank_=0, unsigned long Nr_=0)
73        : FrameTime(FrameTime_), Keys(Keys_), DeltaHeading(DeltaHeading_), DeltaPitch(DeltaPitch_), DeltaBank(DeltaBank_), Nr(Nr_) {}
74};
75
76#endif
Note: See TracBrowser for help on using the browser.