genconmac.h File Reference

The game's general constants and macros. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define absval(v)   (((v) < 0) ? -(v) : (v))
 A simple absolute value function.
#define bitarraylen(bits, datatype)   rounddivup(bits, sizeof(datatype) * 8)
 Computes the length of an array, in elements, that can store a minimum number of bits.
#define bitflag(bitid, datatype)   (1 << ((bitid) & (sizeof(datatype) * 8 - 1)))
 Produces the bit flag for a particular bit at its location in an array.
#define bitindex(bitid, datatype)   (((unsigned)bitid) / ((unsigned)sizeof(datatype) * (unsigned)8))
 Finds the index into an array for a particular bit.
#define BOTTOM_MARGIN   4
 The margin, in pixels, between the GPL or menu items and the bottom of the window.
#define DEAD_TIME   180
 The number of frames a player stays dead after being hit.
#define FMOTION_0_0   0.0f
#define FMOTION_0_1   1.0f
#define FMOTION_22_0   0.374606593f
#define FMOTION_22_1   0.927183855f
#define FMOTION_45_0   0.707106781f
#define FMOTION_45_1   0.707106781f
#define FRAME_DURATION   16
 The intended duration of each frame in milliseconds.
#define MAX_NAME_LEN   32
 The maximum number of characters allowed in a player's name.
#define MAX_PLAYERS   32
 The maximum number of players allowed to participate in a single game.
#define MOTION_0_0   0
#define MOTION_0_1   256
#define MOTION_22_0   98
#define MOTION_22_1   237
#define MOTION_45_0   181
#define MOTION_45_1   181
#define MOTION_DIV   4
#define MOTION_SHELL_FACTOR   5
 The constant multiplied to the values in the motion table to produce the motion values for shells.
#define rounddiv(n, d)   ((((n) % (d)) > ((int)(d) / 2)) ? ((int)(n) / (d) + 1) : ((int)(n) / (d)))
 Divides and rounds up if the fractional part of the result is greater than 0.5.
#define rounddivup(n, d)   ((((n) % (d)) > 0) ? ((int)(n) / (d) + 1) : ((int)(n) / (d)))
 Divides integers and rounds up any fractional part of the result.
#define SHELL_GUIDED_DIST   96
 The maximum distance a guided shell can travel.
#define SHELL_PONG_DIST   192
 The maximum distance a pong shell can travel.
#define SRV_FRAME_OFFSET   6
 The server's time offset of each frame in milliseconds relative to the client's frame.
#define TOP_MARGIN   8
 The margin, in pixels, between the game's title and the top of the window.

Enumerations

enum  {
  TEAM_RED, TEAM_BLUE, TEAM_GREEN, TEAM_PURPLE,
  TEAM_MAX, TEAM_UNDEC = 0xFF
}
 The valid team codes. More...
enum  EVENT_TYPES {
  EC_FORWARD, EC_BACKWARD, EC_ROTRIGHT, EC_ROTLEFT,
  EC_FIRE, EC_FS_TOGGLE, EC_CHARACTER, EC_MAX
}
 The high-level event types used in the game and the menus to abstract the different inputs that can trigger the events. More...
enum  LAYERS {
  LAYER_BACKGROUND, LAYER_OBSTACLES, LAYER_TEXT, LAYER_NAMES,
  LAYER_TANKS, LAYER_MAX
}
 The layer codes. More...

Variables

Uint8 eventState [EC_MAX]
 The event codes that are used to process user input in a way that separates the exact input used from the code that responds to the input.


Detailed Description

The game's general constants and macros.

Author:
Jeff Jackowski (jeffj@ro.com)
Copyright (C) 2007 Jeff Jackowski

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Or visit their website at: http://www.gnu.org/

Definition in file genconmac.h.


Define Documentation

#define absval (  )     (((v) < 0) ? -(v) : (v))

A simple absolute value function.

Avoids having to inculde math libraries that would be underused by this program.

Parameters:
v The value who's magnetude will be returned.
Returns:
The absolute value of v.
Author:
Jeff Jackowski

Definition at line 269 of file genconmac.h.

#define bitarraylen ( bits,
datatype   )     rounddivup(bits, sizeof(datatype) * 8)

Computes the length of an array, in elements, that can store a minimum number of bits.

This macro is a constant when given parameters with constant values.

Parameters:
bits The minimum number of bits the array must hold.
datatype The array element data type.
Author:
Jeff Jackowski

Definition at line 260 of file genconmac.h.

#define bitflag ( bitid,
datatype   )     (1 << ((bitid) & (sizeof(datatype) * 8 - 1)))

Produces the bit flag for a particular bit at its location in an array.

Parameters:
bitid The number of the bit in the array.
datatype The array element data type.
Author:
Jeff Jackowski

Definition at line 251 of file genconmac.h.

Referenced by FlagCfgMsg().

#define bitindex ( bitid,
datatype   )     (((unsigned)bitid) / ((unsigned)sizeof(datatype) * (unsigned)8))

Finds the index into an array for a particular bit.

Parameters:
bitid The number of the bit in the array.
datatype The array element data type.
Author:
Jeff Jackowski

Definition at line 242 of file genconmac.h.

Referenced by FlagCfgMsg().

#define BOTTOM_MARGIN   4

The margin, in pixels, between the GPL or menu items and the bottom of the window.

Definition at line 63 of file genconmac.h.

Referenced by BfldErrResize(), and SplashResize().

#define DEAD_TIME   180

The number of frames a player stays dead after being hit.

Definition at line 209 of file genconmac.h.

Referenced by AddPlayer(), HandleInput(), HandlePlayerSpawn(), ReadPlayer(), and UpdatePlayers().

#define FMOTION_0_0   0.0f

Definition at line 181 of file genconmac.h.

#define FMOTION_0_1   1.0f

Definition at line 182 of file genconmac.h.

#define FMOTION_22_0   0.374606593f

Definition at line 183 of file genconmac.h.

#define FMOTION_22_1   0.927183855f

Definition at line 184 of file genconmac.h.

#define FMOTION_45_0   0.707106781f

Definition at line 185 of file genconmac.h.

#define FMOTION_45_1   0.707106781f

Definition at line 186 of file genconmac.h.

#define FRAME_DURATION   16

The intended duration of each frame in milliseconds.

Definition at line 46 of file genconmac.h.

Referenced by ClientSync(), GameUninit(), main(), and UpdatePlayers().

#define MAX_NAME_LEN   32

The maximum number of characters allowed in a player's name.

Definition at line 30 of file genconmac.h.

Referenced by AppendPlayerData(), ReadPlayer(), SetLocalPlayerName(), and SetUsername().

#define MAX_PLAYERS   32

The maximum number of players allowed to participate in a single game.

Increasing the value can cause an exponential increase in the iterations through some loops.

Note:
This value should be a power of two for best performance and use of memory.
Warning:
Setting this value to more than 256 will require changes to the code and to the newtork message formats.

Definition at line 41 of file genconmac.h.

Referenced by AddScoreNotice(), AddToConfigList(), BatchRender(), DisablePlayerLabels(), EnablePlayerLabels(), GameInit(), GameRun(), GameUninit(), HandleConnAccept(), HandleConnDisconn(), HandleConnReq(), HandleScoreUpdate(), MessageCliToSrv(), NetCliToSrv(), ReadPlayer(), ReceiveMessages(), Send(), SpawnTank(), TeamSelUninit(), TeamSelUpdate(), UpdatePlayers(), and ValidateClient().

#define MOTION_0_0   0

Definition at line 174 of file genconmac.h.

#define MOTION_0_1   256

Definition at line 175 of file genconmac.h.

#define MOTION_22_0   98

Definition at line 176 of file genconmac.h.

#define MOTION_22_1   237

Definition at line 177 of file genconmac.h.

#define MOTION_45_0   181

Definition at line 178 of file genconmac.h.

#define MOTION_45_1   181

Definition at line 179 of file genconmac.h.

#define MOTION_DIV   4

Definition at line 188 of file genconmac.h.

#define MOTION_SHELL_FACTOR   5

The constant multiplied to the values in the motion table to produce the motion values for shells.

Definition at line 194 of file genconmac.h.

Referenced by MoveShell().

#define rounddiv ( n,
 )     ((((n) % (d)) > ((int)(d) / 2)) ? ((int)(n) / (d) + 1) : ((int)(n) / (d)))

Divides and rounds up if the fractional part of the result is greater than 0.5.

Only integer instructions are used. Implemented as a macro. Any compiler should be able to reduce this to a constant if both parameters are constants.

Parameters:
n The numerator.
d The denominator.
Returns:
The divided result after rounding.
Author:
Jeff Jackowski

Definition at line 221 of file genconmac.h.

#define rounddivup ( n,
 )     ((((n) % (d)) > 0) ? ((int)(n) / (d) + 1) : ((int)(n) / (d)))

Divides integers and rounds up any fractional part of the result.

Any compiler should be able to reduce this to a constant if both parameters are constants.

Parameters:
n The numerator.
d The denominator.
Returns:
The divided result after rounding up.
Author:
Jeff Jackowski

Definition at line 233 of file genconmac.h.

Referenced by BatchRender(), FlagCfgMsg(), ReceiveMessages(), and ResizeWindow().

#define SHELL_GUIDED_DIST   96

The maximum distance a guided shell can travel.

Definition at line 199 of file genconmac.h.

Referenced by MoveShell().

#define SHELL_PONG_DIST   192

The maximum distance a pong shell can travel.

For these shells to be effective, they must travel notably further than guided shells.

Definition at line 204 of file genconmac.h.

Referenced by MoveShell().

#define SRV_FRAME_OFFSET   6

The server's time offset of each frame in milliseconds relative to the client's frame.

Definition at line 52 of file genconmac.h.

Referenced by GameInit().

#define TOP_MARGIN   8

The margin, in pixels, between the game's title and the top of the window.

Definition at line 57 of file genconmac.h.

Referenced by BfldErrResize(), SetupMenu(), SplashResize(), and UpdateNotices().


Enumeration Type Documentation

anonymous enum

The valid team codes.

Enumerator:
TEAM_RED  The red team as seen in non-pong tank games in the original Combat.
TEAM_BLUE  The blue team as seen in non-pong tank games in the original Combat.
TEAM_GREEN  The green team as seen in pong tank games in the original Combat.

Warning:
This team's use is not fully implemented.
TEAM_PURPLE  The purple team as seen in pong tank games in the original Combat.

Warning:
This team's use is not fully implemented.
TEAM_MAX 
TEAM_UNDEC  The team value used for players who have connected to the server but have yet to select a team to join.

Definition at line 120 of file genconmac.h.

enum EVENT_TYPES

The high-level event types used in the game and the menus to abstract the different inputs that can trigger the events.

Enumerator:
EC_FORWARD  The up input; a request to move the tank forward.
EC_BACKWARD  The down input; a request to move the tank backward.
EC_ROTRIGHT  Request to turn the tank right.
EC_ROTLEFT  Request to turn the tank left.
EC_FIRE  Request to fire a shell.
EC_FS_TOGGLE  Request to toggle between full-screen and windowed display.
EC_CHARACTER  A character event status.

The event does not include the character code, just information on the status of the key press.

EC_MAX 

Definition at line 69 of file genconmac.h.

enum LAYERS

The layer codes.

Enumerator:
LAYER_BACKGROUND  Used for the background (image, solid color, .

..).

LAYER_OBSTACLES  Used for obstales on the play field.
LAYER_TEXT  Used for text messages.
LAYER_NAMES  Used for player name labels on the tanks.
LAYER_TANKS  Used for tanks and shells.
LAYER_MAX 

Definition at line 150 of file genconmac.h.


Generated on Mon May 28 04:41:39 2007 for Retro Tank Super Attack by  doxygen 1.5.2