/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Element testEmployee; Node firstC; String childName; int nodeType; CharacterData employeeIDNode; String employeeID; doc = (Document) baseT::load("hc_staff", false); elementList = doc.getElementsByTagName(SA::construct_from_utf8("p")); testEmployee = (Element) elementList.item(3); firstC = testEmployee.getFirstChild(); nodeType = (int) firstC.getNodeType(); while (baseT::equals(3, nodeType)) { firstC = firstC.getNextSibling(); nodeType = (int) firstC.getNodeType(); } childName = firstC.getNodeName(); baseT::assertEquals("em", childName, __LINE__, __FILE__); employeeIDNode = (CharacterData) firstC.getFirstChild(); employeeID = employeeIDNode.getNodeValue(); baseT::assertEquals("EMP0004", employeeID, __LINE__, __FILE__); }
void ChatHandler::handleGuildMemberLevelChange(ChatClient &client, MessageIn &msg) { // get the guild, the user to change the permissions, and the new permission // check theyre valid, and then change them MessageOut reply(CPMSG_GUILD_PROMOTE_MEMBER_RESPONSE); short guildId = msg.readInt16(); std::string user = msg.readString(); short level = msg.readInt8(); Guild *guild = guildManager->findById(guildId); CharacterData *c = storage->getCharacter(user); if (guild && c) { int rights = guild->getUserPermissions(c->getDatabaseID()) | level; if (guildManager->changeMemberLevel(&client, guild, c->getDatabaseID(), rights) == 0) { reply.writeInt8(ERRMSG_OK); client.send(reply); } } reply.writeInt8(ERRMSG_FAILURE); client.send(reply); }
void CharacterData::applyData(CharacterData data, CharacterData originalData) { this->attack=data.attack; this->attack = MAX(this->attack,0); this->defense=data.defense; this->defense = MAX(this->defense,0); this->speed=data.speed; this->speed = MAX(this->speed,0); this->jumpHeight=data.jumpHeight; this->jumpHeight = MAX(this->jumpHeight,0); this->attackSpeed=data.attackSpeed; this->attackSpeed = MAX(this->attackSpeed,0); this->maxJumpTimes=data.maxJumpTimes; this->maxJumpTimes = MAX(this->maxJumpTimes,0); if(data.getHealth()>0) { this->health+= data.health; this->health = MIN(this->health,originalData.getHealth()); } else { this->health+= MIN((data.getHealth()+this->getDefense()),0); } // this->health = MAX(this->health,0); }
void HTMLConstructionSite::insertTextNode(const String& characters) { AttachmentSite site; site.parent = currentNode(); site.nextChild = 0; if (shouldFosterParent()) findFosterSite(site); unsigned currentPosition = 0; // FIXME: Splitting text nodes into smaller chunks contradicts HTML5 spec, but is currently necessary // for performance, see <https://bugs.webkit.org/show_bug.cgi?id=55898>. Node* previousChild = site.nextChild ? site.nextChild->previousSibling() : site.parent->lastChild(); if (previousChild && previousChild->isTextNode()) { // FIXME: We're only supposed to append to this text node if it // was the last text node inserted by the parser. CharacterData* textNode = static_cast<CharacterData*>(previousChild); currentPosition = textNode->parserAppendData(characters.characters(), characters.length(), Text::defaultLengthLimit); } while (currentPosition < characters.length()) { RefPtr<Text> textNode = Text::createWithLengthLimit(site.parent->document(), characters, currentPosition); // If we have a whole string of unbreakable characters the above could lead to an infinite loop. Exceeding the length limit is the lesser evil. if (!textNode->length()) textNode = Text::create(site.parent->document(), characters.substring(currentPosition)); currentPosition += textNode->length(); ASSERT(currentPosition <= characters.length()); attachAtSite(site, textNode.release()); } }
void ChatHandler::handleGuildGetMembers(ChatClient &client, MessageIn &msg) { MessageOut reply(CPMSG_GUILD_GET_MEMBERS_RESPONSE); short guildId = msg.readInt16(); Guild *guild = guildManager->findById(guildId); // check for valid guild // write a list of member names that belong to the guild if (guild) { // make sure the requestor is in the guild if (guild->checkInGuild(client.characterId)) { reply.writeInt8(ERRMSG_OK); reply.writeInt16(guildId); std::list<GuildMember*> memberList = guild->getMembers(); std::list<GuildMember*>::const_iterator itr_end = memberList.end(); for (std::list<GuildMember*>::iterator itr = memberList.begin(); itr != itr_end; ++itr) { CharacterData *c = storage->getCharacter((*itr)->mId, nullptr); std::string memberName = c->getName(); reply.writeString(memberName); reply.writeInt8(mPlayerMap.find(memberName) != mPlayerMap.end()); } } } else { reply.writeInt8(ERRMSG_FAILURE); } client.send(reply); }
EveApi::CharacterData::CharacterData ( const CharacterData& other ): _name(other.name()), _characterID(other.characterID()), _corporationName(other.corporationName()), _corporationID(other.corporationID()) { }
bool EveApi::CharacterData::operator==(const CharacterData& other) const { if (this->_name == other.name() && this->_characterID == other.characterID() && this->_corporationName == other.corporationName() && this->_corporationID == other.corporationID()) return true; return false; }
SourceFrame BitmapFont::GetSourceFrameForCharacter(char aCharacter) { CharacterData* characterData = m_CharacterData[aCharacter]; if(characterData != nullptr) { return characterData->GetSourceFrame(); } return SourceFrame(0.0f, 0.0f, 0.0f, 0.0f); }
char BitmapFont::GetBearingYForCharacter(char aCharacter) { CharacterData* characterData = m_CharacterData[aCharacter]; if(characterData != nullptr) { return (char)characterData->GetOffset().y; } return 0; }
unsigned short BitmapFont::GetAdvanceXForCharacter(char aCharacter) { CharacterData* characterData = m_CharacterData[aCharacter]; if(characterData != nullptr) { return characterData->GetAdvanceX(); } return 0; }
void JSCharacterData::putValueProperty(ExecState* exec, int token, JSValue* value) { switch (token) { case DataAttrNum: { CharacterData* imp = static_cast<CharacterData*>(impl()); ExceptionCode ec = 0; imp->setData(valueToStringWithNullCheck(exec, value), ec); setDOMException(exec, ec); break; } } }
JSValue* jsCharacterDataPrototypeFunctionAppendData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCharacterData::s_info)) return throwError(exec, TypeError); JSCharacterData* castedThisObj = static_cast<JSCharacterData*>(thisValue); CharacterData* imp = static_cast<CharacterData*>(castedThisObj->impl()); ExceptionCode ec = 0; const UString& data = args.at(exec, 0)->toString(exec); imp->appendData(data, ec); setDOMException(exec, ec); return jsUndefined(); }
void HTMLConstructionSite::insertTextNode(const String& characters, WhitespaceMode whitespaceMode) { HTMLConstructionSiteTask task; task.parent = currentNode(); if (shouldFosterParent()) findFosterSite(task); #if ENABLE(TEMPLATE_ELEMENT) if (task.parent->hasTagName(templateTag)) task.parent = toHTMLTemplateElement(task.parent.get())->content(); #endif // Strings composed entirely of whitespace are likely to be repeated. // Turn them into AtomicString so we share a single string for each. bool shouldUseAtomicString = whitespaceMode == AllWhitespace || (whitespaceMode == WhitespaceUnknown && isAllWhitespace(characters)); unsigned currentPosition = 0; // FIXME: Splitting text nodes into smaller chunks contradicts HTML5 spec, but is currently necessary // for performance, see <https://bugs.webkit.org/show_bug.cgi?id=55898>. Node* previousChild = task.nextChild ? task.nextChild->previousSibling() : task.parent->lastChild(); if (previousChild && previousChild->isTextNode()) { // FIXME: We're only supposed to append to this text node if it // was the last text node inserted by the parser. CharacterData* textNode = static_cast<CharacterData*>(previousChild); currentPosition = textNode->parserAppendData(characters, 0, Text::defaultLengthLimit); } while (currentPosition < characters.length()) { RefPtr<Text> textNode = Text::createWithLengthLimit(task.parent->document(), shouldUseAtomicString ? AtomicString(characters).string() : characters, currentPosition); // If we have a whole string of unbreakable characters the above could lead to an infinite loop. Exceeding the length limit is the lesser evil. if (!textNode->length()) { String substring = characters.substring(currentPosition); textNode = Text::create(task.parent->document(), shouldUseAtomicString ? AtomicString(substring).string() : substring); } currentPosition += textNode->length(); ASSERT(currentPosition <= characters.length()); task.child = textNode.release(); if (task.parent->document() != task.child->document()) task.parent->document()->adoptNode(task.child, ASSERT_NO_EXCEPTION); executeTask(task); } }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Node nameNode; CharacterData child; String childData; doc = (Document) baseT::load("staff", false); elementList = doc.getElementsByTagName(SA::construct_from_utf8("name")); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); childData = child.getData(); baseT::assertEquals("Margaret Martin", childData, __LINE__, __FILE__); }
JSValue* JSCharacterData::getValueProperty(ExecState* exec, int token) const { switch (token) { case DataAttrNum: { CharacterData* imp = static_cast<CharacterData*>(impl()); return jsString(exec, imp->data()); } case LengthAttrNum: { CharacterData* imp = static_cast<CharacterData*>(impl()); return jsNumber(exec, imp->length()); } case ConstructorAttrNum: return getConstructor(exec); } return 0; }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Node nameNode; CharacterData child; String childData; doc = (Document) baseT::load("staff", true); elementList = doc.getElementsByTagName(SA::construct_from_utf8("address")); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); child.replaceData(30, 5, SA::construct_from_utf8("98665")); childData = child.getData(); baseT::assertEquals("1230 North Ave. Dallas, Texas 98665", childData, __LINE__, __FILE__); }
// static already_AddRefed<DeleteTextTransaction> DeleteTextTransaction::MaybeCreateForPreviousCharacter( EditorBase& aEditorBase, CharacterData& aCharData, uint32_t aOffset) { if (NS_WARN_IF(!aOffset)) { return nullptr; } nsAutoString data; aCharData.GetData(data); if (NS_WARN_IF(data.IsEmpty())) { return nullptr; } uint32_t length = 1; uint32_t offset = aOffset - 1; if (offset && NS_IS_LOW_SURROGATE(data[offset]) && NS_IS_HIGH_SURROGATE(data[offset - 1])) { ++length; --offset; } return DeleteTextTransaction::MaybeCreate(aEditorBase, aCharData, offset, length); }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Node nameNode; CharacterData child; String childData; doc = (Document) baseT::load("hc_staff", true); elementList = doc.getElementsByTagName(SA::construct_from_utf8("acronym")); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); child.deleteData(0, 16); childData = child.getData(); baseT::assertEquals("Dallas, Texas 98551", childData, __LINE__, __FILE__); }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Node nameNode; CharacterData child; String childValue; int childLength; doc = (Document) baseT::load("staff", false); elementList = doc.getElementsByTagName(SA::construct_from_utf8("name")); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); childValue = child.getData(); childLength = SA::length(childValue); baseT::assertEquals(15, childLength, __LINE__, __FILE__); }
JSValue* jsCharacterDataPrototypeFunctionInsertData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCharacterData::s_info)) return throwError(exec, TypeError); JSCharacterData* castedThisObj = static_cast<JSCharacterData*>(thisValue); CharacterData* imp = static_cast<CharacterData*>(castedThisObj->impl()); ExceptionCode ec = 0; int offset = args.at(exec, 0)->toInt32(exec); if (offset < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } const UString& data = args.at(exec, 1)->toString(exec); imp->insertData(offset, data, ec); setDOMException(exec, ec); return jsUndefined(); }
void HTMLConstructionSite::insertTextNode(const String& characters) { AttachmentSite site; site.parent = currentElement(); site.nextChild = 0; if (shouldFosterParent()) findFosterSite(site); Node* previousChild = site.nextChild ? site.nextChild->previousSibling() : site.parent->lastChild(); if (previousChild && previousChild->isTextNode()) { // FIXME: We're only supposed to append to this text node if it // was the last text node inserted by the parser. CharacterData* textNode = static_cast<CharacterData*>(previousChild); textNode->parserAppendData(characters); return; } attachAtSite(site, Text::create(site.parent->document(), characters)); }
/* * Runs the test case. */ void runTest() { Document doc; EntityReference entRef; CharacterData entText; doc = (Document) baseT::load("staff", true); entRef = doc.createEntityReference(SA::construct_from_utf8("ent3")); baseT::assertNotNull(entRef, __LINE__, __FILE__); entText = (CharacterData) entRef.getFirstChild(); baseT::assertNotNull(entText, __LINE__, __FILE__); { boolean success = false; try { entText.setNodeValue(SA::construct_from_utf8("newValue")); } catch (const DOMException& ex) { success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR); } assertTrue(success); } }
/* * Runs the test case. */ void runTest() { Document doc; NodeList genderList; Node genderNode; EntityReference entRef; Node entNode; Element entElement; CharacterData entElementText; int nodeType; doc = (Document) baseT::load("staff", true); genderList = doc.getElementsByTagName(SA::construct_from_utf8("gender")); genderNode = genderList.item(2); entNode = genderNode.getFirstChild(); baseT::template skipIfNot<EntityReference>(entNode); entRef = (EntityReference) genderNode.getFirstChild(); baseT::assertNotNull(entRef, __LINE__, __FILE__); nodeType = (int) entRef.getNodeType(); if (baseT::equals(1, nodeType)) { entRef = doc.createEntityReference(SA::construct_from_utf8("ent4")); baseT::assertNotNull(entRef, __LINE__, __FILE__); } entElement = (Element) entRef.getFirstChild(); baseT::assertNotNull(entElement, __LINE__, __FILE__); entElementText = (CharacterData) entElement.getFirstChild(); baseT::assertNotNull(entElementText, __LINE__, __FILE__); { boolean success = false; try { entElementText.setNodeValue(SA::construct_from_utf8("newValue")); } catch (const DOMException& ex) { success = (ex.code() == DOMException::NO_MODIFICATION_ALLOWED_ERR); } assertTrue(success); } }
/* * Runs the test case. */ void runTest() { Document doc; NodeList elementList; Node nameNode; CharacterData child; doc = (Document) baseT::load("staff", true); elementList = doc.getElementsByTagName(SA::construct_from_utf8("address")); nameNode = elementList.item(0); child = (CharacterData) nameNode.getFirstChild(); { boolean success = false; try { child.insertData(-5, SA::construct_from_utf8("ABC")); } catch (const DOMException& ex) { success = (ex.code() == DOMException::INDEX_SIZE_ERR); } assertTrue(success); } }
JSValue* jsCharacterDataPrototypeFunctionDeleteData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCharacterData::s_info)) return throwError(exec, TypeError); JSCharacterData* castedThisObj = static_cast<JSCharacterData*>(thisValue); CharacterData* imp = static_cast<CharacterData*>(castedThisObj->impl()); ExceptionCode ec = 0; int offset = args[0]->toInt32(exec); if (offset < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } int length = args[1]->toInt32(exec); if (length < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } imp->deleteData(offset, length, ec); setDOMException(exec, ec); return jsUndefined(); }
void BitmapFont::ParseCharactersNode(xml_node<> *aCharactersNode) { //Cycle through the characters and add them to the character map for (xml_node<> *character = aCharactersNode->first_node(); character; character = character->next_sibling()) { //Create a new character data object CharacterData* characterData = new CharacterData(); //Parse the character char characterId = characterData->ParseCharacterNode(character, this); #if LOG_BITMAP_FONT_GLYPH_DATA Log("Character Data for Character: %c - width: %f - height: %f - bearingX: %f - bearingY: %f - advance: %u", characterId, characterData->GetSourceFrame().size.x, characterData->GetSourceFrame().size.y, characterData->GetOffset().x, characterData->GetOffset().y, characterData->GetAdvanceX()); #endif //Push back the character onto the character set vector m_CharacterSet.push_back(characterId); //Set the character data m_CharacterData[characterId] = characterData; } }
void AbstractSkill::calculateSkillData(SkillData* data, CharacterData characterData) { //Calculate enemy effect list vector<EffectData> listEffect = data->getListEnemyEffect(); for(int i=0 ; i<listEffect.size() ; i++) { EffectData effectData = data->getListEnemyEffect()[i]; effectData.setHealth(effectData.getHealth()-characterData.getAttack()); listEffect[i] = effectData; // CCLOG("%d",data->getListEnemyEffect()[i].getHealth()); } data->setListEnemyEffect(listEffect); }
void ChatHandler::sendGuildListUpdate(Guild *guild, const std::string &characterName, char eventId) { MessageOut msg(CPMSG_GUILD_UPDATE_LIST); msg.writeInt16(guild->getId()); msg.writeString(characterName); msg.writeInt8(eventId); std::map<std::string, ChatClient*>::const_iterator chr; std::list<GuildMember*> members = guild->getMembers(); for (std::list<GuildMember*>::const_iterator itr = members.begin(); itr != members.end(); ++itr) { CharacterData *c = storage->getCharacter((*itr)->mId, nullptr); chr = mPlayerMap.find(c->getName()); if (chr != mPlayerMap.end()) { chr->second->send(msg); } } }
JSValue* jsCharacterDataPrototypeFunctionSubstringData(ExecState* exec, JSObject*, JSValue* thisValue, const ArgList& args) { if (!thisValue->isObject(&JSCharacterData::s_info)) return throwError(exec, TypeError); JSCharacterData* castedThisObj = static_cast<JSCharacterData*>(thisValue); CharacterData* imp = static_cast<CharacterData*>(castedThisObj->impl()); ExceptionCode ec = 0; int offset = args.at(exec, 0)->toInt32(exec); if (offset < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } int length = args.at(exec, 1)->toInt32(exec); if (length < 0) { setDOMException(exec, INDEX_SIZE_ERR); return jsUndefined(); } JSC::JSValue* result = jsStringOrNull(exec, imp->substringData(offset, length, ec)); setDOMException(exec, ec); return result; }
// static already_AddRefed<DeleteTextTransaction> DeleteTextTransaction::MaybeCreateForNextCharacter( EditorBase& aEditorBase, CharacterData& aCharData, uint32_t aOffset) { nsAutoString data; aCharData.GetData(data); if (NS_WARN_IF(aOffset >= data.Length()) || NS_WARN_IF(data.IsEmpty())) { return nullptr; } uint32_t length = 1; if (aOffset + 1 < data.Length() && NS_IS_HIGH_SURROGATE(data[aOffset]) && NS_IS_LOW_SURROGATE(data[aOffset + 1])) { ++length; } return DeleteTextTransaction::MaybeCreate(aEditorBase, aCharData, aOffset, length); }