Exemple #1
0
void VM::VMHandleSyscall(uint32_t id, Util::Reader reader) {
    int major = id >> 16;
    int minor = id & 0xffff;
    if (major == VM::QVM) {
        switch (minor) {
            case CG_STATIC_INIT:
                IPC::HandleMsg<CGameStaticInitMsg>(VM::rootChannel, std::move(reader), [] (int milliseconds) {
                    VM::InitializeProxies(milliseconds);
                    FS::Initialize();
                    srand(time(nullptr));
					cmdBuffer.Init();
                });
                break;

            case CG_INIT:
                IPC::HandleMsg<CGameInitMsg>(VM::rootChannel, std::move(reader), [] (int serverMessageNum, int clientNum, glconfig_t gl, GameStateCSs gamestate) {
                    CG_Init(serverMessageNum, clientNum, gl, gamestate);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_SHUTDOWN:
                IPC::HandleMsg<CGameShutdownMsg>(VM::rootChannel, std::move(reader), [] {
                    CG_Shutdown();
                });
                break;

			case CG_ROCKET_VM_INIT:
				IPC::HandleMsg<CGameRocketInitMsg>(VM::rootChannel, std::move(reader), [] (glconfig_t gl) {
					CG_Rocket_Init(gl);
				});
				break;

			case CG_ROCKET_FRAME:
				IPC::HandleMsg<CGameRocketFrameMsg>(VM::rootChannel, std::move(reader), [] (cgClientState_t cs) {
					CG_Rocket_Frame(cs);
					cmdBuffer.TryFlush();
				});
				break;

            case CG_DRAW_ACTIVE_FRAME:
                IPC::HandleMsg<CGameDrawActiveFrameMsg>(VM::rootChannel, std::move(reader), [] (int serverTime, bool demoPlayback) {
                    CG_DrawActiveFrame(serverTime, demoPlayback);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_CROSSHAIR_PLAYER:
                IPC::HandleMsg<CGameCrosshairPlayerMsg>(VM::rootChannel, std::move(reader), [] (int& player) {
                    player = CG_CrosshairPlayer();
                });
                break;

            case CG_KEY_EVENT:
                IPC::HandleMsg<CGameKeyEventMsg>(VM::rootChannel, std::move(reader), [] (int key, bool down) {
                    CG_KeyEvent(key, down);
                    cmdBuffer.TryFlush();
                });
                break;

            case CG_MOUSE_EVENT:
                IPC::HandleMsg<CGameMouseEventMsg>(VM::rootChannel, std::move(reader), [] (int dx, int dy) {
                    CG_MouseEvent(dx, dy);
					cmdBuffer.TryFlush();
                });
                break;

			case CG_MOUSE_POS_EVENT:
				IPC::HandleMsg<CGameMousePosEventMsg>(VM::rootChannel, std::move(reader), [] (int x, int y) {
					CG_MousePosEvent(x, y);
					cmdBuffer.TryFlush();
				});
				break;

			case CG_TEXT_INPUT_EVENT:
				IPC::HandleMsg<CGameTextInptEvent>(VM::rootChannel, std::move(reader), [] (int c) {
					Rocket_ProcessTextInput(c);
					cmdBuffer.TryFlush();
				});
				break;

			case CG_CONSOLE_LINE:
				IPC::HandleMsg<CGameConsoleLineMsg>(VM::rootChannel, std::move(reader), [](std::string str) {
					Rocket_AddConsoleText( str );
					cmdBuffer.TryFlush();
				});
				break;

            default:
                CG_Error("VMMain(): unknown cgame command %i", minor);

        }
    } else if (major < VM::LAST_COMMON_SYSCALL) {
        VM::HandleCommonSyscall(major, minor, std::move(reader), VM::rootChannel);
    } else {
        CG_Error("unhandled VM major syscall number %i", major);
    }
}
Exemple #2
0
qboolean CL_InternalConsolePrint( const char *text )
{
	int      y;
	int      c, i;
	int      color;
	int      wordLen = 0;

	// for some demos we don't want to ever show anything on the console
	if ( cl_noprint && cl_noprint->integer )
	{
		return qtrue;
	}

	if ( !consoleState.initialized )
	{
		consoleState.textWidthInChars = -1;
		consoleState.initialized = Con_CheckResize();
	}

	//Video hasn't been initialized
	if ( ! cls.glconfig.vidWidth ) {
		return qfalse;
	}

	// NERVE - SMF - work around for text that shows up in console but not in notify
	if ( !Q_strncmp( text, S_SKIPNOTIFY, 12 ) )
	{
		text += 12;
	}
	else if ( !consoleState.isOpened && strncmp( text, "EXCL: ", 6 ) )
	{
		// feed the text to cgame
		Cmd_SaveCmdContext();
		Cmd_TokenizeString( Cmd::Escape(text).c_str() );
		Rocket_AddConsoleText();
		Cmd_RestoreCmdContext();
	}

	color = ColorIndex( CONSOLE_COLOR );

	while ( ( c = *text & 0xFF ) != 0 )
	{
		if ( Q_IsColorString( text ) )
		{
			color = ( text[ 1 ] == COLOR_NULL ) ? ColorIndex( CONSOLE_COLOR ) : ColorIndex( text[ 1 ] );
			text += 2;
			continue;
		}

		if ( !wordLen )
		{
			// count word length
			for ( i = 0; ; ++wordLen )
			{
				if ( text[ i ] <= ' ' && text[ i ] >= 0 )
				{
					break;
				}
				if ( Q_IsColorString( text + i ) )
				{
					i += 2;
					continue;
				}
				if ( text[ i ] == Q_COLOR_ESCAPE && text[ i + 1 ] == Q_COLOR_ESCAPE )
				{
					++i;
				}

				i += Q_UTF8_Width( text + i );
			}

			// word wrap
			if ( consoleState.horizontalCharOffset + wordLen >= consoleState.textWidthInChars
			       && consoleState.horizontalCharOffset > 0 )
			{
				Con_Linefeed();
			}
		}

		switch ( c )
		{
			case '\n':
				Con_Linefeed( );
				break;

			case '\r':
				consoleState.horizontalCharOffset = 0;
				break;

			case Q_COLOR_ESCAPE:
				if ( text[ 1 ] == Q_COLOR_ESCAPE )
				{
					++text;
				}
				/* no break */

			default: // display character and advance
				y = consoleState.currentLine % consoleState.maxScrollbackLengthInLines;
				// rain - sign extension caused the character to carry over
				// into the color info for high ascii chars; casting c to unsigned
				consoleState.text[ y * consoleState.textWidthInChars + consoleState.horizontalCharOffset ].ch = Q_UTF8_CodePoint( text );
				consoleState.text[ y * consoleState.textWidthInChars + consoleState.horizontalCharOffset ].ink = color;
				++consoleState.horizontalCharOffset;
				if ( wordLen > 0 )
				{
					--wordLen;
				}

				if ( consoleState.horizontalCharOffset >= consoleState.textWidthInChars )
				{
					Con_Linefeed();
				}

				break;
		}

		text += Q_UTF8_Width( text );
	}

	return qtrue;
}