Пример #1
0
/* INFO: */
int DeviceListPrintList() {
	StructuresDynamicNode * localNode = { 0 };
	unsigned int localDeviceNumber = { 0 };

	CHECK_INITIALIZED(staticInitializedFlag);

	++localDeviceNumber;

	CHECK(ConsolePrint(DEVICE_LIST_PRINT_LIST_STRING));

	CHECK(DeviceListMutexLock());
	{
		localNode = globalDeviceList;

		while(localNode) {
			CHECK(ConsolePrint(
				DEVICE_LIST_PRINT_LIST_ENTRY_FORMATTER,
				localDeviceNumber, localNode->device->
				friendlyName, localNode->device->
				uniqueDeviceName));
			localNode = localNode->next;

			++localDeviceNumber;
		}
	}
	CHECK(DeviceListMutexUnlock());

	CHECK(ConsolePrint(DEVICE_LIST_NEW_LINE_STRING));

	return NO_ERROR;
}
Пример #2
0
void CHudAmmo::UserCmd_Rebuy()
{
	char *afile = (char*)gEngfuncs.COM_LoadFile("rebuy.txt", 5, NULL);
	char *pfile = afile;
	char token[64];
	char szCmd[1024];
	int lastCh;

	if( !pfile )
	{
		ConsolePrint( "Can't open rebuy.txt file.\n" );
		return;
	}

	// start with \"
	strncpy(szCmd, "cl_setrebuy \"", sizeof(szCmd));



	while((pfile = gEngfuncs.COM_ParseFile( pfile, token )))
	{
		strcat(szCmd, token);
		// append space after token
		strcat(szCmd, " ");
	}
	// replace last space with ", before terminator
	lastCh = strlen(szCmd);
	szCmd[lastCh - 1] = '\"';

	ConsolePrint(szCmd);
	gEngfuncs.pfnServerCmd(szCmd);

	gEngfuncs.COM_FreeFile( afile );
}
Пример #3
0
/* INFO: */
static int CommandsCommonPrintHelpList(const bool inpLongHelpFlag) {
	const char * localCommandString = { 0 };
	const char * localShortHelpString = { 0 };
	const char * localLongHelpString = { 0 };
	unsigned int localIndex = { 0 };

	CHECK(ConsolePrint(COMMANDS_INFO));

	for(; localIndex < globalCommandsCommandArraySize; ++localIndex) {
		localCommandString = globalCommandsCommandArray[localIndex].
			commandString;
		localShortHelpString = globalCommandsCommandArray[localIndex].
			shortHelpString;
		localLongHelpString = globalCommandsCommandArray[localIndex].
			longHelpString;

		CHECK(CommandsCommonPrintHelpEntry(inpLongHelpFlag,
			localCommandString, localShortHelpString,
			localLongHelpString));
	}

	CHECK(ConsolePrint(COMMANDS_NEW_LINE_STRING));

	return NO_ERROR;
}
Пример #4
0
void CHudAmmo::UserCmd_Autobuy()
{
	char *afile = (char*)gEngfuncs.COM_LoadFile("autobuy.txt", 5, NULL);
	char *pfile = afile;
	char token[256];
	char szCmd[1024];

	if( !pfile )
	{
		ConsolePrint( "Can't open autobuy.txt file.\n" );
		return;
	}

	strncpy(szCmd, "cl_setautobuy", sizeof(szCmd));

	while((pfile = gEngfuncs.COM_ParseFile( pfile, token )))
	{
		// append space first
		strcat(szCmd, " ");
		strcat(szCmd, token);
	}

	ConsolePrint(szCmd);
	gEngfuncs.pfnServerCmd(szCmd);

	gEngfuncs.COM_FreeFile( afile );
}
Пример #5
0
void RootConsoleMenu::GotRootCmd(const CCommand &cmd)
{
	unsigned int argnum = cmd.ArgC();

	if (argnum >= 2)
	{
		const char *cmdname = cmd.Arg(1);
		if (strcmp(cmdname, "internal") == 0)
		{
			if (argnum >= 3)
			{
				const char *arg = cmd.Arg(2);
				if (strcmp(arg, "1") == 0)
				{
					SM_ConfigsExecuted_Global();
				}
				else if (strcmp(arg, "2") == 0)
				{
					if (argnum >= 4)
					{
						SM_ConfigsExecuted_Plugin(atoi(cmd.Arg(3)));
					}
				}
			}
			return;
		}

		CCommandArgs ocmd(cmd);

		ConsoleEntry *entry;
		if (m_Commands.retrieve(cmdname, &entry))
		{
			if (entry->version2)
			{
				entry->cmd->OnRootConsoleCommand2(cmdname, &ocmd);
			}
			else
			{
				entry->cmd->OnRootConsoleCommand(cmdname, cmd);
			}
			return;
		}
	}

	ConsolePrint("SourceMod Menu:");
	ConsolePrint("Usage: sm <command> [arguments]");

	List<ConsoleEntry *>::iterator iter;
	ConsoleEntry *pEntry;
	for (iter=m_Menu.begin(); iter!=m_Menu.end(); iter++)
	{
		pEntry = (*iter);
		DrawGenericOption(pEntry->command.c_str(), pEntry->description.c_str());
	}
}
Пример #6
0
// Message handler for text messages
// displays a string, looking them up from the titles.txt file, which can be localised
// parameters:
//   byte:   message direction  ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
//   string: message
// optional parameters:
//   string: message parameter 1
//   string: message parameter 2
//   string: message parameter 3
//   string: message parameter 4
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
{
	BEGIN_READ( pbuf, iSize );

	int msg_dest = READ_BYTE();

#define MSG_BUF_SIZE 128
	static char szBuf[6][MSG_BUF_SIZE];
	char *msg_text = LookupString( READ_STRING(), &msg_dest );
	msg_text = safe_strcpy( szBuf[0], msg_text , MSG_BUF_SIZE);

	// keep reading strings and using C format strings for subsituting the strings into the localised text string
	char *sstr1 = LookupString( READ_STRING() );
	sstr1 = safe_strcpy( szBuf[1], sstr1 , MSG_BUF_SIZE);
	StripEndNewlineFromString( sstr1 );  // these strings are meant for subsitution into the main strings, so cull the automatic end newlines
	char *sstr2 = LookupString( READ_STRING() );
	sstr2 = safe_strcpy( szBuf[2], sstr2 , MSG_BUF_SIZE);
	StripEndNewlineFromString( sstr2 );
	char *sstr3 = LookupString( READ_STRING() );
	sstr3 = safe_strcpy( szBuf[3], sstr3 , MSG_BUF_SIZE);
	StripEndNewlineFromString( sstr3 );
	char *sstr4 = LookupString( READ_STRING() );
	sstr4 = safe_strcpy( szBuf[4], sstr4 , MSG_BUF_SIZE);
	StripEndNewlineFromString( sstr4 );
	char *psz = szBuf[5];

	if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
		return 1;

	switch ( msg_dest )
	{
	case HUD_PRINTCENTER:
		safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
		CenterPrint( ConvertCRtoNL( psz ) );
		break;

	case HUD_PRINTNOTIFY:
		psz[0] = 1;  // mark this message to go into the notify buffer
		safe_sprintf( psz+1, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
		ConsolePrint( ConvertCRtoNL( psz ) );
		break;

	case HUD_PRINTTALK:
		safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
		gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 );
		break;

	case HUD_PRINTCONSOLE:
		safe_sprintf( psz, MSG_BUF_SIZE, msg_text, sstr1, sstr2, sstr3, sstr4 );
		ConsolePrint( ConvertCRtoNL( psz ) );
		break;
	}

	return 1;
}
Пример #7
0
void	Blitters_Init()
{
    ConsolePrint(Msg_Get(MSG_Blitters_Loading));

    Blitters.list = NULL;
    Blitters.current = NULL;

    // Open and read file
    t_tfile * tf;
    if ((tf = tfile_read (Blitters.filename)) == NULL)
        Quit_Msg("%s", meka_strerror());
    ConsolePrint("\n");

    // Parse each line
    int line_cnt = 0;
    for (t_list* lines = tf->data_lines; lines; lines = lines->next)
    {
        const char* line = (char*)lines->elem;
        line_cnt += 1;

		int i, j;
        char s1 [256], s2 [256];
        for (i = 0, j = 0; line [i] != 0 && line [i] != ';'; i ++)
            if ((line [0] == '[') || (line [i] != ' ' && line [i] != '\t'))
                s2 [j ++] = line [i];
        s2 [j] = 0;
        if (StrIsNull (s2))
            continue;

        strcpy(s1, s2);
        StrLower(s1);

        switch (Blitters_Parse_Line (s1, s2))
        {
        case MEKA_ERR_UNKNOWN:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Unrecognized), line_cnt);
        case MEKA_ERR_MISSING:          tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Missing), line_cnt);
        case MEKA_ERR_VALUE_INCORRECT:  tfile_free(tf); Quit_Msg(Msg_Get(MSG_Blitters_Error_Incorrect_Value), line_cnt);
        }
    }

    // Free file data
    tfile_free(tf);

    // Requires at least 1 blitter
    if (Blitters.count == 0)
        Quit_Msg("%s", Msg_Get(MSG_Blitters_Error_Not_Enough));

    // Current blitter
    if (Blitters.blitter_configuration_name != NULL)
        Blitters.current = Blitters_FindBlitterByName(Blitters.blitter_configuration_name);
    if (Blitters.current == NULL)
        Blitters.current = (t_blitter*)Blitters.list->elem; // first
}
Пример #8
0
//-----------------------------------------------------------------------------
// DB_Load (const char *filename)
// Initialize and load given Meka DB file
//-----------------------------------------------------------------------------
void            DB_Load (const char *filename)
{
    t_tfile *   tf;
    t_list *    lines;
    char *      line;
    int         line_cnt;

    ConsolePrint (Msg_Get (MSG_DB_Loading));

    // Open and read file
    tf = tfile_read (filename);
    if (tf == NULL)
    {
        ConsolePrintf ("%s\n", meka_strerror());
        return;
    }

    // Ok
    ConsolePrint ("\n");

    // Parse each line
    line_cnt = 0;
    for (lines = tf->data_lines; lines; lines = lines->next)
    {
        line_cnt += 1;
        line = lines->elem;

        // Strip comments
        // FIXME
        // Trim spaces?
        // FIXME
        // Skip empty lines
        //if (line[0] == EOSTR)
        //    continue;

        if (DB_Load_Line (line) == 0)
        {
            tfile_free (tf); 
            Quit_Msg (Msg_Get (MSG_DB_SyntaxError), line_cnt);
        }
    }

    // Free file data
    tfile_free(tf);

    // FIXME - Uncomment for counting progress of DB transition
    //ConsolePrintf ("ENTRIES NEW = %d, OLD = %d\n", DB.entries_counter_format_new, DB.entries_counter_format_old);
    //Quit();
}
Пример #9
0
/* INFO: */
static int CommandsCommonPrintHelpEntry(const bool inpLongHelpFlag,
		const char * const inpCommandString,
		const char * const inpShortHelpString,
		const char * const inpLongHelpString) {
	if(inpLongHelpFlag) {
		CHECK(ConsolePrint(COMMANDS_LONG_HELP_FORMATTER,
			inpCommandString, inpShortHelpString,
			inpLongHelpString));
	} else {
		CHECK(ConsolePrint(COMMANDS_SHORT_HELP_FORMATTER,
			inpCommandString, inpShortHelpString));
	}

	return NO_ERROR;
}
Пример #10
0
/* INFO: */
static int DisplayPrintServiceHeader(
		const StructuresDynamicService * const inpService,
		const unsigned int inpServiceNumber,
		const char inpServiceTreeVertical) {
	CHECK(ConsolePrint(
		DISPLAY_PRINT_SERVICE_HEADER_FORMAT_STRING,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_HORIZONTAL_FULL,
		DISPLAY_SERVICE_GROUP_STRING,
		inpServiceNumber,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL));
	CHECK(DisplayPrintServiceEntry(DISPLAY_SUBSCRIPTION_ID_STRING,
		inpService->subscriptionId, inpServiceTreeVertical));
	CHECK(DisplayPrintServiceEntry(DISPLAY_SERVICE_TYPE_STRING,
		inpService->serviceType, inpServiceTreeVertical));
	CHECK(DisplayPrintServiceEntry(DISPLAY_SERVICE_ID_STRING,
		inpService->serviceId, inpServiceTreeVertical));
	CHECK(DisplayPrintServiceEntry(DISPLAY_SCPDURL_STRING,
		inpService->SCPDURL, inpServiceTreeVertical));
	CHECK(DisplayPrintServiceEntry(DISPLAY_CONTROL_URL_STRING,
		inpService->controlURL, inpServiceTreeVertical));
	CHECK(DisplayPrintServiceEntry(DISPLAY_EVENT_SUB_URL_STRING,
		inpService->eventSubURL, inpServiceTreeVertical));

	return NO_ERROR;
}
Пример #11
0
// Initialize Sound Engine ----------------------------------------------------
// FIXME: This is mostly legacy stuff :(
static  int     Sound_Init_Engine (int buffer_mode)
{
    // Stream Buffer Mode
    //STREAM_BUFFER_MAXA = DEF_STREAM_BUFFER_MAXA;
    MODEB_FRAME_SIZE   = DEF_MODEB_FRAME_SIZE;
    MODEB_UPDATE_COUNT = DEF_MODEB_UPDATE_COUNT;
    MODEB_ERROR_MAX    = DEF_STREAM_UPDATE_ERROR_MAX;
    STREAM_BUFFER_MAXB = MODEB_FRAME_SIZE;
    MODEB_MASK         = MODEB_FRAME_SIZE / MODEB_UPDATE_COUNT;

    sound_stream_mode  = buffer_mode; /* SOUND_STREAM_WAIT in MEKA */
    //stream_buffer_max  = (sound_stream_mode == SOUND_STREAM_NORMAL) ? STREAM_BUFFER_MAXA : STREAM_BUFFER_MAXB;
#ifdef INSTALL_SOUND_TIMER
    buffered_stream_max = stream_buffer_max = 3; // audio_buffer_max_size
    MODEB_UPDATE_COUNT = 1;
#else
    stream_buffer_max = ((stream_buffer_max / 6) / MODEB_UPDATE_COUNT) * MODEB_UPDATE_COUNT;
    // buffered_stream_max = stream_buffer_max;   // audio_buffer_max_size
    buffered_stream_max = MODEB_UPDATE_COUNT * 2; // audio_buffer_max_size
#endif

    /**** timer work init ****/
    sound_freerun_count = 0;
    sound_slice = 0;

    if (change_sample_rate)
    { // Sample rate has changed, so all emulators must be restarted!
        change_sample_rate = FALSE;
        saStopSoundEmulators();
    }
    ConsolePrint (" - SEAL: Ok\n"); // FIXME: should be a message ?

#ifdef INSTALL_SOUND_TIMER
    saInitSoundTimer();
#endif

    if (SndMachine != NULL)
    {
        if (!SndMachine->first)
        {
            int i;
            SndMachine->first = 1;           /* first flag clear */
            streams_sh_start();              /* streaming system initialize & start */
            pause_sound = 0;                 /* pause flag off */
            vbover_err = vbunder_err = 0;    /* error initial */
            for (i = 0; i < SndMachine->control_max; i++)
            {
                if (SndMachine->f_init[i])
                {
                    if (SndMachine->f_init[i] (SndMachine->userdata[i]) != MEKA_ERR_OK)
                    {
                        SndMachine = NULL;
                        return (MEKA_ERR_FAIL);
                    }
                }
            }
        }
    }
    return (MEKA_ERR_OK);
}
Пример #12
0
/* INFO: */
static int DisplayPrintAllowedValueHeader(
		const StructuresDynamicAllowedValue * const inpAllowedValue,
		const unsigned int inpAllowedValueNumber,
		const char inpServiceTreeVertical,
		const char inpAllowedValueTreeVertical) {
	CHECK(ConsolePrint(
		DISPLAY_PRINT_ALLOWED_VALUE_HEADER_FORMAT_STRING,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_HORIZONTAL_FULL,
		DISPLAY_ALLOWED_VALUE_GROUP_STRING,
		inpAllowedValueNumber,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpAllowedValueTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL));
	CHECK(DisplayPrintAllowedValueEntry(DISPLAY_ALLOWED_VALUE_STRING,
		inpAllowedValue->allowedValue, inpServiceTreeVertical,
		inpAllowedValueTreeVertical));

	return NO_ERROR;
}
Пример #13
0
/**
  Prints a chracter to the default console,
  using L"%c" format.

  @param  Character  Character to print.

  @return Length of string printed to the console.

**/
UINTN
PrintChar (
  CHAR16       Character
  )
{
  return ConsolePrint (L"%c", Character);
}
Пример #14
0
/**
  Prints a unicode string to the default console,
  using L"%s" format.

  @param  String     String pointer.

  @return Length of string printed to the console

**/
UINTN
PrintString (
  IN CHAR16       *String
  )
{
  return ConsolePrint (L"%s", String);
}
Пример #15
0
/* INFO: */
static int CliAutocompletionApplySuggestion(char * const inpCommandBuffer,
		const unsigned int inpCommandBufferSize,
		unsigned int * const inpCommandSize,
		unsigned int * const inpCommandBufferOffset,
		const char * const inpSuggestion,
		const unsigned int inpSuggestionSize) {
	char * localCompletionBuffer = { 0 };
	unsigned int localCompletionBufferSize = { 0 };
	const char * localSuggestionTail = { 0 };
	unsigned int localSuggestionTailSize = { 0 };
	unsigned int localSuggestionOffset = { 0 };

	localCompletionBuffer = inpCommandBuffer + (* inpCommandSize);

	if((* inpCommandSize) >= inpCommandBufferSize) {
		return ERROR;
	}

	localCompletionBufferSize = inpCommandBufferSize - (* inpCommandSize);

	if(! localCompletionBufferSize) {
		return ERROR;
	}

	if((* inpCommandBufferOffset) > (* inpCommandSize)) {
		return ERROR;
	}

	localSuggestionOffset = (* inpCommandSize) -
		(* inpCommandBufferOffset);
	localSuggestionTail = inpSuggestion + localSuggestionOffset;

	localSuggestionTailSize = inpSuggestionSize - localSuggestionOffset;

	if(! localSuggestionTailSize) {
		(* inpCommandBufferOffset) = (* inpCommandSize);

		return NO_ERROR;
	}

	if(localSuggestionTailSize >= localCompletionBufferSize) {
		(* inpCommandBufferOffset) = (* inpCommandSize);

		return NO_ERROR;
	}

	memcpy(localCompletionBuffer, localSuggestionTail,
		localSuggestionTailSize);

	localCompletionBuffer[localSuggestionTailSize] = 0;

	(* inpCommandSize) += localSuggestionTailSize;
	
	CHECK(ConsolePrint(UTILS_SIMPLE_PRINT_FORMATTER,
		localCompletionBuffer));

	(* inpCommandBufferOffset) = (* inpCommandSize);

	return NO_ERROR;
}
Пример #16
0
/* INFO: */
static int CliAutocompletionPrintPrimaryCommand(
		char * const inpCommandBuffer) {
	CHECK(ConsolePrint(UTILS_SIMPLE_PRINT_FORMATTER,
		inpCommandBuffer));

	return NO_ERROR;
}
Пример #17
0
/* INFO: */
static int DisplayPrintActionHeader(
		const StructuresDynamicAction * const inpAction,
		const unsigned int inpActionNumber,
		const char inpServiceTreeVertical) {
	CHECK(ConsolePrint(
		DISPLAY_PRINT_ACTION_HEADER_FORMAT_STRING,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_HORIZONTAL_FULL,
		DISPLAY_ACTION_GROUP_STRING,
		inpActionNumber,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		inpServiceTreeVertical,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL,
		DISPLAY_TREE_HORIZONTAL_EMPTY,
		DISPLAY_TREE_VERTICAL_FULL));
	CHECK(DisplayPrintActionEntry(DISPLAY_NAME_STRING, inpAction->name,
		inpServiceTreeVertical));

	return NO_ERROR;
}
Пример #18
0
void Log::LogPrint(LogType type, const char* msg)
{
  if (config.logConsole)
    ConsolePrint(type, msg);
  if (config.logSyslog)
    SyslogPrint(type, msg);
  if (config.logFile)
    FilePrint(type, msg);
}
Пример #19
0
// ------------------------------------------------------------------------------------------------
void EthSendIntf(NetIntf *intf, const void *dstAddr, u16 etherType, NetBuf *pkt)
{
    // Determine ethernet address by protocol of packet
    const EthAddr *dstEthAddr = 0;

    switch (etherType)
    {
    case ET_ARP:
        dstEthAddr = (const EthAddr *)dstAddr;
        break;

    case ET_IPV4:
        {
            const Ipv4Addr *dstIpv4Addr = (const Ipv4Addr *)dstAddr;

            if (Ipv4AddrEq(dstIpv4Addr, &g_broadcastIpv4Addr) ||
                Ipv4AddrEq(dstIpv4Addr, &intf->broadcastAddr))
            {
                // IP Broadcast -> Ethernet Broacast
                dstEthAddr = &g_broadcastEthAddr;
            }
            else
            {
                // Lookup Ethernet address in ARP cache
                dstEthAddr = ArpLookupEthAddr(dstIpv4Addr);
                if (!dstEthAddr)
                {
                    ArpRequest(intf, dstIpv4Addr, etherType, pkt);
                    return;
                }
            }
        }
        break;

    case ET_IPV6:
        break;
    }

    // Skip packets without a destination
    if (!dstEthAddr)
    {
        ConsolePrint("Dropped packet\n");
        return;
    }

    // Fill in ethernet header
    pkt->start -= sizeof(EthHeader);

    EthHeader *hdr = (EthHeader *)pkt->start;
    hdr->dst = *dstEthAddr;
    hdr->src = intf->ethAddr;
    hdr->etherType = NetSwap16(etherType);

    // Transmit
    EthPrint(pkt);
    intf->devSend(pkt);
}
Пример #20
0
// Message handler for text messages
// displays a string, looking them up from the titles.txt file, which can be localised
// parameters:
//   byte:   message direction  ( HUD_PRINTCONSOLE, HUD_PRINTNOTIFY, HUD_PRINTCENTER, HUD_PRINTTALK )
//   string: message
// optional parameters:
//   string: message parameter 1
//   string: message parameter 2
//   string: message parameter 3
//   string: message parameter 4
// any string that starts with the character '#' is a message name, and is used to look up the real message in titles.txt
// the next (optional) one to four strings are parameters for that string (which can also be message names if they begin with '#')
int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf )
{
	int destination;
	StringList message;
	NetMsg_TextMsg( pbuf, iSize, destination, message );
 
	if ( gViewPort && gViewPort->AllowedToPrintText() == FALSE )
		return 1;

	while( message.size() < 5 )
	{ message.push_back( string("") ); }
	char psz[1024];

	char* origin = psz;
	if( destination == HUD_PRINTNOTIFY )
	{ 
		psz[0] = 1;
		origin = psz + 1;
	}

	// Ensure that message[0] does not contain exessive %'s, max 4x%s, all other %'s removed.
	size_t lastpos = 0; size_t pos; int count = 0;
	while(true)
	{
		pos = message[0].find("%", lastpos);

		if (pos == string::npos)
			break;

		if ((message[0].substr(pos + 1, 1) == "s") && (count < 4))
			count++;
		else
			message[0].replace(pos, 1, " ");

		lastpos = pos + 1;
	}

	sprintf( origin, message[0].c_str(), message[1].c_str(), message[2].c_str(), message[3].c_str(), message[4].c_str() );
	ConvertCRtoNL(psz);

	switch ( destination )
	{
	case HUD_PRINTNOTIFY:
	case HUD_PRINTCONSOLE:
		ConsolePrint(psz);
		break;
	case HUD_PRINTCENTER:
		CenterPrint(psz);
		break;
	case HUD_PRINTTALK:
		gHUD.m_SayText.SayTextPrint(psz, 1024);
		break;
	}

	return 1;
}
void OutputTable::FilePrint(string file)
{
	std::ofstream out(file);	//	Opens the file
	std::streambuf *coutbuf = std::cout.rdbuf(); //	Saves the old buf
	std::cout.rdbuf(out.rdbuf());	//	Redirects std::cout to file

	ConsolePrint();

	std::cout.rdbuf(coutbuf);	//	Resets to standard output again
}
Пример #22
0
//-----------------------------------------------------------------------------
// ConsolePrintf (const char *format, ...)
// Print formatted message to console.
//-----------------------------------------------------------------------------
void            ConsolePrintf (const char *format, ...)
{
    va_list       params;

    va_start (params, format);
    vsprintf (Msg_Buf, format, params);
    va_end   (params);

    ConsolePrint(Msg_Buf);
}
Пример #23
0
 bool Tester::RunAllTests()
 {
   ConsolePrint("Running all tests.\n");
   bool retVal = true;
   for (unsigned i = 0; i < tests_.size(); ++i)
   {
     retVal = (RunTest(i) && retVal);
   }
   return retVal;
 }
Пример #24
0
// Initialize Sound Card ------------------------------------------------------
static  int     Sound_Init_SoundCard (void)
{
  int            i;
  AUDIOINFO      Audio_Infos;

  ConsolePrintf (Msg_Get (MSG_Sound_Init_Soundcard), Sound.SampleRate);
  ConsolePrint ("\n");

  Audio_Infos.nDeviceId = Sound.SoundCard;
  Audio_Infos.wFormat = AUDIO_FORMAT_16BITS | AUDIO_FORMAT_STEREO; // FIXME: Stereo ?
  Audio_Infos.nSampleRate = audio_sample_rate = Sound.SampleRate;

  if (AOpenAudio(&Audio_Infos) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Audio));
     return (MEKA_ERR_FAIL);
     }
  // FIXME: original sound engine was trying different sample rate on failure

  // Unused
  // Maybe it was intended to check out number of channels there ?
  // AGetAudioCaps (Audio_Infos.nDeviceId, &Audio_Caps);

  // Open voices
  if (AOpenVoices(Sound.Voices_Max) != AUDIO_ERROR_NONE)
     {
     Quit_Msg ("%s", Msg_Get (MSG_Sound_Init_Error_Voices));
     return (MEKA_ERR_FAIL);
     }

  ASetAudioMixerValue (AUDIO_MIXER_MASTER_VOLUME, 256);

  // Allocate voices and waveforms
  Sound.Voices = Memory_Alloc (sizeof (t_voice) * Sound.Voices_Max);
  for (i = 0; i < Sound.Voices_Max; i++)
     {
     if (ACreateAudioVoice(&Sound.Voices[i].hVoice) != AUDIO_ERROR_NONE)
        {
        Quit_Msg (Msg_Get (MSG_Sound_Init_Error_Voice_N), i);
        return (MEKA_ERR_FAIL);
        }
     ASetVoicePanning(Sound.Voices[i].hVoice, 128); // Center voice
     Sound.Voices[i].lpWave  = NULL;
     Sound.Voices[i].playing = FALSE;
     }

  // FIXME: is this needed ?
  AUpdateAudio ();

  // FIXME: is this needed ?
  // Check frame sample rate
  audio_sample_rate = nominal_sample_rate = Audio_Infos.nSampleRate;

  return (MEKA_ERR_OK);
}
Пример #25
0
void Appli_DsadcCyclic(void)
{
	char str_adc[10];
	int chn;
#ifdef iLLD
	// start conversions
	IfxDsadc_Dsadc_startScan(&dsadc, 0x3f, 0x3f);
	// results are now available in IFXDSADC(ds).CH[x].RESM.B.RESULT (x=0..5

	// declared globally    // sint16 result[];
	for(chn=0; chn<IFXDSADC_NUM_CHANNELS; ++chn)
	{
		if( dsadcChannelAvailable[chn] )
		{
			result[chn] = IfxDsadc_Dsadc_getMainResult(&dsadcChannel[chn]);
#if 0
			ConsolePrint("\tCH");
			ShortToAscii(chn, str_adc);
			ConsolePrint(str_adc);
			ConsolePrint(" :");
			ShortToAscii(result, str_adc);  //str_adc[10] = '\0';
			ConsolePrint(str_adc);
#endif
		}
	}
#else
	DSADC_GLOBRC.U = 0x010001;
	delay();
	//note that DSADC result is 2's complement
	if ((DSADC_RESM0.B.RESULT & 0x8000) == 0x8000)
	{
		result[0] = (float) (~DSADC_RESM0.U + 1) * 11.375290337;
		//display_ascii_printf(DISPLAYSTDOUT0, "DSADC0 = -%.4fV\n", result);
	}
	else
	{
		result[0] = (float) DSADC_RESM0.U * 11.375290337;
		//display_ascii_printf(DISPLAYSTDOUT0, "DSADC0 = %.4fV\n", result);
	}

#endif
}
Пример #26
0
void CHudMenu::UserCmd_ShowVGUIMenu()
{
	if( gEngfuncs.Cmd_Argc() < 2 )
	{
		ConsolePrint("usage: showvguimenu <menuType>\n");
		return;
	}

	int menuType = atoi(gEngfuncs.Cmd_Argv(1));
	ShowVGUIMenu(menuType);
}
Пример #27
0
  Model* Graphics::LoadModel(const std::string& modelName)
  {
    Model* newModel = nullptr;
    int dotIndex = modelName.find_last_of('.');
    std::string extension = modelName.substr(dotIndex, (modelName.size()) - dotIndex);
    auto& modelLoader = loaders_.find(extension);

    std::string friendlyName = modelName.substr(0, dotIndex);
    

    if (modelLoader != loaders_.end())
    {
      newModel = ((*modelLoader).val)->Load("Content/Models/" + modelName);
      if (newModel)
      {
        auto it = models_.find(friendlyName);
        if(it == models_.end())
        {
          models_.insert(friendlyName, newModel);
        }
        else
        {
          auto sit = models_.find(friendlyName + extension);
          if(sit == models_.end())
          {
            models_.insert(friendlyName + extension, newModel);
          }
          else
          {
            ConsolePrint("Two model files of same name and same type, cannot load model" + friendlyName + extension + "\n");
          }
        }
      }
    }
    else
    {
      ConsolePrint("Can't load file extension " + extension + " as model.\n");
    }
    newModel->Initialize();
    return newModel;
  }
Пример #28
0
void TreeStem::Build(TreeSegment* parentSeg, float offset, TreeGeneralParams generalParams, TreeLevelParams levelParams, 
					 LevelContext& context)
{
	static int dbNumStems[4];
	dbNumStems[levelParams.level]++;
	ConsolePrint(L"current numStems: (0-%d),(1-%d),(2-%d),(3-%d)\n", dbNumStems[0], dbNumStems[1], dbNumStems[2], dbNumStems[3]);

	SAFE_DELETE(mFirstSeg);
	mParentSeg = parentSeg;
	mLevelParams = levelParams;

	float parentLength = 0;
	float stemOffset = 0;

	if(parentSeg)
	{
		mPos = Vector3(0, offset, 0);		// offset: 当stem是parentSeg的一个枝条时, stem在parentSeg上长出的位置

		parentLength = mParentSeg->mStem->GetLength();
		stemOffset = mParentSeg->mSegIndex * mParentSeg->mStem->GetSegLength() + offset;
	}
	else
	{
		_Assert(mLevelParams.level == 0);	// 只有trunk不存在parentSeg
		mPos = Vector3::Zero;
	}

	mLength = calcStemLength(generalParams, parentLength, stemOffset);
	mBaseRadius = calcStemBaseRadius(generalParams, parentLength, stemOffset);

	float baseLength = 0;
	if(mLevelParams.level == 0)
	{
		baseLength = generalParams.baseSize * mLength;
	}
	calcStemBranchInterval(parentLength, stemOffset, baseLength, &mNumBranches, &mBranchInterval);

	float parentBaseLength = 0;
	if(mLevelParams.level == 1)
	{
		parentBaseLength = generalParams.baseSize * parentLength;
	}

	float downAngle = 0;
	float rotateAngle = 0;
	calcBranchAngle(parentLength, stemOffset, parentBaseLength, context.rotateAngle, &downAngle, &rotateAngle);

	context.rotateAngle = rotateAngle;

	mOrient = Quaternion(0, DEGREE_TO_RAD(rotateAngle), DEGREE_TO_RAD(downAngle));

	buildSegment(generalParams, NULL, 0, 0, 0, 0, LevelContext());
}
Пример #29
0
extern void ConsolePrintStrStack(void)
{
	const char *str;
	int i = 0;
	
	while ((str = ConsolePopStrStack()) != NULL)
	{
		ConsoleSetColor(WHITE, BLACK);
		ConsoleSetCursor(i++, 0);
		ConsolePrint(str);
	}
}
Пример #30
0
/*-----------------------------------------------------------------------------
  Console: Extern Functions
  ---------------------------------------------------------------------------*/
extern void ConsoleFillRect( int top, int left, int bottom, int right, int fgColor, int bgColor, const char* str)
{
	ConsoleSetColor( fgColor, bgColor );
	for (int i=top; i<bottom; ++i)
	{
		ConsoleSetCursor( i, 0 );
		for (int j=left; j<right; ++j)
		{
			ConsolePrint(str);
		}
	}
}