示例#1
0
//===========================================================================
//
// Parameter:           -
// Returns:             -
// Changes Globals:     -
//===========================================================================
void Characteristic_String( int character, int index, char *buf, int size )
{
    bot_character_t *ch;

    ch = BotCharacterFromHandle( character );

    if ( !ch )
    {
        return;
    }

    //check if the index is in range
    if ( !CheckCharacteristicIndex( character, index ) )
    {
        return;
    }

    //an integer will be converted to a float
    if ( ch->c[ index ].type == CT_STRING )
    {
        strncpy( buf, ch->c[ index ].value.string, size - 1 );
        buf[ size - 1 ] = '\0';
        return;
    } //end if
    else
    {
        botimport.Print( PRT_ERROR, "characteristic %d is not a string\n", index );
        return;
    } //end else if

    return;
} //end of the function Characteristic_String
示例#2
0
//===========================================================================
//
// Parameter:           -
// Returns:             -
// Changes Globals:     -
//===========================================================================
int Characteristic_Integer( int character, int index )
{
    bot_character_t *ch;

    ch = BotCharacterFromHandle( character );

    if ( !ch )
    {
        return 0;
    }

    //check if the index is in range
    if ( !CheckCharacteristicIndex( character, index ) )
    {
        return 0;
    }

    //an integer will just be returned
    if ( ch->c[ index ].type == CT_INTEGER )
    {
        return ch->c[ index ].value.integer;
    } //end if
    //floats are casted to integers
    else if ( ch->c[ index ].type == CT_FLOAT )
    {
        return ( int ) ch->c[ index ].value._float;
    } //end else if
    else
    {
        botimport.Print( PRT_ERROR, "characteristic %d is not a integer\n", index );
        return 0;
    } //end else if

//  return 0;
} //end of the function Characteristic_Integer
示例#3
0
//===========================================================================
//
// Parameter:			-
// Returns:				-
// Changes Globals:		-
//===========================================================================
float Characteristic_Float(int character, int index)
{
	bot_character_t *ch;

	ch = BotCharacterFromHandle(character);
	if (!ch) return 0;
	//check if the index is in range
	if (!CheckCharacteristicIndex(character, index)) return 0;
	//an integer will be converted to a float
	if (ch->c[index].type == CT_INTEGER)
	{
		return (float) ch->c[index].value.integer;
	} //end if
	//floats are just returned
	else if (ch->c[index].type == CT_FLOAT)
	{
		return ch->c[index].value._float;
	} //end else if
	//cannot convert a string pointer to a float
	else
	{
		botimport.Print(PRT_ERROR, "characteristic %d is not a float\n", index);
		return 0;
	} //end else if
//	return 0;
} //end of the function Characteristic_Float
示例#4
0
int
Characteristic_Integer(int character, int index)
{
	bot_character_t *ch;

	ch = BotCharacterFromHandle(character);
	if(!ch) return 0;
	/* check if the index is in range */
	if(!CheckCharacteristicIndex(character, index)) return 0;
	/* an integer will just be returned */
	if(ch->c[index].type == CT_INTEGER)
		return ch->c[index].value.integer;
	/* floats are casted to integers */
	else if(ch->c[index].type == CT_FLOAT)
		return (int)ch->c[index].value._float;

	else{
		botimport.Print(PRT_ERROR,
			"characteristic %d is not a integer\n",
			index);
		return 0;
	}
/*	return 0; */
}
示例#5
0
float
Characteristic_Float(int character, int index)
{
	bot_character_t *ch;

	ch = BotCharacterFromHandle(character);
	if(!ch) return 0;
	/* check if the index is in range */
	if(!CheckCharacteristicIndex(character, index)) return 0;
	/* an integer will be converted to a float */
	if(ch->c[index].type == CT_INTEGER)
		return (float)ch->c[index].value.integer;
	/* floats are just returned */
	else if(ch->c[index].type == CT_FLOAT)
		return ch->c[index].value._float;

	/* cannot convert a string pointer to a float */
	else{
		botimport.Print(PRT_ERROR, "characteristic %d is not a float\n",
			index);
		return 0;
	}
/*	return 0; */
}