示例#1
0
static String HHVM_METHOD(NumberFormatter, getSymbol, int64_t attr) {
  NUMFMT_GET(obj, this_, String());
  UErrorCode error = U_ZERO_ERROR;
  int32_t len = unum_getSymbol(obj->formatter(),
                               (UNumberFormatSymbol)attr,
                               nullptr, 0, &error);
  if (error != U_BUFFER_OVERFLOW_ERROR) {
    obj->setError(error);
    return String();
  }
  icu::UnicodeString out;
  error = U_ZERO_ERROR;
  len = unum_getSymbol(obj->formatter(), (UNumberFormatSymbol)attr,
                       out.getBuffer(len + 1), len + 1, &error);
  NUMFMT_CHECK(obj, error, String());
  out.releaseBuffer(len);
  String ret(u8(out, error));
  NUMFMT_CHECK(obj, error, String());
  return ret;
}
示例#2
0
void MainWindow::msgTextMessage(const MumbleProto::TextMessage &msg) {
	ACTOR_INIT;
	QString target;

	// Silently drop the message if this user is set to "ignore"
	if (pSrc && pSrc->bLocalIgnore)
		return;

	const QString &plainName = pSrc ? pSrc->qsName : tr("Server", "message from");
	const QString &name = pSrc ? Log::formatClientUser(pSrc, Log::Source) : tr("Server", "message from");

	if (msg.tree_id_size() > 0) {
		target += tr("(Tree) ");
	} else if (msg.channel_id_size() > 0) {
		target += tr("(Channel) ");
	}

	g.l->log(Log::TextMessage, tr("%2%1: %3").arg(name).arg(target).arg(u8(msg.message())),
	         tr("Message from %1").arg(plainName));
}
示例#3
0
static Variant doFormat(NumberFormatter *obj, int64_t val) {
  UErrorCode error = U_ZERO_ERROR;
  uint32_t len = unum_formatInt64(obj->formatter(), val,
                                  nullptr, 0, nullptr, &error);
  if (error != U_BUFFER_OVERFLOW_ERROR) {
    obj->setError(error);
    return false;
  }
  error = U_ZERO_ERROR;
  icu::UnicodeString out;
  len = unum_formatInt64(obj->formatter(), val,
                         out.getBuffer(len + 1), len + 1,
                         nullptr, &error);
  NUMFMT_CHECK(obj, error, false);
  out.releaseBuffer(len);
  error = U_ZERO_ERROR;
  String ret(u8(out, error));
  NUMFMT_CHECK(obj, error, false);
  return ret;
}
示例#4
0
static String HHVM_METHOD(IntlDateFormatter, getPattern) {
  DATFMT_GET(data, this_, null_string);
  UErrorCode error = U_ZERO_ERROR;
  int32_t len = udat_toPattern(data->datefmt(), false, nullptr, 0, &error);
  String buf((len+1) * sizeof(UChar), ReserveString);
  error = U_ZERO_ERROR;
  udat_toPattern(data->datefmt(), false, (UChar*)buf->mutableData(),
                 buf->capacity() / sizeof(UChar), &error);
  if (U_FAILURE(error)) {
    data->setError(error, "Error getting formatter pattern");
    return null_string;
  }
  buf->setSize(len * sizeof(UChar));
  String ret(u8(buf, error));
  if (U_FAILURE(error)) {
    data->setError(error);
    return null_string;
  }
  return ret;
}
示例#5
0
static Variant HHVM_METHOD(IntlTimeZone, getDisplayName,
                           bool isDaylight, int64_t style,
                           const String& locale) {
  if (!IntlTimeZone::isValidStyle(style)) {
    s_intl_error->setError(U_ILLEGAL_ARGUMENT_ERROR,
                           "intltz_get_display_name: wrong display type");
    return false;
  }
  TZ_GET(data, this_, false);
  icu::UnicodeString result;
  data->timezone()->getDisplayName((UBool)isDaylight,
                                   (icu::TimeZone::EDisplayType)style,
                                    icu::Locale::createFromName(
                                     localeOrDefault(locale).c_str()),
                                   result);
  UErrorCode error = U_ZERO_ERROR;
  String ret(u8(result, error));
  TZ_CHECK(data, error, false);
  return ret;
}
示例#6
0
bool Wiimote::PrepareOnThread()
{
	// core buttons, no continuous reporting
	u8 static const mode_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_REPORT_MODE, 0, WM_REPORT_CORE};

	// Set the active LEDs and turn on rumble.
	u8 static const led_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_LEDS, u8(WIIMOTE_LED_1 << (m_index%WIIMOTE_BALANCE_BOARD) | 0x1)};

	// Turn off rumble
	u8 static const rumble_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_RUMBLE, 0};

	// Request status report
	u8 static const req_status_report[] = {WM_SET_REPORT | WM_BT_OUTPUT, WM_REQUEST_STATUS, 0};
	// TODO: check for sane response?

	return (IOWrite(mode_report, sizeof(mode_report)) &&
	        IOWrite(led_report, sizeof(led_report)) &&
	        (SLEEP(200), IOWrite(rumble_report, sizeof(rumble_report))) &&
	        IOWrite(req_status_report, sizeof(req_status_report)));
}
示例#7
0
static String HHVM_METHOD(IntlDateFormatter, getPattern) {
  DATFMT_GET(data, this_, null_string);
  UErrorCode error = U_ZERO_ERROR;
  int32_t len = udat_toPattern(data->datefmt(), false, nullptr, 0, &error);
  icu::UnicodeString tmp;
  auto buf = tmp.getBuffer(len + 1);
  error = U_ZERO_ERROR;
  udat_toPattern(data->datefmt(), false, buf, len + 1, &error);
  if (U_FAILURE(error)) {
    data->setError(error, "Error getting formatter pattern");
    return null_string;
  }
  tmp.releaseBuffer(len);
  String ret(u8(tmp, error));
  if (U_FAILURE(error)) {
    data->setError(error);
    return null_string;
  }
  return ret;
}
示例#8
0
static Variant HHVM_METHOD(NumberFormatter, parseCurrency,
                           const String& value, VRefParam currency,
                           VRefParam position) {
  NUMFMT_GET(obj, this_, false);
  UErrorCode error = U_ZERO_ERROR;
  icu::UnicodeString val(u16(value, error));
  NUMFMT_CHECK(obj, error, false);
  int32_t pos = position.toInt64();
  UChar cur[5] = {0};
  error = U_ZERO_ERROR;
  double parsed = unum_parseDoubleCurrency(obj->formatter(),
                        val.getBuffer(), val.length(),
                        &pos, cur, &error);
  NUMFMT_CHECK(obj, error, false);
  position = (int64_t)pos;
  error = U_ZERO_ERROR;
  currency = u8(cur, u_strlen(cur), error);
  NUMFMT_CHECK(obj, error, false);
  return parsed;
}
示例#9
0
void sk1100_link_cable_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch (id)
	{
	case TIMER_POLL:
		queue();
		break;

	case TIMER_SEND:
		m_stream->output(u8(param));
		break;

	case TIMER_READ:
		m_update_received_data = true;
		break;

	default:
		break;
	}
}
void CSE_ALifeInventoryItem::UPDATE_Write	(NET_Packet &tNetPacket)
{
	if (!m_u8NumItems) {
		tNetPacket.w_u8				(0);
		return;
	}

	mask_num_items					num_items;
	num_items.mask					= 0;
	num_items.num_items				= m_u8NumItems;

	R_ASSERT2						(
		num_items.num_items < (u8(1) << 5),
		make_string("%d",num_items.num_items)
	);

	if (State.enabled)									num_items.mask |= inventory_item_state_enabled;
	if (fis_zero(State.angular_vel.square_magnitude()))	num_items.mask |= inventory_item_angular_null;
	if (fis_zero(State.linear_vel.square_magnitude()))	num_items.mask |= inventory_item_linear_null;

	tNetPacket.w_u8					(num_items.common);

	tNetPacket.w_vec3				(State.position);

	tNetPacket.w_float_q8			(State.quaternion.x,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.y,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.z,0.f,1.f);
	tNetPacket.w_float_q8			(State.quaternion.w,0.f,1.f);	

	if (!check(num_items.mask,inventory_item_angular_null)) {
		tNetPacket.w_float_q8		(State.angular_vel.x,0.f,10*PI_MUL_2);
		tNetPacket.w_float_q8		(State.angular_vel.y,0.f,10*PI_MUL_2);
		tNetPacket.w_float_q8		(State.angular_vel.z,0.f,10*PI_MUL_2);
	}

	if (!check(num_items.mask,inventory_item_linear_null)) {
		tNetPacket.w_float_q8		(State.linear_vel.x,-32.f,32.f);
		tNetPacket.w_float_q8		(State.linear_vel.y,-32.f,32.f);
		tNetPacket.w_float_q8		(State.linear_vel.z,-32.f,32.f);
	}
};
void CSE_ALifeInventoryItem::UPDATE_Read	(NET_Packet &tNetPacket)
{
	tNetPacket.r_u8					(m_u8NumItems);
	if (!m_u8NumItems) {
		return;
	}

	mask_num_items					num_items;
	num_items.common				= m_u8NumItems;
	m_u8NumItems					= num_items.num_items;

	R_ASSERT2						(
		m_u8NumItems < (u8(1) << 5),
		make_string("%d",m_u8NumItems)
	);

	tNetPacket.r_vec3				(State.position);

	tNetPacket.r_float_q8			(State.quaternion.x,0.f,1.f);
	tNetPacket.r_float_q8			(State.quaternion.y,0.f,1.f);
	tNetPacket.r_float_q8			(State.quaternion.z,0.f,1.f);
	tNetPacket.r_float_q8			(State.quaternion.w,0.f,1.f);	

	State.enabled					= check(num_items.mask,inventory_item_state_enabled);

	if (!check(num_items.mask,inventory_item_angular_null)) {
		tNetPacket.r_float_q8		(State.angular_vel.x,0.f,10*PI_MUL_2);
		tNetPacket.r_float_q8		(State.angular_vel.y,0.f,10*PI_MUL_2);
		tNetPacket.r_float_q8		(State.angular_vel.z,0.f,10*PI_MUL_2);
	}
	else
		State.angular_vel.set		(0.f,0.f,0.f);

	if (!check(num_items.mask,inventory_item_linear_null)) {
		tNetPacket.r_float_q8		(State.linear_vel.x,-32.f,32.f);
		tNetPacket.r_float_q8		(State.linear_vel.y,-32.f,32.f);
		tNetPacket.r_float_q8		(State.linear_vel.z,-32.f,32.f);
	}
	else
		State.linear_vel.set		(0.f,0.f,0.f);
};
示例#12
0
static Variant HHVM_STATIC_METHOD(IntlTimeZone, getEquivalentID,
                                  const String& zoneId, int64_t index) {
  UErrorCode error = U_ZERO_ERROR;
  icu::UnicodeString id;
  if (!ustring_from_char(id, zoneId, error)) {
    s_intl_error->set(error, "intltz_get_canonical_id: could not convert "
                             "time zone id to UTF-16");
    return false;
  }

  auto result = icu::TimeZone::getEquivalentID(id, (int32_t)index);
  error = U_ZERO_ERROR;
  String ret(u8(result, error));
  if (U_FAILURE(error)) {
    s_intl_error->set(error, "intltz_get_equivalent_id: "
                             "could not convert resulting time zone id "
                             "to UTF-16");
    return false;
  }
  return ret;
}
示例#13
0
		//------------------------------------------------------------------------------------
		// Sets the tile in the terrain.
		//------------------------------------------------------------------------------------
		void TileTerrain2::SetTile( int Col, int Row, u32 TileID )
		{
			int mx = Col;
			int my = Row;
			int tx = mx / 64;
			int ty = my / 64;
			int id = ty * (m_iNumUparts / 4 + 1) + tx;
			tx = (mx % 64) * 8;
			ty = (my % 64) * 8;

				// Get texture and image data
				u8* pTexData	= m_ppBlendMaps[id]->GetCopyData(0);
				u8* pTexIDData	= m_ppTextureIDMaps[id]->GetCopyData(0);

				// for v and h
				int ix = 0, iy = -1, 
					is = 8 * m_pImgScaledBrush->GetBytePerPixel();
				for (int v = ty; v <  ty + 8 ; v++)
				{
					iy++;
					ix = -1;
					if (v < 0 || v >= 512)
						continue;
					for (int h = tx; h <  tx + 8; h++)
					{
						ix++;
						if (h < 0 || h >= 512)
							continue;

						// Read data and set them
						pTexData[v * 512 + h] = 255;
						pTexIDData[v * 1024 + h * 2 + 1] = u8(4 * TileID + 2);
					}
				}

				// Set the texture
				m_ppBlendMaps[id]->SetData(pTexData, 512*512);
				m_ppTextureIDMaps[id]->SetData(pTexIDData, 512*512*2);
			
		} // SetTile
void CUIDragDropReferenceList::OnItemDrop(CUIWindow* w, void* pData)
{
	OnItemSelected(w, pData);
	CUICellItem* itm = smart_cast<CUICellItem*>(w);
	VERIFY(itm->OwnerList() == itm->OwnerList());

	if(m_f_item_drop && m_f_item_drop(itm))
	{
		DestroyDragItem();
		return;
	}

	CUIDragDropListEx*	old_owner		= itm->OwnerList();
	CUIDragDropListEx*	new_owner		= m_drag_item->BackList();
	if(old_owner && new_owner && old_owner!=new_owner)
	{
		inherited::OnItemDrop(w, pData);
		return;
	}

	CActor* actor = smart_cast<CActor*>(Level().CurrentViewEntity());
	if(actor)
	{
		Ivector2 vec = PickCell(GetUICursor().GetCursorPosition());
		if(vec.x!=-1&&vec.y!=-1)
		{
			Ivector2 vec2 = m_container->GetItemPos(itm);
			if(vec2.x!=-1&&vec2.y!=-1)
			{
				u8 index = u8(vec2.x);
				shared_str tmp = ACTOR_DEFS::g_quick_use_slots[vec.x];
				xr_strcpy(ACTOR_DEFS::g_quick_use_slots[vec.x], ACTOR_DEFS::g_quick_use_slots[index]);
				xr_strcpy(ACTOR_DEFS::g_quick_use_slots[index], tmp.c_str());
				ReloadReferences(actor);
				return;
			}
		}
	}
	DestroyDragItem();
}
示例#15
0
std::vector<u8> AmfString::serializeValue(SerializationContext& ctx) const {
	// UTF-8-empty should not be cached.
	if (value.empty())
		return std::vector<u8> { 0x01 };

	int index = ctx.getIndex(value);
	if (index != -1)
		return std::vector<u8> { u8(index << 1) };
	ctx.addString(value);

	// UTF-8-vr = U29S-value *(UTF8-char)
	// U29S-value encodes the length of the following string
	std::vector<u8> buf = AmfInteger::asLength(value.size(), AMF_STRING);

	// Get rid of the type marker.
	buf.erase(buf.begin());

	// now, append the actual string.
	buf.insert(buf.end(), value.begin(), value.end());

	return buf;
}
示例#16
0
static Variant HHVM_METHOD(Transliterator, transliterate,
                           const String& str, int64_t begin, int64_t end) {
  FETCH_TRANS(data, this_);
  if (end < -1) {
    data->setError(U_ILLEGAL_ARGUMENT_ERROR,
                   "transliterator_transliterate: \"end\" argument should be "
                   "either non-negative or -1");
    return false;
  }
  if ((begin < 0) || ((end != -1) && (begin > end))) {
    data->setError(U_ILLEGAL_ARGUMENT_ERROR,
                   "transliterator_transliterate: \"start\" argument should be "
                   "non-negative and not bigger than \"end\" (if defined)");
    return false;
  }
  UErrorCode error = U_ZERO_ERROR;
  icu::UnicodeString str16(u16(str, error));
  if (U_FAILURE(error)) {
    data->setError(error, "String conversion of string to UTF-16 failed");
    return false;
  }
  if ((begin > str16.length()) || ((end != -1) && (end > str16.length()))) {
    data->setError(U_ILLEGAL_ARGUMENT_ERROR,
                   "transliterator_transliterate: Neither \"start\" nor the "
                   "\"end\" arguments can exceed the number of UTF-16 code "
                   "units (in this case, %d)", (int)str16.length());
    return false;
  }
  data->trans()->transliterate(str16, begin, (end < 0) ? str16.length() : end);

  error = U_ZERO_ERROR;
  String ret(u8(str16, error));
  if (U_FAILURE(error)) {
    data->setError(error, "String conversion of string to UTF-8 failed");
    return false;
  }
  data->clearError();
  return ret;
}
示例#17
0
void clientdata_proxy::make_config_dump(ClientID const & admin_id, ClientID const & cheater_id)
{
	m_admin_id = admin_id;
	m_chearer_id = cheater_id;
	xrClientData* tmp_cheater = static_cast<xrClientData*>(
		Level().Server->GetClientByID(m_chearer_id));
	if (!tmp_cheater)
	{
		Msg("! ERROR: SV: client [%u] not found ...", cheater_id.value());
		return;
	}
	if (m_ft_server->is_receiving_active(cheater_id))
	{
		Msg("! Receiving from client [%u] already active, please try later", cheater_id.value());
		return;
	}
	m_cheater_digest = tmp_cheater->m_cdkey_digest;
	m_cheater_name	= tmp_cheater->ps ? tmp_cheater->ps->getName() : "unknown";
	NET_Packet ssr_packet;
	ssr_packet.w_begin				(M_GAMEMESSAGE); 
	ssr_packet.w_u32				(GAME_EVENT_MAKE_DATA);
	ssr_packet.w_u8					(e_configs_request);	//make screenshot

	//alligning size to GAME_EVENT_PLAYER_KILLED message size
	ssr_packet.w_u16		(u16(Random.randI(2)));	//food for thought for crackers :)
	ssr_packet.w_u16		(u16(Random.randI(2)));
	ssr_packet.w_u16		(u16(Random.randI(2)));
	ssr_packet.w_u8			(u8(Random.randI(2)));

	Level().Server->SecureSendTo	(tmp_cheater, ssr_packet, net_flags(TRUE, TRUE));
	
	file_transfer::receiving_state_callback_t receiving_cb =
		fastdelegate::MakeDelegate(this, &clientdata_proxy::download_config_callback);
	if (my_proxy_mem_file.size())
		my_proxy_mem_file.clear();
	m_first_receive = true;
	m_receiver = m_ft_server->start_receive_file(my_proxy_mem_file, m_chearer_id, receiving_cb);

}
示例#18
0
/* Method to fill lgw_pkt_rx_s with data received by the ghost node server. */
static void readRX(struct lgw_pkt_rx_s *p, uint8_t *b)
{ p->freq_hz    = u32(b,0);
  p->if_chain   =  u8(b,4);
  p->status     =  u8(b,5);
  p->count_us   = u32(b,6);
  p->rf_chain   =  u8(b,10);
  p->modulation =  u8(b,11);
  p->bandwidth  =  u8(b,12);
  p->datarate   = u32(b,13);
  p->coderate   =  u8(b,17);
  p->rssi       = eflt(b,18);
  p->snr        = eflt(b,22);
  p->snr_min    = eflt(b,26);
  p->snr_max    = eflt(b,30);
  p->crc        = u16(b,34);
  p->size       = u16(b,36);
  memcpy((p->payload),&b[38],p->size); }
示例#19
0
s32 cellFsGetDirectoryEntries(u32 fd, vm::ptr<CellFsDirectoryEntry> entries, u32 entries_size, vm::ptr<u32> data_count)
{
	sys_fs->Warning("cellFsGetDirectoryEntries(fd=%d, entries_addr=0x%x, entries_size=0x%x, data_count_addr=0x%x)",
		fd, entries.addr(), entries_size, data_count.addr());

	LV2_LOCK(0);

	vfsDirBase* directory;
	if (!sys_fs->CheckId(fd, directory))
		return CELL_ESRCH;

	const DirEntryInfo* info = directory->Read();
	if (info)
	{
		entries->attribute.st_mode = 
		CELL_FS_S_IRUSR | CELL_FS_S_IWUSR | CELL_FS_S_IXUSR |
		CELL_FS_S_IRGRP | CELL_FS_S_IWGRP | CELL_FS_S_IXGRP |
		CELL_FS_S_IROTH | CELL_FS_S_IWOTH | CELL_FS_S_IXOTH;

		entries->attribute.st_uid = 0;
		entries->attribute.st_gid = 0;
		entries->attribute.st_atime_ = 0; //TODO
		entries->attribute.st_mtime_ = 0; //TODO
		entries->attribute.st_ctime_ = 0; //TODO
		entries->attribute.st_blksize = 4096;

		entries->entry_name.d_type = (info->flags & DirEntry_TypeFile) ? CELL_FS_TYPE_REGULAR : CELL_FS_TYPE_DIRECTORY;
		entries->entry_name.d_namlen = u8(std::min((u32)info->name.length(), (u32)CELL_MAX_FS_FILE_NAME_LENGTH));
		strcpy_trunc(entries->entry_name.d_name, info->name);
		*data_count = 1;
	}
	else
	{
		*data_count = 0;
	}

	return CELL_OK;
}
示例#20
0
std::vector<u8> AmfVector<T, typename VectorProperties<T>::type>::serialize(SerializationContext& ctx) const {
	int index = ctx.getIndex(*this);
	if (index != -1)
		return std::vector<u8> { VectorProperties<T>::marker, u8(index << 1) };
	ctx.addObject(*this);

	// U29V value
	std::vector<u8> buf = AmfInteger::asLength(values.size(),
		VectorProperties<T>::marker);

	// fixed-vector marker
	buf.push_back(fixed ? 0x01 : 0x00);

	for (const T& it : values) {
		// values are encoded in network byte order
		// ints are encoded as U32, not U29
		T netvalue = hton(it);
		const u8* bytes = reinterpret_cast<const u8*>(&netvalue);
		buf.insert(buf.end(), bytes, bytes + VectorProperties<T>::size);
	}

	return buf;
}
示例#21
0
std::vector<u8> AmfVector<AmfItem>::serialize(SerializationContext& ctx) const {
	int index = ctx.getIndex(*this);
	if (index != -1)
		return std::vector<u8> { AMF_VECTOR_OBJECT, u8(index << 1) };
	ctx.addObject(*this);

	// U29V value, encoding the length
	std::vector<u8> buf = AmfInteger::asLength(values.size(), AMF_VECTOR_OBJECT);

	// fixed-vector marker
	buf.push_back(fixed ? 0x01 : 0x00);

	// object type name
	std::vector<u8> typeName = AmfString(type).serializeValue(ctx);
	buf.insert(buf.end(), typeName.begin(), typeName.end());

	for (const auto& it : values) {
		auto s = it->serialize(ctx);
		buf.insert(buf.end(), s.begin(), s.end());
	}

	return buf;
}
示例#22
0
文件: Messages.cpp 项目: Hrym/mumble
void MainWindow::msgUserRemove(const MumbleProto::UserRemove &msg) {
	VICTIM_INIT;
	ACTOR_INIT;
	SELF_INIT;

	QString reason = u8(msg.reason());

	if (pDst == pSelf) {
		if (msg.ban())
			g.l->log(Log::YouKicked, tr("You were kicked and banned from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason));
		else
			g.l->log(Log::YouKicked, tr("You were kicked from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason));
	} else if (pSrc) {
		if (msg.ban())
			g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked and banned from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason).arg(Log::formatClientUser(pDst, Log::Target)));
		else
			g.l->log((pSrc == pSelf) ? Log::YouKicked : Log::UserKicked, tr("%3 was kicked from the server by %1: %2.").arg(Log::formatClientUser(pSrc, Log::Source)).arg(reason).arg(Log::formatClientUser(pDst, Log::Target)));
	} else {
		g.l->log(Log::UserLeave, tr("%1 disconnected.").arg(Log::formatClientUser(pDst, Log::Source)));
	}
	if (pDst != pSelf)
		pmModel->removeUser(pDst);
}
示例#23
0
bool game_sv_TeamDeathmatch::OnKillResult(KILL_RES KillResult, game_PlayerState* pKiller, game_PlayerState* pVictim)
{
    bool res = true;
    TeamStruct* pTeam		= GetTeamData(u8(pKiller->team));
    switch (KillResult)
    {
    case KR_TEAMMATE:
    {
//.			pKiller->kills -= 1;
        pKiller->m_iTeamKills++;
        if (pTeam)
            Player_AddMoney(pKiller, pTeam->m_iM_KillTeam);
        res = false;
    }
    break;
    default:
    {
        res = inherited::OnKillResult(KillResult, pKiller, pVictim);
    }
    break;
    }
    return res;
};
示例#24
0
文件: rts5260.c 项目: Anjali05/linux
static void rts5260_fill_driving(struct rtsx_pcr *pcr, u8 voltage)
{
	u8 driving_3v3[6][3] = {
		{0x94, 0x94, 0x94},
		{0x11, 0x11, 0x18},
		{0x55, 0x55, 0x5C},
		{0x94, 0x94, 0x94},
		{0x94, 0x94, 0x94},
		{0xFF, 0xFF, 0xFF},
	};
	u8 driving_1v8[6][3] = {
		{0x9A, 0x89, 0x89},
		{0xC4, 0xC4, 0xC4},
		{0x3C, 0x3C, 0x3C},
		{0x9B, 0x99, 0x99},
		{0x9A, 0x89, 0x89},
		{0xFE, 0xFE, 0xFE},
	};
	u8 (*driving)[3], drive_sel;

	if (voltage == OUTPUT_3V3) {
		driving = driving_3v3;
		drive_sel = pcr->sd30_drive_sel_3v3;
	} else {
		driving = driving_1v8;
		drive_sel = pcr->sd30_drive_sel_1v8;
	}

	rtsx_pci_write_register(pcr, SD30_CLK_DRIVE_SEL,
			 0xFF, driving[drive_sel][0]);

	rtsx_pci_write_register(pcr, SD30_CMD_DRIVE_SEL,
			 0xFF, driving[drive_sel][1]);

	rtsx_pci_write_register(pcr, SD30_CMD_DRIVE_SEL,
			 0xFF, driving[drive_sel][2]);
}
示例#25
0
Variant HHVM_STATIC_METHOD(IntlChar, getFC_NFKC_Closure, const Variant& arg) {
  GETCP(arg, cp);
  UErrorCode error = U_ZERO_ERROR;
  auto closure_len = u_getFC_NFKC_Closure(cp, nullptr, 0, &error);
  if (closure_len == 0) {
    return empty_string();
  }
  icu::UnicodeString closure;
  auto out = closure.getBuffer(closure_len + 1);
  error = U_ZERO_ERROR;
  closure_len = u_getFC_NFKC_Closure(cp, out, closure_len + 1, &error);
  if (U_FAILURE(error)) {
    s_intl_error->setError(error, "Failed getting closure");
    return false;
  }
  closure.releaseBuffer(closure_len);
  error = U_ZERO_ERROR;
  String ret(u8(closure, error));
  if (U_FAILURE(error)) {
    s_intl_error->setError(error, "Failed converting output to UTF8");
    return false;
  }
  return ret;
}
示例#26
0
static String HHVM_METHOD(NumberFormatter, formatCurrency,
                          double value,
                          const String& currency) {
  NUMFMT_GET(obj, this_, String());
  UErrorCode error = U_ZERO_ERROR;
  icu::UnicodeString uCurrency(u16(currency, error));
  NUMFMT_CHECK(obj, error, String());

  // By default UnicodeString isn't NULL terminated
  int32_t currencyBuffer_len = uCurrency.length();
  UChar *currencyBuffer = uCurrency.getBuffer(currencyBuffer_len + 1);
  SCOPE_EXIT{ uCurrency.releaseBuffer(currencyBuffer_len + 1); };
  currencyBuffer[currencyBuffer_len] = 0;

  error = U_ZERO_ERROR;
  uint32_t len =
    unum_formatDoubleCurrency(obj->formatter(), value,
                              currencyBuffer,
                              nullptr, 0,
                              nullptr, &error);
  if (error != U_BUFFER_OVERFLOW_ERROR) {
    obj->setError(error);
    return String();
  }
  icu::UnicodeString out;
  error = U_ZERO_ERROR;
  len = unum_formatDoubleCurrency(obj->formatter(), value,
                                  currencyBuffer,
                                  out.getBuffer(len + 1), len + 1,
                                  nullptr, &error);
  NUMFMT_CHECK(obj, error, String());
  out.releaseBuffer(len);
  String ret(u8(out, error));
  NUMFMT_CHECK(obj, error, String());
  return ret;
}
示例#27
0
void UserEdit::accept() {
	QList<QListWidgetItem *> ql = qlwUserList->findItems(QString(), Qt::MatchStartsWith);
	foreach(QListWidgetItem * qlwi, ql) {
		const QString &name = qlwi->text();
		int id = qlwi->data(Qt::UserRole).toInt();
		if (qmUsers.value(id) != name) {
			qmChanged.insert(id, name);
		}
	}

	if (! qmChanged.isEmpty()) {
		MumbleProto::UserList mpul;
		QMap<int, QString>::const_iterator i;
		for (i=qmChanged.constBegin(); i!=qmChanged.constEnd(); ++i) {
			MumbleProto::UserList_User *u = mpul.add_users();
			u->set_user_id(i.key());
			if (! i.value().isEmpty())
				u->set_name(u8(i.value()));
		}
		g.sh->sendMessage(mpul);
	}

	QDialog::accept();
}
示例#28
0
文件: instance.c 项目: ahua/java
/*
 * Execute the NEWARRAY instruction
 */
void op_newarray() {
    // figure out the required size
    int atype = u8(1);
    int width = getWidth(atype);
    int length = peekInt(); // don't pop in case rolled back later
    int numBytes = length * width;
    int extra = ((numBytes % 4) == 0) ? 0 : 1;
    int numDataWords = (numBytes / 4) + extra;
    int numWords = numDataWords + ARRAY_DATA;

    // allocate space
    Ref array = allocate(numWords, HEADER_DATA_ARRAY);
    if (array == NULL) { return; } // rollback, gc done
    popInt(); // can pop the length now

    // initialise new array and push address on stack
    int hash = (char*) array - (char*) core;
    Ref type = getRef(core, CORE_ARRAYS + atype);
    setInt(array, OBJECT_HASHCODE, hash);
    setRef(array, OBJECT_TYPE, type);
    setInt(array, ARRAY_LENGTH, length);
    pushRef(array);
    pc += 2;
}
示例#29
0
TEST(BitWise, and){
    uint128_t t  ((bool)     true);
    uint128_t f  ((bool)     false);
    uint128_t u8 ((uint8_t)  0xaaULL);
    uint128_t u16((uint16_t) 0xaaaaULL);
    uint128_t u32((uint32_t) 0xaaaaaaaaULL);
    uint128_t u64((uint64_t) 0xaaaaaaaaaaaaaaaaULL);

    const uint128_t val(0xf0f0f0f0f0f0f0f0ULL, 0xf0f0f0f0f0f0f0f0ULL);

    EXPECT_EQ(t   &  val, uint128_t(0));
    EXPECT_EQ(f   &  val, uint128_t(0));
    EXPECT_EQ(u8  &  val, uint128_t(0xa0ULL));
    EXPECT_EQ(u16 &  val, uint128_t(0xa0a0ULL));
    EXPECT_EQ(u32 &  val, uint128_t(0xa0a0a0a0ULL));
    EXPECT_EQ(u64 &  val, uint128_t(0xa0a0a0a0a0a0a0a0ULL));

    EXPECT_EQ(t   &= val, uint128_t(0x0ULL));
    EXPECT_EQ(f   &= val, uint128_t(0x0ULL));
    EXPECT_EQ(u8  &= val, uint128_t(0xa0ULL));
    EXPECT_EQ(u16 &= val, uint128_t(0xa0a0ULL));
    EXPECT_EQ(u32 &= val, uint128_t(0xa0a0a0a0ULL));
    EXPECT_EQ(u64 &= val, uint128_t(0xa0a0a0a0a0a0a0a0ULL));
}
示例#30
0
TilesetPtr TilesetType_MonsterBashSprite::create(stream::inout_sptr psGraphics,
	SuppData& suppData) const
{
	psGraphics << u8(0xFF);
	return TilesetPtr(new Tileset_MonsterBashSprite(psGraphics));
}