コード例 #1
0
ファイル: UIPlayerItem.cpp プロジェクト: 2asoft/xray
void UIPlayerItem::GetIconParamValue(game_PlayerState const * ps,
									 shared_str const & param_name,
									 buffer_vector<char> & dest)
{
	VERIFY(ps);
	game_cl_mp* cl_game = static_cast<game_cl_mp*>(&Game());
	VERIFY(cl_game);
	if (param_name.equal("rank"))
	{
		if (ETeam(cl_game->ModifyTeam(ps->team)) == etGreenTeam)
		{
			sprintf_s(dest.begin(), dest.size(), "ui_hud_status_green_0%d", ps->rank + 1);
		} else if (ETeam(cl_game->ModifyTeam(ps->team)) == etBlueTeam)
		{
			sprintf_s(dest.begin(), dest.size(), "ui_hud_status_blue_0%d", ps->rank + 1);
		}
	} else if (param_name.equal("death_atf"))
	{
		if (ps->testFlag(GAME_PLAYER_FLAG_VERY_VERY_DEAD))
		{
			strcpy_s(dest.begin(), dest.size(), "death");
			return;
		}
		if (cl_game->Type() == eGameIDCaptureTheArtefact)
		{
			game_cl_CaptureTheArtefact* cta_cl_game = static_cast<game_cl_CaptureTheArtefact*>(cl_game);
			R_ASSERT(cta_cl_game);
			if (ps->GameID == cta_cl_game->GetGreenArtefactOwnerID() ||
				ps->GameID == cta_cl_game->GetBlueArtefactOwnerID())
			{
				strcpy_s(dest.begin(), dest.size(), "artefact");
			}
		} else if (cl_game->Type() == eGameIDArtefactHunt)
		{
			game_cl_ArtefactHunt* ahunt_cl_game = static_cast<game_cl_ArtefactHunt*>(cl_game);
			R_ASSERT(ahunt_cl_game);
			if (ps->GameID == ahunt_cl_game->artefactBearerID)
			{
				strcpy_s(dest.begin(), dest.size(), "artefact");
			}
		}
	} else
	{
		VERIFY2(false, make_string("unknown icon parameter: %s", param_name.c_str()).c_str());
	}

}
コード例 #2
0
ファイル: UIPlayerItem.cpp プロジェクト: 2asoft/xray
void UIPlayerItem::GetTextParamValue(game_PlayerState const * ps, 
									 shared_str const & param_name,
									 buffer_vector<char> & dest)
{
	VERIFY(ps);
	if (param_name.equal("mp_name"))
	{
		strcpy_s(dest.begin(), dest.size(), ps->name);
	} else if (param_name.equal("mp_frags"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iRivalKills - ps->m_iSelfKills);
	} else if (param_name.equal("mp_deaths"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->m_iDeaths);
	} else if (param_name.equal("mp_artefacts"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->af_count);
	} else if (param_name.equal("mp_spots"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", m_checkPoints);
	}else if (param_name.equal("mp_status"))
	{
		CStringTable st;
		if (ps->testFlag(GAME_PLAYER_FLAG_READY))
			strcpy_s(dest.begin(), dest.size(), st.translate("st_mp_ready").c_str());
	} else if (param_name.equal("mp_ping"))
	{
		sprintf_s(dest.begin(), dest.size(), "%d", ps->ping);
	}
}
コード例 #3
0
void StipplePenHandle::Init(buffer_vector<uint8_t, 8> const & pattern)
{
    // encoding scheme
    // 63 - 61 bits = size of pattern in range [0 : 8]
    // 60 - 53 bits = first value of pattern in range [1 : 128]
    // 52 - 45 bits = second value of pattern
    // ....
    // 0 - 5 bits = reserved

    uint32_t patternSize = pattern.size();
    ASSERT(patternSize >= 1 && patternSize < 9, (patternSize));

    m_keyValue = patternSize - 1; // we code value 1 as 000 and value 8 as 111
    for (size_t i = 0; i < patternSize; ++i)
    {
        m_keyValue <<=7;
        ASSERT(pattern[i] > 0, ()); // we have 7 bytes for value. value = 1 encode like 0000000
        ASSERT(pattern[i] < 129, ()); // value = 128 encode like 1111111
        uint32_t value = pattern[i] - 1;
        m_keyValue += value;
    }

    m_keyValue <<= ((8 - patternSize) * 7 + 5);
}