Example #1
0
FILE *safe_fopen( char *filename, char *mode )
{
	FILE
		*fp;

	ASSERT (filename);

	ASSERT (mode);

	fp = fopen( filename, mode );

	if ( !fp )
	{

		if ( ( *mode == 'r' ) || ( *mode == 'R' ) )
		{

			debug_fatal("Error opening file for reading: %s", filename );
		}
		else if ( ( *mode == 'w' ) || ( *mode == 'W' ) )
		{

			debug_fatal("Error opening file for writing: %s", filename );
		}
		else
		{

			debug_fatal("Error opening file %s", filename );
		}
	}

	return fp;
}
Example #2
0
void load_global_options_data (void)
{

	FILE
		*file_ptr;

	int
		size;

	if (!file_exist (global_options_filename))
	{

		return;
	}

	if (!(file_ptr = fopen (global_options_filename, "rb")))
	{

		debug_fatal ("Global: Error loading global options data (file : %s)", global_options_filename);
	}

	//
	// We have to be able to read in previous version of the global options file.
	//

	size = file_size (global_options_filename);

	#ifdef DEBUG

	if (size != sizeof (global_options))
	{
		debug_fatal ("Global: Global options file has changed size (file : %s) - Please delete it", global_options_filename);
	}

	#endif

	if (size > sizeof (global_options))
	{

		debug_fatal ("Global: Global options file is oversized (file : %s) - Please delete it", global_options_filename);
	}

	fread (&global_options, size, 1, file_ptr);

  	fclose (file_ptr);

	//
	// Need to upgrade the version number ( possibly )
	//

	if ( ( get_global_version_number () != application_version_number ) || ( size != sizeof ( global_options ) ) )
	{

		debug_log ( "Upgrading application version number" );

		initialise_global_options_data_version2 ();
	}

	set_global_version_number (application_version_number);
}
Example #3
0
void *safe_mopen (char *filename)
{
	void
		*ptr;

	ASSERT (filename);

	ptr = mopen (filename);

	if ( !ptr )
	{

		if ( file_exist ( filename ) )
		{

			debug_fatal ( "Unable to map file %s\n\nThis may be due to lack of virtual memory", filename );
		}
		else
		{

			debug_fatal ( "Unable to load file %s", filename );
		}
	}

	safe_memory_mapped_file_counter++;

	return (ptr);
}
Example #4
0
int get_regen_sub_type (int type)
{
	int
		regen_type;

	switch (type)
	{
		case ENTITY_TYPE_FIXED_WING:
		{
			regen_type = ENTITY_SUB_TYPE_REGEN_FIXED_WING;

			break;
		}
		
		case ENTITY_TYPE_HELICOPTER:
		{
			regen_type = ENTITY_SUB_TYPE_REGEN_HELICOPTER;

			break;
		}
		
		case ENTITY_TYPE_ROUTED_VEHICLE:
		{
			regen_type = ENTITY_SUB_TYPE_REGEN_GROUND;

			break;
		}
		
		case ENTITY_TYPE_SHIP_VEHICLE:
		{
			regen_type = ENTITY_SUB_TYPE_REGEN_SEA;

			break;
		}
		
		case ENTITY_TYPE_PERSON:
		{
			regen_type = ENTITY_SUB_TYPE_REGEN_PEOPLE;

			break;
		}
		
		case ENTITY_SUB_TYPE_REGEN_NONE:
		{
			debug_fatal ("RG_UPDT: illegal regen sub type: ENTITY_SUB_TYPE_REGEN_NONE");
		}
		
		default:
		{
			debug_fatal ("RG_UPDT: Unknown entity type");
		}
		
	}

	return regen_type;
}
Example #5
0
static void default_unpack_entity_data (entity *en, entity_types type, pack_modes mode)
{
    if (mode == PACK_MODE_UPDATE_ENTITY)
    {
        debug_fatal ("default_unpack_entity_data invoked: %s (index = %d)", get_local_entity_type_name (en), get_local_entity_index (en));
    }
    else
    {
        debug_fatal ("default_unpack_entity_data invoked: %s", get_entity_type_name (type));
    }
}
Example #6
0
static float get_eo_sensor_fov(eo_params *eo, target_acquisition_systems system)
{
	// TODO: change fov numbers
	float fov = 9.0;

	switch (eo->field_of_view)
	{
		case EO_FOV_MEDIUM:
		{
			if (system == TARGET_ACQUISITION_SYSTEM_FLIR)
				fov = 4.0 * ONE_OVER_SQRT2;
			else  // DTV or DVO
				fov = 2.0 * ONE_OVER_SQRT2;

			break;
		}
		case EO_FOV_WIDE:
		{
			if (system == TARGET_ACQUISITION_SYSTEM_FLIR)
				fov = 15.0 * ONE_OVER_SQRT2;
			else  // DVO
				fov = 9.0 * ONE_OVER_SQRT2;

			break;
		}
		default:
		{
			debug_fatal ("Invalid field of view = %d", eo->field_of_view);

			break;
		}
	}

	return fov;
}
Example #7
0
static void *get_local_ptr_value (entity *en, ptr_types type)
{
	waypoint
		*raw;

	void
		*ptr;

	raw = get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case PTR_TYPE_POSITION_ENTITY:
		////////////////////////////////////////
		{
			debug_fatal ("WP_PTR: REMOVE");
			ptr = raw->position_entity;

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_ptr_type (en, type);

			break;
		}
	}

	return (ptr);
}
Example #8
0
//**********************************************************************
//	Filename:	KEYMAPPING.C
//	Authors:	Lukas "Retro" Friembichler
//	Date:		20. Mar 2003
//	Update:
//
//	Description:	Well.. hmm... uuuug... rrrriiight...
//					New user-configurable keymapping
//	Developers!:	if you add a key, use set_configurable_event
//					instead of set_event, you can use whatever string you
//					want to 'name' that function (well... please keep it short,
//					50 chars at max) - that´s all you have to do, it might
//					be a good idea telling the users this string, so that
//					they can map it..
//*********************************************************************/
#include "system.h"

#include "cmndline.h"

#include "keymapping.h"

//#define SHOW_COMMENT_LINES	// prints comment-lines into "comment.txt"

//#define TELL_ME_WHAT_YOU_SEE	// prints other lines into "echo.txt"

//#define TIGHT_ARSE_DEBUG	// less forgiving version...

#define SHOW_UNKNOWNS	// if there´s a command registered (by using set_configurable_event () that is NOT in
						// the keymaps.cfg file, I get an error-output file (hopefully)

#define MAXMAPPINGS 300		// Max number of mappings, no real reason for 300 (just a number)

#define MAX_LINE_LENGTH 1024

#define SLIZE 50	// max length one command, keycombo or modifier can have.. (I´m still unconfortable using malloc())

//**********************************************************************
//	this struct represents one key;
//	the name as it is represented in the config file, and the assigned
//	direct-input-keypress (DIK)
//*********************************************************************/
typedef struct {
	char* key_name;
	int dik_val;
} key;

#define NUM_OF_KEYS 142

	key all_keys[NUM_OF_KEYS] = {

	{"ESCAPE",		0x01},
	{"1",			0x02},
	{"2",			0x03},
	{"3",			0x04},
	{"4",			0x05},
	{"5",			0x06},
	{"6",			0x07},
	{"7",			0x08},
	{"8",			0x09},
	{"9",			0x0A},
	{"0",			0x0B},
	{"MINUS",		0x0C},	  /* - on main keyboard */
	{"EQUALS",		0x0D},
	{"BACK",		0x0E},    /* backspace */
	{"BACKSPACE",	0x0E},    /* backspace */
	{"TAB",			0x0F},
	{"Q",			0x10},
	{"W",			0x11},
	{"E",			0x12},
	{"R",			0x13},
	{"T",			0x14},
	{"Y",			0x15},
	{"U",			0x16},
	{"I",			0x17},
	{"O",			0x18},
	{"P",			0x19},
	{"LBRACKET",	0x1A},
	{"RBRACKET",	0x1B},
	{"RETURN",		0x1C},    /* Enter on main keyboard */
	{"LCONTROL",	0x1D},
	{"A",			0x1E},
	{"S",			0x1F},
	{"D",			0x20},
	{"F",			0x21},
	{"G",			0x22},
	{"H",			0x23},
	{"J",			0x24},
	{"K",			0x25},
	{"L",			0x26},
	{"SEMICOLON",	0x27},
	{"APOSTROPHE",	0x28},
	{"GRAVE",		0x29},    /* accent grave */
	{"LSHIFT",		0x2A},
	{"BACKSLASH",	0x2B},
	{"Z",			0x2C},
	{"X",			0x2D},
	{"C",			0x2E},
	{"V",			0x2F},
	{"B",			0x30},
	{"N",			0x31},
	{"M",			0x32},
	{"COMMA",		0x33},
	{"PERIOD",		0x34},    /* . on main keyboard */
	{"SLASH",		0x35},    /* / on main keyboard */
	{"RSHIFT",		0x36},
	{"MULTIPLY",	0x37},
	{"NUMPADSTAR",	0x37},    /* * on numeric keypad */
	{"LMENU",		0x38},
	{"LALT",		0x38},    /* left Alt */
	{"SPACE",		0x39},
	{"CAPITAL",		0x3A},
	{"CAPSLOCK",	0x3A},
	{"F1",			0x3B},
	{"F2",			0x3C},
	{"F3",			0x3D},
	{"F4",			0x3E},
	{"F5",			0x3F},
	{"F6",			0x40},
	{"F7",			0x41},
	{"F8",			0x42},
	{"F9",			0x43},
	{"F10",			0x44},
	{"NUMLOCK",		0x45},
	{"SCROLL",		0x46},    /* Scroll Lock */
	{"NUMPAD7",		0x47},
	{"NUMPAD8",		0x48},
	{"NUMPAD9",		0x49},
	{"SUBTRACT",	0x4A},
	{"NUMPADMINUS",	0x4A},    /* - on numeric keypad */
	{"NUMPAD4",		0x4B},
	{"NUMPAD5",		0x4C},
	{"NUMPAD6",		0x4D},
	{"ADD",			0x4E},
	{"NUMPADPLUS",	0x4E},    /* + on numeric keypad */
	{"NUMPAD1",		0x4F},
	{"NUMPAD2",		0x50},
	{"NUMPAD3",		0x51},
	{"NUMPAD0",		0x52},
	{"DECIMAL",		0x53},
	{"NUMPADPERIOD",0x53},    /* . on numeric keypad */
	{"OEM_102",		0x56},    /* < > | on UK/Germany keyboards */
	{"F11",			0x57},
	{"F12",			0x58},
	{"F13",			0x64},    /*                     (NEC PC98) */
	{"F14",			0x65},    /*                     (NEC PC98) */
	{"F15",			0x66},    /*                     (NEC PC98) */
	{"KANA",		0x70},    /* (Japanese keyboard)            */
	{"ABNT_C1",		0x73},    /* / ? on Portugese (Brazilian) keyboards */
	{"CONVERT",		0x79},    /* (Japanese keyboard)            */
	{"NOCONVERT",	0x7B},    /* (Japanese keyboard)            */
	{"YEN",			0x7D},    /* (Japanese keyboard)            */
	{"ABNT_C2",		0x7E},    /* Numpad . on Portugese (Brazilian) keyboards */
	{"NUMPADEQUALS",0x8D},    /* = on numeric keypad (NEC PC98) */
	{"CIRCUMFLEX",	0x90},    /* (Japanese keyboard)            */
	{"AT",			0x91},    /*                     (NEC PC98) */
	{"COLON",		0x92},    /*                     (NEC PC98) */
	{"UNDERLINE",	0x93},    /*                     (NEC PC98) */
	{"KANJI",		0x94},    /* (Japanese keyboard)            */
	{"STOP",		0x95},    /*                     (NEC PC98) */
	{"AX",			0x96},    /*                     (Japan AX) */
	{"UNLABELED",	0x97},    /*                        (J3100) */
	{"NUMPADENTER",	0x9C},    /* Enter on numeric keypad */
	{"RCONTROL",	0x9D},
	{"NUMPADCOMMA",	0xB3},    /* , on numeric keypad (NEC PC98) */
	{"DIVIDE",		0xB5},
	{"NUMPADSLASH",	0xB5},    /* / on numeric keypad */
	{"SYSRQ",		0xB7},
	{"RMENU",		0xB8},
	{"RALT",		0xB8},    /* right Alt */
	{"PAUSE",		0xC5},    /* Pause */
	{"HOME",		0xC7},    /* Home on arrow keypad */
	{"UP",			0xC8},
	{"UPARROW",		0xC8},
	{"PRIOR",		0xC9},
	{"PGUP",		0xC9},   /* PgUp on arrow keypad */
	{"LEFT",		0xCB},
	{"LEFTARROW",	0xCB},    /* LeftArrow on arrow keypad */
	{"RIGHT",		0xCD},
	{"RIGHTARROW",	0xCD},    /* RightArrow on arrow keypad */
	{"END",			0xCF},    /* End on arrow keypad */
	{"DOWN",		0xD0},
	{"DOWNARROW",	0xD0},    /* DownArrow on arrow keypad */
	{"NEXT",		0xD1},
	{"PGDN",		0xD1},    /* PgDn on arrow keypad */
	{"INSERT",		0xD2},    /* Insert on arrow keypad */
	{"DELETE",		0xD3},    /* Delete on arrow keypad */
	{"LWIN",		0xDB},    /* Left Windows key */
	{"RWIN",		0xDC},    /* Right Windows key */
	{"APPS",		0xDD},    /* AppMenu key */
	{"POWER",		0xDE},
	{"SLEEP",		0xDF},
	{"WAKE",		0xE3}
	};

//**********************************************************************
//	this struct represents one line of the config-file;
//	functionID, key, modifer and state
//*********************************************************************/
typedef struct {
	char	functionID[SLIZE];
	int		key,		// This is actually the DIK of the key..
			modifier,	// I guess with multiple modifiers per key this could become a bitfield..
			state;
} mapline;

static mapline keymaps[MAXMAPPINGS];

static int number_of_commands = 0;	// number of keymappings in the above array

//**********************************************************************
//
// Function:    check_for_validity
// Date:		21.3.2003
// Author:		Retro
//
// Description:		Should check for duplicate key+modifier combos,
//					and also for typos (?)
//					not yet used
//
//*********************************************************************/
int check_for_validity ( void )
{
	int i = 0;
	int j = 0;
	int numOfDuplicates = 0;

	int tmp_key;
	int tmp_mod;

	for ( i = 0; i < number_of_commands; i++)
	{
		tmp_key = keymaps[i].key;
		tmp_mod = keymaps[i].modifier;

		for ( j = 0; j < number_of_commands; j++)
		{
			if ((keymaps[i].key = tmp_key)&&(keymaps[i].modifier = tmp_mod))
			{
				numOfDuplicates++;
				if (numOfDuplicates > 1)
					debug_fatal ( "Duplicate key+modifier combination (%i) (%i)",tmp_key,tmp_mod );
			}
		}
		numOfDuplicates = 0;
	}

	return 0;
}

//**********************************************************************
//
// Function:    get_DIK_from_string
// Date:		21.3.2003
// Author:		Retro
//
// Description:		returns direct-input-keypress (DIK) on input-string.
//					uses the all_keys array defined above
//
//*********************************************************************/
int get_DIK_from_string ( char* keystring )
{
	int i;
	int retval = 0;

	for ( i = 0; i < NUM_OF_KEYS; i++ )
	{
		if ( strcmp(all_keys[i].key_name,keystring) == 0 )
		{
			retval = all_keys[i].dik_val;
			break;
		}
	}
	if ( retval == 0 )	// kinda crappy way of error checking.. if reval is still 0, obviously no string matched.
	{
		debug_fatal ( "Don´t know key %s",keystring );
	}

	return retval;
}

//**********************************************************************
//
// Function:    get_modifier_from_string
// Date:		21.3.2003
// Author:		Retro
//
// Description:		returns modifier enum on input-string
//					note that in non-debug builds, right and left modifiers
//					are considered the same...
//
//*********************************************************************/
int get_modifier_from_string ( char* modifierstring )
{
	int retval = 0;
	
	if ( strcmp ( modifierstring, "MODIFIER_NONE") == 0 )
		retval = MODIFIER_NONE;
	else if ( strcmp ( modifierstring, "MODIFIER_LEFT_SHIFT") == 0 )
		retval = MODIFIER_LEFT_SHIFT;
	else if ( strcmp ( modifierstring, "MODIFIER_LEFT_CONTROL") == 0 )
		retval = MODIFIER_LEFT_CONTROL;
	else if ( strcmp ( modifierstring, "MODIFIER_LEFT_ALT") == 0 )
		retval = MODIFIER_LEFT_ALT;
	else if ( strcmp ( modifierstring, "MODIFIER_RIGHT_SHIFT") == 0 )
		retval = MODIFIER_RIGHT_SHIFT;
    else if ( strcmp ( modifierstring, "MODIFIER_RIGHT_CONTROL") == 0 )
		retval = MODIFIER_RIGHT_CONTROL;
    else if ( strcmp ( modifierstring, "MODIFIER_RIGHT_ALT") == 0 )
		retval = MODIFIER_RIGHT_ALT;
	else
	{
		debug_fatal ( "Don´t know modifier %s",modifierstring );
	}

	return retval;
}
Example #9
0
void add_default_entity_to_regen_queue (entity_sides side, entity_sub_types group_type)
{
	switch (side)
	{
		case ENTITY_SIDE_BLUE_FORCE:
		{
			add_entity_to_regen_queue (side,
												group_database [group_type].default_entity_type,
												group_database [group_type].default_blue_force_sub_type,
												group_type);

			break;
		}
		case ENTITY_SIDE_RED_FORCE:
		{
			add_entity_to_regen_queue (side,
												group_database [group_type].default_entity_type,
												group_database [group_type].default_red_force_sub_type,
												group_type);

			break;
		}
		default:
		{
			debug_fatal ("RG_UPDT: Invalid Side %d For Default Entity Regen", side);

			break;
		}
	}
}
Example #10
0
void set_3d_fogmode ( env_3d *env, fogmodes mode )
{

	ASSERT ( env );

	env->fogmode = mode;

	switch ( mode )
	{

		case FOGMODE_ON_AUTOMATIC:
		case FOGMODE_ON_MANUAL:
		case FOGMODE_OFF:
		{
		
			break;
		}

		default:
		{

			debug_fatal ( "Unknown fogmode in set_3d_fogmode" );

			break;
		}
	}
}
Example #11
0
void add_sub_object_index_to_table ( object_3d_sub_object_index_numbers index, object_3d_database_entry *object )
{

	int
		count;

	for ( count = 0; count < number_of_sub_object_table_entries; count++ )
	{

		if ( current_sub_object_table[count].sub_object_index == index )
		{

			int
				offset;

			offset = current_sub_object_table[count].number_of_sub_objects;

			current_sub_object_table[count].sub_objects[offset] = object;

			current_sub_object_table[count].number_of_sub_objects++;

			return;
		}
	}

	debug_fatal ( "Unable to find sub object index in table" );
}
Example #12
0
void load_terrain_3d_tree_database ( char *sector_filename, char *data_filename )
{

	FILE
		*fp;

	int
		x_sector,
		z_sector;

	terrain_tree_data
		*tree_data;

	//
	// Memory map the tree data file
	//

	terrain_tree_database = mopen ( data_filename );

	if ( !terrain_tree_database )
	{

		debug_fatal ( "Unable to memory-map %s", data_filename );
	}

	//
	// Open the sector file
	//

	fp = safe_fopen ( sector_filename, "rb" );

	//
	// Go through all the sectors, setting the number of trees and the relevant pointer
	//

	tree_data = terrain_tree_database;

	for ( z_sector = 0; z_sector < terrain_3d_sector_z_max; z_sector++ )
	{

		for ( x_sector = 0; x_sector < terrain_3d_sector_z_max; x_sector++ )
		{

			fread ( &terrain_tree_sectors[z_sector][x_sector].number_of_trees, sizeof ( int ), 1, fp );

			if ( terrain_tree_sectors[z_sector][x_sector].number_of_trees )
			{

				terrain_tree_sectors[z_sector][x_sector].data = tree_data;

				tree_data += terrain_tree_sectors[z_sector][x_sector].number_of_trees;
			}
			else
			{

				terrain_tree_sectors[z_sector][x_sector].data = NULL;
			}
		}
	}
}
Example #13
0
void set_3d_lightmode ( env_3d *env, enum LIGHTMODES mode )
{

	ASSERT ( env );

	switch ( mode )
	{

		case LIGHTMODE_NO_LIGHT:
		case LIGHTMODE_AUTOMATIC_LIGHT:
		case LIGHTMODE_MANUAL_LIGHT:
		{

			break;
		}

		default:
		{

			debug_fatal ( "Trying to set an unknown light mode for 3d environment" );

			break;
		}
	}

	env->lightmode = mode;
}
Example #14
0
void create_new_pilot_name( entity_sides side, const char **firstname, const char **lastname )
{

	switch( side )
	{
		case ENTITY_SIDE_NEUTRAL:
		case ENTITY_SIDE_BLUE_FORCE:
		{

			*firstname = blue_side_first_name_list[ rand16() % NUM_BLUE_SIDE_FIRST_NAMES ];

			*lastname = blue_side_last_name_list[ rand16() % NUM_BLUE_SIDE_LAST_NAMES ];

			break;
		}
		case ENTITY_SIDE_RED_FORCE:
		{

			*firstname = red_side_first_name_list[ rand16() % NUM_RED_SIDE_FIRST_NAMES ];

			*lastname = red_side_last_name_list[ rand16() % NUM_RED_SIDE_LAST_NAMES ];

			break;
		}
		default:
		{

			debug_fatal( "Trying to create pilot for side %d", side );
		}
	}
}
Example #15
0
void set_cloud_3d_scan_radius ( int scan_radius )
{

	if ( ( scan_radius < 1 ) || ( scan_radius > 32 ) )
	{

		debug_fatal ( "Trying to set cloud scan radius to %d", scan_radius );
	}
	else
	{

		cloud_3d_sector_scan_radius = scan_radius;

		//
		// Now set up the blending constants
		//

		cloud_3d_blend_start = CLOUD_MINIMUM_BLEND_DISTANCE;

		cloud_3d_blend_end = CLOUD_MAXIMUM_BLEND_DISTANCE;

		cloud_3d_blend_distance = cloud_3d_blend_end - cloud_3d_blend_start;

		cloud_3d_blend_start_squared = cloud_3d_blend_start * cloud_3d_blend_start;

		cloud_3d_blend_distance_squared = cloud_3d_blend_distance * cloud_3d_blend_distance;

		cloud_3d_blend_constant = cloud_3d_blend_distance_squared - cloud_3d_blend_start_squared;

		cloud_3d_blend_factor = 1.0 / cloud_3d_blend_distance_squared;
	}
}
Example #16
0
//**********************************************************************
//	Filename:	KEYMAPPING.C
//	Authors:	Lukas "Retro" Friembichler
//	Date:		20. Mar 2003
//	Update:
//
//	Description:	Well.. hmm... uuuug... rrrriiight...
//					New user-configurable keymapping
//	Developers!:	if you add a key, use set_configurable_event
//					instead of set_event, you can use whatever string you
//					want to 'name' that function (well... please keep it short,
//					50 chars at max) - that´s all you have to do, it might
//					be a good idea telling the users this string, so that
//					they can map it..
//*********************************************************************/
#include "system.h"

#include "cmndline.h"

#include "keymapping.h"

//#define SHOW_COMMENT_LINES	// prints comment-lines into "comment.txt"

//#define TELL_ME_WHAT_YOU_SEE	// prints other lines into "echo.txt"

//#define TIGHT_ARSE_DEBUG	// less forgiving version...

#define SHOW_UNKNOWNS	// if there´s a command registered (by using set_configurable_event () that is NOT in
						// the keymaps.cfg file, I get an error-output file (hopefully)

#define MAXMAPPINGS 300		// Max number of mappings, no real reason for 300 (just a number)

#define MAX_LINE_LENGTH 1024

#define SLIZE 50	// max length one command, keycombo or modifier can have.. (I´m still unconfortable using malloc())

//**********************************************************************
//	this struct represents one key;
//	the name as it is represented in the config file, and the assigned
//	direct-input-keypress (DIK)
//*********************************************************************/
typedef struct {
	char* key_name;
	int dik_val;
} key;

#define NUM_OF_KEYS 142

	key all_keys[NUM_OF_KEYS] = {

	{"ESCAPE",		0x01},
	{"1",			0x02},
	{"2",			0x03},
	{"3",			0x04},
	{"4",			0x05},
	{"5",			0x06},
	{"6",			0x07},
	{"7",			0x08},
	{"8",			0x09},
	{"9",			0x0A},
	{"0",			0x0B},
	{"MINUS",		0x0C},	  /* - on main keyboard */
	{"EQUALS",		0x0D},
	{"BACK",		0x0E},    /* backspace */
	{"BACKSPACE",	0x0E},    /* backspace */
	{"TAB",			0x0F},
	{"Q",			0x10},
	{"W",			0x11},
	{"E",			0x12},
	{"R",			0x13},
	{"T",			0x14},
	{"Y",			0x15},
	{"U",			0x16},
	{"I",			0x17},
	{"O",			0x18},
	{"P",			0x19},
	{"LBRACKET",	0x1A},
	{"RBRACKET",	0x1B},
	{"RETURN",		0x1C},    /* Enter on main keyboard */
	{"LCONTROL",	0x1D},
	{"A",			0x1E},
	{"S",			0x1F},
	{"D",			0x20},
	{"F",			0x21},
	{"G",			0x22},
	{"H",			0x23},
	{"J",			0x24},
	{"K",			0x25},
	{"L",			0x26},
	{"SEMICOLON",	0x27},
	{"APOSTROPHE",	0x28},
	{"GRAVE",		0x29},    /* accent grave */
	{"LSHIFT",		0x2A},
	{"BACKSLASH",	0x2B},
	{"Z",			0x2C},
	{"X",			0x2D},
	{"C",			0x2E},
	{"V",			0x2F},
	{"B",			0x30},
	{"N",			0x31},
	{"M",			0x32},
	{"COMMA",		0x33},
	{"PERIOD",		0x34},    /* . on main keyboard */
	{"SLASH",		0x35},    /* / on main keyboard */
	{"RSHIFT",		0x36},
	{"MULTIPLY",	0x37},
	{"NUMPADSTAR",	0x37},    /* * on numeric keypad */
	{"LMENU",		0x38},
	{"LALT",		0x38},    /* left Alt */
	{"SPACE",		0x39},
	{"CAPITAL",		0x3A},
	{"CAPSLOCK",	0x3A},
	{"F1",			0x3B},
	{"F2",			0x3C},
	{"F3",			0x3D},
	{"F4",			0x3E},
	{"F5",			0x3F},
	{"F6",			0x40},
	{"F7",			0x41},
	{"F8",			0x42},
	{"F9",			0x43},
	{"F10",			0x44},
	{"NUMLOCK",		0x45},
	{"SCROLL",		0x46},    /* Scroll Lock */
	{"NUMPAD7",		0x47},
	{"NUMPAD8",		0x48},
	{"NUMPAD9",		0x49},
	{"SUBTRACT",	0x4A},
	{"NUMPADMINUS",	0x4A},    /* - on numeric keypad */
	{"NUMPAD4",		0x4B},
	{"NUMPAD5",		0x4C},
	{"NUMPAD6",		0x4D},
	{"ADD",			0x4E},
	{"NUMPADPLUS",	0x4E},    /* + on numeric keypad */
	{"NUMPAD1",		0x4F},
	{"NUMPAD2",		0x50},
	{"NUMPAD3",		0x51},
	{"NUMPAD0",		0x52},
	{"DECIMAL",		0x53},
	{"NUMPADPERIOD",0x53},    /* . on numeric keypad */
	{"OEM_102",		0x56},    /* < > | on UK/Germany keyboards */
	{"F11",			0x57},
	{"F12",			0x58},
	{"F13",			0x64},    /*                     (NEC PC98) */
	{"F14",			0x65},    /*                     (NEC PC98) */
	{"F15",			0x66},    /*                     (NEC PC98) */
	{"KANA",		0x70},    /* (Japanese keyboard)            */
	{"ABNT_C1",		0x73},    /* / ? on Portugese (Brazilian) keyboards */
	{"CONVERT",		0x79},    /* (Japanese keyboard)            */
	{"NOCONVERT",	0x7B},    /* (Japanese keyboard)            */
	{"YEN",			0x7D},    /* (Japanese keyboard)            */
	{"ABNT_C2",		0x7E},    /* Numpad . on Portugese (Brazilian) keyboards */
	{"NUMPADEQUALS",0x8D},    /* = on numeric keypad (NEC PC98) */
	{"CIRCUMFLEX",	0x90},    /* (Japanese keyboard)            */
	{"AT",			0x91},    /*                     (NEC PC98) */
	{"COLON",		0x92},    /*                     (NEC PC98) */
	{"UNDERLINE",	0x93},    /*                     (NEC PC98) */
	{"KANJI",		0x94},    /* (Japanese keyboard)            */
	{"STOP",		0x95},    /*                     (NEC PC98) */
	{"AX",			0x96},    /*                     (Japan AX) */
	{"UNLABELED",	0x97},    /*                        (J3100) */
	{"NUMPADENTER",	0x9C},    /* Enter on numeric keypad */
	{"RCONTROL",	0x9D},
	{"NUMPADCOMMA",	0xB3},    /* , on numeric keypad (NEC PC98) */
	{"DIVIDE",		0xB5},
	{"NUMPADSLASH",	0xB5},    /* / on numeric keypad */
	{"SYSRQ",		0xB7},
	{"RMENU",		0xB8},
	{"RALT",		0xB8},    /* right Alt */
	{"PAUSE",		0xC5},    /* Pause */
	{"HOME",		0xC7},    /* Home on arrow keypad */
	{"UP",			0xC8},
	{"UPARROW",		0xC8},
	{"PRIOR",		0xC9},
	{"PGUP",		0xC9},   /* PgUp on arrow keypad */
	{"LEFT",		0xCB},
	{"LEFTARROW",	0xCB},    /* LeftArrow on arrow keypad */
	{"RIGHT",		0xCD},
	{"RIGHTARROW",	0xCD},    /* RightArrow on arrow keypad */
	{"END",			0xCF},    /* End on arrow keypad */
	{"DOWN",		0xD0},
	{"DOWNARROW",	0xD0},    /* DownArrow on arrow keypad */
	{"NEXT",		0xD1},
	{"PGDN",		0xD1},    /* PgDn on arrow keypad */
	{"INSERT",		0xD2},    /* Insert on arrow keypad */
	{"DELETE",		0xD3},    /* Delete on arrow keypad */
	{"LWIN",		0xDB},    /* Left Windows key */
	{"RWIN",		0xDC},    /* Right Windows key */
	{"APPS",		0xDD},    /* AppMenu key */
	{"POWER",		0xDE},
	{"SLEEP",		0xDF},
	{"WAKE",		0xE3}
	};

//**********************************************************************
//	this struct represents one line of the config-file;
//	functionID, key, modifer and state
//*********************************************************************/
typedef struct {
	char	functionID[SLIZE];
	int		key,		// This is actually the DIK of the key..
			modifier,	// I guess with multiple modifiers per key this could become a bitfield..
			state;
} mapline;

static mapline keymaps[MAXMAPPINGS];

static int number_of_commands = 0;	// number of keymappings in the above array

//**********************************************************************
//
// Function:    check_for_validity
// Date:		21.3.2003
// Author:		Retro
//
// Description:		Should check for duplicate key+modifier combos,
//					and also for typos (?)
//					not yet used
//
//*********************************************************************/
int check_for_validity ( void )
{
	int i = 0;
	int j = 0;
	int numOfDuplicates = 0;

	int tmp_key;
	int tmp_mod;

	for ( i = 0; i < number_of_commands; i++)
	{
		tmp_key = keymaps[i].key;
		tmp_mod = keymaps[i].modifier;

		for ( j = 0; j < number_of_commands; j++)
		{
			if ((keymaps[i].key = tmp_key)&&(keymaps[i].modifier = tmp_mod))
			{
				numOfDuplicates++;
				if (numOfDuplicates > 1)
					debug_fatal ( "Duplicate key+modifier combination (%i) (%i)",tmp_key,tmp_mod );
			}
		}
		numOfDuplicates = 0;
	}

	return 0;
}
Example #17
0
void decrease_rocket_salvo_size (void)
{
	switch (rocket_salvo_size)
	{
		////////////////////////////////////////
		case 1:
		////////////////////////////////////////
		{
			break;
		}
		////////////////////////////////////////
		case 2:
		////////////////////////////////////////
		{
			rocket_salvo_size = 1;

			break;
		}
		////////////////////////////////////////
		case 4:
		////////////////////////////////////////
		{
			rocket_salvo_size = 2;

			break;
		}
		////////////////////////////////////////
		case 8:
		////////////////////////////////////////
		{
			rocket_salvo_size = 4;

			break;
		}
		////////////////////////////////////////
		case 16:
		////////////////////////////////////////
		{
			rocket_salvo_size = 8;

			break;
		}
		////////////////////////////////////////
		case ROCKET_SALVO_SIZE_ALL:
		////////////////////////////////////////
		{
			rocket_salvo_size = 16;

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal ("Invalid rocket salvo size = %d", rocket_salvo_size);

			break;
		}
	}
}
Example #18
0
void load_3d_terrain_game_data (void)
{

	char
		filename [1024];

	session_list_data_type
		*session;

	//
	// Load 3d terrain
	//

	unload_3d_terrain ();

	session = get_current_game_session ();

	sprintf (filename, "%s\\terrain", session->data_path);

	if (!load_3d_terrain (filename))
	{

		debug_fatal ("ZONE_FN: unable to load terrain");
	}

	//
	// Load 2d map
	//
	
	load_2d_terrain (session->data_path);
}
Example #19
0
static void get_local_vec3d (entity *en, vec3d_types type, vec3d *v)
{
	group
		*raw;

	ASSERT (v);

	raw = (group *) get_local_entity_data (en);

	switch (type)
	{
		////////////////////////////////////////
		case VEC3D_TYPE_POSITION:
		////////////////////////////////////////
		{
			#ifdef DEBUG
			
			debug_fatal ("Invalid call to get group position");

			#endif

			break;
		}
		////////////////////////////////////////
		case VEC3D_TYPE_LAST_KNOWN_POSITION:
		////////////////////////////////////////
		{
			#ifdef DEBUG
			
			debug_fatal ("Invalid call to get group last known position. Use ptr not vec3d copy");

			#endif

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal_invalid_vec3d_type (en, type);

			break;
		}
	}
}
Example #20
0
static void set_eo_view_params(target_acquisition_systems system, int x_min, int y_min, int x_max, int y_max, float xfov, float yfov)
{
	display_3d_light_levels
		light_level;

	display_3d_noise_levels
		noise_level;

	vec3d
		*position;

	weathermodes
		weather_mode;

	day_segment_types
		day_segment_type;

	display_3d_tints
		tint;

	position = get_local_entity_vec3d_ptr (get_gunship_entity (), VEC3D_TYPE_POSITION);

	weather_mode = get_simple_session_weather_at_point (position);
	ASSERT ((weather_mode > WEATHERMODE_INVALID) && (weather_mode < WEATHERMODE_LAST));

	day_segment_type = (day_segment_types) get_local_entity_int_value (get_session_entity (), INT_TYPE_DAY_SEGMENT_TYPE);
	ASSERT ((day_segment_type >= 0) && (day_segment_type < NUM_DAY_SEGMENT_TYPES));

	switch (system)
	{
		case TARGET_ACQUISITION_SYSTEM_FLIR:
		{
			light_level = flir_light_levels[weather_mode][day_segment_type];
			noise_level = flir_noise_levels[weather_mode][day_segment_type];
			tint = DISPLAY_3D_TINT_AMBER;

			break;
		}
		case TARGET_ACQUISITION_SYSTEM_LLLTV:
		{
			light_level = llltv_light_levels[weather_mode][day_segment_type];
			noise_level = llltv_noise_levels[weather_mode][day_segment_type];
			tint = DISPLAY_3D_TINT_AMBER_VISUAL;

			break;
		}
		default:
		{
			debug_fatal ("Invalid target acquisition system = %d", system);

			break;
		}
	}

	set_main_3d_params (tint, light_level, noise_level, x_min, y_min, x_max, y_max, xfov, yfov);
}
Example #21
0
object_3d_sub_instance* find_sub_object(object_3d_instance* parent_object, unsigned sub_obj_id)
{
	object_3d_sub_object_search_data
		search;

	const char* name = (sub_obj_id < OBJECT_3D_SUB_OBJECT_LAST) ? object_3d_subobject_names[sub_obj_id] : NULL;

	search.search_depth = 0;
	search.search_object = parent_object;
	search.sub_object_index = sub_obj_id;

	if (find_object_3d_sub_object(&search) != SUB_OBJECT_SEARCH_RESULT_OBJECT_FOUND)
		if (name)
			debug_fatal ("Failed to locate sub object: %s", name);
		else
			debug_fatal ("Failed to locate sub object: %d (illegal id)", sub_obj_id);

	return search.result_sub_object;
}
Example #22
0
void safe_fread ( void *data, int element_size, int number_of_elements, FILE *fp )
{

	size_t
		size_read;

	size_read = fread ( data, element_size, number_of_elements, fp );

	if ( feof ( fp ) )
	{

		debug_fatal ( "Read past end of file" );
	}

	if ( ferror ( fp ) )
	{

		debug_fatal ( "Error reading file" );
	}
}
Example #23
0
static void deselect_viper_target_acquisition_system (target_acquisition_systems system)
{
	switch (system)
	{
		////////////////////////////////////////
		case TARGET_ACQUISITION_SYSTEM_OFF:
		////////////////////////////////////////
		{
			// laser is on in all modes but OFF in automatic mode
			if (!command_line_manual_laser_radar)
				set_laser_is_active(TRUE);
			
			break;
		}
		////////////////////////////////////////
		case TARGET_ACQUISITION_SYSTEM_FLIR:
		////////////////////////////////////////
		{
			deactivate_common_eo ();

			copy_eo_zoom(&viper_flir, &viper_dtv);

			break;
		}
		////////////////////////////////////////
		case TARGET_ACQUISITION_SYSTEM_DTV:
		////////////////////////////////////////
		{
			deactivate_common_eo ();

			copy_eo_zoom(&viper_dtv, &viper_flir);

			break;
		}
		////////////////////////////////////////
		case TARGET_ACQUISITION_SYSTEM_HIDSS:
		////////////////////////////////////////
		{
			deactivate_common_hms ();

			break;
		}
		////////////////////////////////////////
		default:
		////////////////////////////////////////
		{
			debug_fatal ("Invalid target acquisition system = %d", system);

			break;
		}
	}
}
Example #24
0
void notify_options_page (options_pages page)
{
	switch (page)
	{
		case OPTIONS_PAGE_CONTROLLER:
		{
			notify_show_controller_page ();

			break;
		}
		case OPTIONS_PAGE_DYNAMICS:
		{
			notify_show_dynamics_page ();

			break;
		}
		case OPTIONS_PAGE_GRAPHICS:
		{
			notify_show_graphics_page ();

			break;
		}
		case OPTIONS_PAGE_REALISM:
		{
			notify_show_realism_page ();

			break;
		}
		case OPTIONS_PAGE_SOUND:
		{
			notify_show_sound_page ();

			break;
		}
		case OPTIONS_PAGE_INGAME_SOUND:
		{
			notify_show_ingame_sound_page ();

			break;
		}
		case OPTIONS_PAGE_MULTIPLAYER:
		{
			notify_multi_player_setup ();

			break;
		}
		default:
		{
			debug_fatal ("OPTIONS.C: illegal options page called");
		}
	}
}
Example #25
0
void initialise_vector_dynamics (void)
{

	FILE
		*file_ptr;

	current_flight_dynamics = &vector_flight_dynamics;

	memset (current_flight_dynamics, 0, sizeof (dynamics_type));

	if (!file_exist ("vector.dyn"))
	{

		set_vector_dynamics_defaults ();

		#if !DEBUG_DYNAMICS

		file_ptr = fopen ("vector.dyn", "wb");

		if (file_ptr)
		{

			save_dynamics_model (file_ptr);
		}

		fclose (file_ptr);

		#endif
	}
	else
	{

		file_ptr = fopen ("vector.dyn", "rb");

		if (file_ptr)
		{

			if (file_size ("vector.dyn") != sizeof (dynamics_type))
			{

				debug_fatal ("DYNAMICS: VECTOR: apache.dyn file incorrect size");
			}

			load_dynamics_model (file_ptr);
		}

		fclose (file_ptr);
	}
}
Example #26
0
void set_graphics_rendering_mode ( enum GRAPHICS_RENDERING_MODES mode )
{

	switch ( mode )
	{

		case GRAPHICS_SOFTWARE_RENDER:
		{

			debug_fatal ( "Unable to render using software. Please contact your program vendor." );

			break;
		}

		case GRAPHICS_HARDWARE_RENDER:
		{

			if ( ddraw.use_system_memory )
			{
		
				debug_fatal ( "Unable to do hardware rendering onto a system memory surface" );
			}
		
		
			break;
		}

		default:
		{

			debug_fatal ( "Unknown rendering method for 3D visual system" );

			break;
		}
	}
}
Example #27
0
int safe_fclose (FILE *fp)
{
	int
		error;

	ASSERT (fp);

	error = fclose (fp);

	if (error)
	{
		debug_fatal ("Error closing file (error = %d)", error);
	}

	return (error);
}
Example #28
0
//Xhit: Same type of behaviour as get_free_entity. Here the local entity pointers are set instead. (030428)
entity *get_free_local_entity (int index)
{
	entity
		*en;

	if (index == ENTITY_INDEX_CREATE_LOCAL)
	{
		en = first_free_local_entity;

		if (en)
		{
			//
			// unlink local_entity from start of free list
			//

			first_free_local_entity = en->succ;

			if (en->succ)
			{
				en->succ->pred = NULL;
			}

			//
			// insert local_entity into start of used list (en->pred already set to NULL)
			//

			en->succ = first_used_local_entity;

			if (en->succ)
			{
				en->succ->pred = en;
			}

			first_used_local_entity = en;
		}
		else
		{
			debug_colour_log (DEBUG_COLOUR_RED, "WARNING! Failed to get a free local_entity");
		}
	}
	else
	{
		debug_fatal ("Entity already in use: %s (index = %d)", entity_type_names[index], index);
	}

	return (en);
}
Example #29
0
void damage_kiowa (gunship_damage_levels damage_level)
{
	unsigned int
		damage;

	kiowa_damage_flags
		kiowa_damage;

	damage = 0;

	switch (damage_level)
	{
		case GUNSHIP_DAMAGE_LEVEL_LIGHT:
		{
			damage |= 1 << (rand16 () & 0x1f);

			break;
		}
		case GUNSHIP_DAMAGE_LEVEL_MEDIUM:
		{
			damage |= 1 << (rand16 () & 0x1f);
			damage |= 1 << (rand16 () & 0x1f);

			break;
		}
		case GUNSHIP_DAMAGE_LEVEL_HEAVY:
		{
			damage |= 1 << (rand16 () & 0x1f);
			damage |= 1 << (rand16 () & 0x1f);
			damage |= 1 << (rand16 () & 0x1f);

			break;
		}
		default:
		{
			debug_fatal ("Invalid damage_level = %d", damage_level);

			break;
		}
	}

	kiowa_damage.flags = damage;

	damage_systems (kiowa_damage);
}
Example #30
0
void pack_unsigned_data (unsigned int unpacked_data, int number_of_bits_to_pack)
{
    int
    count;

#if PACKING_STATS

    todd_unsigned_int_pack_stats [number_of_bits_to_pack] ++;

#endif

    //
    // pre-amble
    //

    ASSERT ((number_of_bits_to_pack > 0) && (number_of_bits_to_pack <= 32));

    ASSERT (current_pack_buffer);

    ASSERT (current_pack_buffer->buffer);

    if (current_pack_buffer->overflow)
    {
        return;
    }

    //
    // check data can be packed into given number of bits
    //

#ifdef DEBUG
    {
        unsigned int
        residue;

        if (number_of_bits_to_pack < 32)
        {
            residue = unpacked_data >> number_of_bits_to_pack;

            if (residue != 0)
            {
                debug_fatal ("pack_unsigned_data: exceeded pack width (value = %u, width = %d)", unpacked_data, number_of_bits_to_pack);
            }
        }
    }