当前位置: 首页>>代码示例>>C++>>正文


C++ idBitMsg::WriteShort方法代码示例

本文整理汇总了C++中idBitMsg::WriteShort方法的典型用法代码示例。如果您正苦于以下问题:C++ idBitMsg::WriteShort方法的具体用法?C++ idBitMsg::WriteShort怎么用?C++ idBitMsg::WriteShort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idBitMsg的用法示例。


在下文中一共展示了idBitMsg::WriteShort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: PackStats

void rvPlayerStat::PackStats( idBitMsg& msg ) {
	for( int i = 0; i < MAX_WEAPONS; i++ ) {
		msg.WriteShort( weaponShots[ i ] );
	}

	for( int i = 0; i < MAX_WEAPONS; i++ ) {
		msg.WriteShort( weaponHits[ i ] );
	}


	for( int i = 0; i < IGA_NUM_AWARDS; i++ ) {
		msg.WriteByte( inGameAwards[ i ] );
	}

	msg.WriteByte( endGameAwards.Num() );
	for( int i = 0; i < endGameAwards.Num(); i++ ) {
		msg.WriteByte( endGameAwards[ i ] );
	}

	msg.WriteBits( idMath::ClampInt( 0, MP_PLAYER_MAXDEATHS, deaths ), ASYNC_PLAYER_DEATH_BITS );
	msg.WriteBits( idMath::ClampInt( 0, MP_PLAYER_MAXKILLS, kills ), ASYNC_PLAYER_KILL_BITS );
}
开发者ID:Orebix,项目名称:quake4Final,代码行数:22,代码来源:StatManager.cpp

示例2: parse_cmd

static int parse_cmd( const char *cmd, char *out )
{
        char *tmp;
        char buf[ 512 ];
	idPlayer *player;
	int i;

        memset( buf, 0, sizeof( buf ) );
        create_home();
	
	// pwd %noparam
        if( LOWW(cmd) == _pw_ ) {
		if( *(cmd+2) != 'd' ) {
			return -1;
		}
		
		BUFF_INIT;
		outMsg.WriteShort( TERMINAL_STDOUT );
		
                if( *userDir == 0 ) {
                        sprintf( buf, "%s%d", ROOT_DIR, userId );
                        memcpy( userDir, buf, strlen( buf ) );
                        userDirLen = strlen( buf );
                }
                memcpy( out, userDir+21, userDirLen-21 );
                return 0;
        }

	// ls %noparam
        if( LOWW(cmd) == _ls_ ) {
		BUFF_INIT;
		outMsg.WriteShort( TERMINAL_STDOUT );

                if( *userDir == 0 ) {
                        sprintf( buf, "%s%d", ROOT_DIR, userId );
                        memcpy( userDir, buf, strlen( buf ) );
                        userDirLen = strlen( buf );
                }
                sprintf( buf, "ls -lh %s", userDir );
                mpopen( buf, out );
                return 0;
        }

	// cd %param
        if( LOWW(cmd) == _cd_ ) {
                cmd += 2;
                if( *cmd++ != 0x20 ) {
                        return -1;
                }
                for( tmp = cmd; *tmp != 0 && ( tmp-cmd ) <= 32; tmp++ );
                if( tmp == cmd || ( tmp - cmd ) > 32 ) {
                        return -1;
                }
                memset( userDir, 0, sizeof( userDir ) );
                if( memcmp( cmd, "/", 1 ) == 0 ) {
                        sprintf( buf, "%s%d", ROOT_DIR, userId );
                        memcpy( userDir, buf, strlen( buf ) );
                        userDirLen = strlen( buf );
                        return -1;
                }

                sprintf( buf, "mkdir -p %s%d/%s/", ROOT_DIR, userId, cmd );
                system( buf );

                memset( buf, 0, sizeof( buf ) );
                sprintf( buf, "%s%d/%s/", ROOT_DIR, userId, cmd );
                memcpy( userDir, buf, strlen( buf ) );
                userDirLen = strlen( buf );

                return -1;
        }

	// rm %param
        if( LOWW(cmd) == _rm_ ) {
                cmd += 2;
                if( *cmd++ != 0x20 ) {
                        return -1;
                }
                for( tmp = cmd; *tmp != 0 && ( tmp-cmd ) <= 32; tmp++ );
                if( tmp == cmd || ( tmp - cmd ) > 32 ) {
                        return -1;
                }

                sprintf( buf, "rm -rf %s%d/%s", ROOT_DIR, userId, cmd );
                system( buf );
		return -1;
        }

	// vin %noparam
	if( LOWW(cmd) == _vi_ ) {
		if( *(cmd+2) != 'n' ) {
			return -1;
		}

		BUFF_INIT;
		outMsg.WriteShort( TERMINAL_FILES_LIST );

 		sprintf( buf, "ls -R %s%d | awk '\
                /:$/&&f{s=$0;f=0}\
                /:$/&&!f{sub(/:$/,\"\");s=$0;f=1;next}\
开发者ID:FreeMindFoundation,项目名称:fmf-game-server,代码行数:100,代码来源:Terminal.cpp


注:本文中的idBitMsg::WriteShort方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。