QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph) { TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); QImage result(glyphBitmapBytes, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight, glyphBitmapSize.iWidth, QImage::Format_Indexed8); result.setColorTable(grayPalette()); // The above setColorTable() call detached the image data anyway, so why not shape tha data a bit, while we can. // CFont::GetCharacterData() returns 8-bit data that obviously was 4-bit data before, and converted to 8-bit incorrectly. // The data values are 0x00, 0x10 ... 0xe0, 0xf0. So, a real opaque 0xff is never reached, which we get punished // for every time we want to blit this glyph in the raster paint engine. // "Fix" is to convert all 0xf0 to 0xff. Is fine, quality wise, and I assume faster than correcting all values. // Blitting is however, evidentially faster now. const int bpl = result.bytesPerLine(); for (int row = 0; row < result.height(); ++row) { uchar *scanLine = result.scanLine(row); for (int column = 0; column < bpl; ++column) { if (*scanLine == 0xf0) *scanLine = 0xff; scanLine++; } } return result; }
//----------------------------------------------------------------------------- void SMonster::dead(SCharacter* murderer) { #if 0 SCharacter::dead(murderer); //10秒后复活 setAliveTime(20); SRegionObjectBase* myRegion = this->getCurrentRegionObject(); DYNAMIC_ASSERT(NULL != myRegion); //怪物死后掉落物品 U32 randItemId = getCharacterTempInfo()->getMonsterItemGroupId(); myRegion->getDropItemManager()->handleDropItemMonster(randItemId, getCurrentRegionObject(), getPos(), murderer); //将怪物和杀死的它的玩家信息传递给frontserver做处理 如:任务 SPlayerCharacter* killerTemp = (SPlayerCharacter*)murderer; SPlayerIdentifyInfoInPlayerCharacter* playerIdentify = killerTemp->getPlayerIdentifyInfo(); MonsterData* monsterData = getMonsterData(); DYNAMIC_ASSERT(monsterData); MonsterIdType monsterId = monsterData->mCharacterTemplateID; PlayerCharacterIdType playerCharacterId = killerTemp->getID(); PlayerIdType playerId = playerIdentify->accountId; NetIdType netFrontServerID = playerIdentify->frontServerId; NetIdType netClientInFrontId = playerIdentify->clientNetIdInFrontServer; SMonsterNetPacketProcesser::getInstance().sendMonsterBeKilledByPlayerCharacter(netFrontServerID,monsterId,playerCharacterId,playerId,netClientInFrontId); //判断是否结束副本 SInstanceRegion* myInstanceRegion = getCurrentRealRegionObject(); DYNAMIC_ASSERT(NULL != myInstanceRegion); //DYNAMIC_ASSERT(InstanceType_PVE == myInstanceRegion->getInstanceType()); SInstanceBase* instanceBase = myInstanceRegion->getNewInstanceBase(); if (InstanceType_PVE != myInstanceRegion->getInstanceType()) { return; } SPVEInstance* pveInstance = (SPVEInstance*)myInstanceRegion->getNewInstanceBase(); if (getCharacterData()->mCharacterTemplateID == pveInstance->getFinishCharacter()) { //此怪物死了,副本结束 //DYNAMIC_ASSERT(murderer->getType() == GOT_PLAYERCHARACTER); SPlayerCharacter* killer = (SPlayerCharacter*)murderer; Int groupItemId = pveInstance->getPVECsv()->itemGroupId; myRegion->getDropItemManager()->handleRewardItemInRegion(myRegion, groupItemId); //获取奖励接口, 并在FrontServer负责通知客户端 获得哪些物品 //sitem.getprize(pveInstance->); } #endif }
void QFontEngineS60::recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const { Q_UNUSED(flags); TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; for (int i = 0; i < glyphs->numGlyphs; i++) { getCharacterData(glyphs->glyphs[i], metrics, glyphBitmapBytes, glyphBitmapSize); glyphs->advances_x[i] = metrics.HorizAdvance(); glyphs->advances_y[i] = 0; } }
void DisplayManager::printCharacter(char c, int8_t dx, int8_t dy, uint8_t brightness){ uint8_t data[8]; getCharacterData(c, data); for(uint8_t y=0; y<getCharacterHeight(); ++y){ for(uint8_t x=0; x<getCharacterWidth(); ++x){ // font data is 8 bits left adjusted if((data[y] & _BV(7-x)) && x+dx<10) blipbox.leds.setLed(x+dx, 7-y+dy, brightness); else if(x+dx<10) blipbox.leds.setLed(x+dx, 7-y+dy, 0x00); } } }
QImage QFontEngineS60::alphaMapForGlyph(glyph_t glyph) { // Note: On some Symbian versions (apparently <= Symbian^1), this // function will return gray values 0x00, 0x10 ... 0xe0, 0xf0 due // to a bug. The glyphs are nowhere perfectly opaque. // This has been fixed for Symbian^3. TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); QImage result(glyphBitmapBytes, glyphBitmapSize.iWidth, glyphBitmapSize.iHeight, glyphBitmapSize.iWidth, QImage::Format_Indexed8); result.setColorTable(grayPalette()); return result; }
glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const { TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); const glyph_metrics_t result( metrics.HorizBearingX(), -metrics.HorizBearingY(), metrics.Width(), metrics.Height(), metrics.HorizAdvance(), 0 ); return result; }
glyph_metrics_t QFontEngineS60::boundingBox_const(glyph_t glyph) const { TOpenFontCharMetrics metrics; const TUint8 *glyphBitmapBytes; TSize glyphBitmapSize; getCharacterData(glyph, metrics, glyphBitmapBytes, glyphBitmapSize); TRect glyphBounds; metrics.GetHorizBounds(glyphBounds); const glyph_metrics_t result( glyphBounds.iTl.iX, glyphBounds.iTl.iY, glyphBounds.Width(), glyphBounds.Height(), metrics.HorizAdvance(), 0 ); return result; }
void xml::lex::getContent(xml::token *tok) { static const char* s_emptyElement = "/>"; static const char* s_endElement = "</"; static const char* s_elementEnd = ">"; static const char* s_cdataStart = "<![CDATA["; int nEndlessLoopDetection = 0; if (m_s != 0) { contentTop:; if (nEndlessLoopDetection++ > 1000) { // When parsing a XML with an invalid element <@CustomerID> // 1000 is well beyond any normal behavior of stream stacks. throw GException("XML Parser", 27, m_line, m_byte); } switch (m_sstate) { case xml::_xml_element_start : if (!m_s) throw GException("XML Parser", 28, m_line, m_byte); if ((m_s->m_xml[m_s->m_offset] == '<') && (isNameChar(m_s->m_xml[m_s->m_offset + 1]))) { m_s->m_offset++; offsetLine(); tok->m_type = _startTag; if (getName(tok) != false) { GStackPush(m_tagStack,tok->get()); m_sstate = _xml_element_attribute; if ((m_tagStack.m_nNext == 1) && (m_documentType != 0)) { if (memcmp(m_documentType, tok->get(), tok->length()) != 0) { throw GException("XML Parser", 16, m_line, m_byte); } } } else { throw GException("XML Parser", 11, m_line, m_byte); } } else { // make sure that the next tag isn't a > if (m_s->m_xml[m_s->m_offset + 1] == *s_elementEnd) throw GException("XML Parser", 11, m_line, m_byte); m_sstate = _xml_element_content; goto contentTop; } break; case xml::_xml_element_attribute : if (handleWhitespace() != false) { if (getName(tok) != false) { tok->m_type = _attributeName; m_sstate = _xml_element_attribute_value; } else { m_sstate = _xml_element_start_end; goto contentTop; } } else { m_sstate = _xml_element_start_end; goto contentTop; } break; case xml::_xml_element_start_end : if (handleReserved(s_emptyElement) != false) { // return an empty end tag token tok->m_type = _emptyEndTag; m_sstate = _xml_element_start; } else if (handleReserved(s_elementEnd) != false) { m_sstate = _xml_element_content; goto contentTop; } else { throw GException("XML Parser", 8, m_line, m_byte); } break; case xml::_xml_element_attribute_value : getEqual(); getQuote(); tok->m_type = _pcdata; getAttribute(tok); getQuote(); m_sstate = _xml_element_attribute; break; case xml::_xml_element_content : if (getCharacterData(tok) != false) tok->m_type = _pcdata; else if (handleReserved(s_cdataStart) != false) { getCData(tok); tok->m_type = _cdata; } else { getMisc(tok); if (tok->m_type == _unknown) { m_sstate = _xml_element_end_tag; goto contentTop; } } break; case xml::_xml_element_end_tag : handleWhitespace(); if (handleReserved(s_endElement) != false) { tok->m_type = _endTag; getName(tok); m_sstate = _xml_element_end_end; } else if (m_tagStack.m_nNext) { m_sstate = _xml_element_start; goto contentTop; } break; case xml::_xml_element_end_end : handleWhitespace(); if (handleReserved(s_elementEnd) == false) { throw GException("XML Parser", 8, m_line, m_byte); } m_sstate = _xml_element_start; goto contentTop; break; } } if ((tok->m_type == _endTag) || (tok->m_type == _emptyEndTag)) { // throw an exception if the end tag // doesn't match the last start tag GStackPopType(m_tagStack,tag,char *) if ( (tok->isEmpty() == false) && (tag != 0) ) { if (memcmp(tag, tok->get(), tok->length()) != 0) { GString strStartTag; while ((tag) && (*tag != '>') && (!isWhitespace(*tag))) { strStartTag += *tag; tag++; } GString strEndTag(tok->get(), tok->length()); throw GException("XML Parser", 12, (const char *)strEndTag, (const char *)strStartTag,m_line, m_byte); } } if (m_tagStack.m_nNext == 0) { m_state = xml::_finished; m_nextState = xml::_finished; if ((tok->m_type == _endTag) && (handleReserved(s_elementEnd) == false)) { throw GException("XML Parser", 8, m_line, m_byte); } } }
//----------------------------------------------------------------------------- void CCharacter::setCharacterTemplateID( U32 id ) { getCharacterData()->mCharacterTemplateID = id; }
//----------------------------------------------------------------------------- void CCharacter::setCharacterTempInfo() { mCharacterTempInfo = CharacterTemplate::getInstance().getCharacterTempInfo(getCharacterData()->mCharacterTemplateID); }
//----------------------------------------------------------------------------- InstanceIdType CCharacter::getInstanceUId() { return getCharacterData()->mInstanceUId; }
//----------------------------------------------------------------------------- MG::U32 CCharacter::getRegionID() { return getCharacterData()->mRegionID; }
//----------------------------------------------------------------------------- MG::REGION_OBJ_TYPE CCharacter::getRegionType() { return getCharacterData()->mRegionType; }
//----------------------------------------------------------------------------- void CCharacter::setRegion( REGION_OBJ_TYPE type, U32 id, InstanceIdType instanceId, Bool isCalBelongMapID/*=false*/ ) { getCharacterData()->mRegionType = type; getCharacterData()->mRegionID = id; getCharacterData()->mInstanceUId = instanceId; }
//----------------------------------------------------------------------------- void CCharacter::setLevel( U32 level ) { getCharacterData()->mLevel = level; }
//----------------------------------------------------------------------------- MG::U32 CCharacter::getLevel() { return getCharacterData()->mLevel; }
//----------------------------------------------------------------------------- MonsterData* SMonster::getMonsterData() { return (MonsterData*)(getCharacterData()); }
//----------------------------------------------------------------------------- MG::U32 CCharacter::getCharacterTemplateID() { return getCharacterData()->mCharacterTemplateID; }