TEST_F(LuaMobileTest, LuaMobileTemplatesTest) { CreatureTemplateManager::DEBUG_MODE = 1; // Verify that all mobiles load ASSERT_EQ(CreatureTemplateManager::instance()->loadTemplates(), 0); // Verify loot group map loads LootGroupMap* lootGroupMap = LootGroupMap::instance(); ASSERT_EQ(lootGroupMap->initialize(), 0); HashTableIterator<uint32, Reference<CreatureTemplate*> > iter = CreatureTemplateManager::instance()->iterator(); while (iter.hasNext()) { CreatureTemplate* creature = iter.next(); std::string templateName( creature->getTemplateName().toCharArray() ); // Verify loot group percentages LootGroupCollection* groupCollection = creature->getLootGroups(); if( groupCollection->count() > 0 ){ for( int i = 0; i < groupCollection->count(); i++ ){ LootGroupCollectionEntry* collectionEntry = groupCollection->get(i); LootGroups* groups = collectionEntry->getLootGroups(); if( groups->count() > 0){ int totalChance = 0; for( int j = 0; j < groups->count(); j++ ){ LootGroupEntry* lootGroup = groups->get(j); totalChance += lootGroup->getLootChance(); // Verify loot group is configured correctly LootGroupTemplate* foundGroup = lootGroupMap->getLootGroupTemplate( lootGroup->getLootGroupName() ); std::string groupName( lootGroup->getLootGroupName().toCharArray() ); EXPECT_TRUE( foundGroup != NULL ) << "Loot group " << groupName << " from " << templateName << " was not found in LootGroupMap"; } EXPECT_EQ( 10000000, totalChance ) << "Loot groups total chance is incorrect " << templateName; } } } // Verify weapon groups exist Vector<String> weapons = creature->getWeapons(); for (int i = 0; i < weapons.size(); i++) { String weaponGroup = weapons.get(i); std::string groupName( weaponGroup.toCharArray() ); Vector<String> group = CreatureTemplateManager::instance()->getWeapons(weaponGroup); EXPECT_TRUE( group.size() > 0 ) << "Weapon group " << groupName << " from " << templateName << " was not found in weaponMap"; } } }
KConfigGroup ScriptApi::config() const { QString groupName("Silk-Script-Api-%1-%2-%3"); groupName = groupName.arg( m_view->name() ).arg( m_gmNameSpace ).arg( m_gmName ); return KGlobal::config()->group( groupName ); }
void XMLModelDefinitionSerializer::readSounds(TiXmlElement* mAnimationsNode, ActionDefinition* action) { const char* tmp = 0; for (TiXmlElement* soundElem = mAnimationsNode->FirstChildElement(); soundElem != 0; soundElem = soundElem->NextSiblingElement()) { tmp = soundElem->Attribute("group"); if (tmp) { std::string groupName(tmp); unsigned int playOrder = 0; tmp = soundElem->Attribute("playOrder"); if (tmp) { std::string playO(tmp); if (playO == "linear") playOrder = 0; else if (playO == "inverse") playOrder = 1; else if (playO == "random") playOrder = 2; } action->createSoundDefinition(groupName, playOrder); S_LOG_VERBOSE( " Add Sound: " << groupName); } } }
bool INDI_D::removeProperty(INDI::Property * prop) { if (prop == NULL) return false; QString groupName(prop->getGroupName()); if (strcmp(prop->getDeviceName(), dv->getDeviceName())) { // qDebug() << "Ignoring property " << prop->getName() << " for device " << prop->getgetDeviceName() << " because our deviec is " // << dv->getDeviceName() << endl; return false; } // qDebug() << "Received new property " << prop->getName() << " for our device " << dv->getDeviceName() << endl; INDI_G * pg = getGroup(groupName); if (pg == NULL) return false; bool removeResult = pg->removeProperty(prop->getName()); if (pg->size() ==0 && removeResult) { //qDebug() << "Removing tab for group " << pg->getName() << " with an index of " << groupsList.indexOf(pg) << endl; groupContainer->removeTab(groupsList.indexOf(pg)); groupsList.removeOne(pg); delete (pg); } return removeResult; }
bool INDI_D::buildProperty(INDI::Property * prop) { QString groupName(prop->getGroupName()); if (strcmp(prop->getDeviceName(), dv->getDeviceName())) { // qDebug() << "Ignoring property " << prop->getName() << " for device " << prop->getgetDeviceName() << " because our deviec is " // << dv->getDeviceName() << endl; return false; } // qDebug() << "Received new property " << prop->getName() << " for our device " << dv->getDeviceName() << endl; INDI_G * pg = getGroup(groupName); if (pg == NULL) { pg = new INDI_G(this, groupName); groupsList.append(pg); groupContainer->addTab(pg->getScrollArea(), i18nc(libindi_strings_context, groupName.toUtf8())); } return pg->addProperty(prop); }
int main(int argc, char* argv[]) { parseArgs(argc, argv); initLogger(argv); UtlString urlString = "https://" + UtlString(xmlrpcServer); Url url(urlString); url.setHostPort(HttpPort); // Delay for 5 minutes // printf("Wating for start of memcheck ...\n"); // OsTask::delay(600000); // printf("Starting memcheck ...\n"); // Test run // while (1) for (int i = 0; i < 10; i++) { XmlRpcRequest* request = new XmlRpcRequest(url, "addExtension"); UtlString groupName("*****@*****.**"); request->addParam(&groupName); UtlString extension("*****@*****.**"); request->addParam(&extension); printf("Sending %d ...", i); XmlRpcResponse response; if (!request->execute(response)) { UtlString reason; int code; response.getFault(&code,reason); printf(" failed\n %d %s\n", code, reason.data() ); } else { printf(" ok\n"); } delete request; request = NULL; // OsTask::delay(2000); } // printf("Done with memcheck ...\n"); // while (1) // { // OsTask::delay(60000); // } return(1); }
void StaffTypePercussion::write(Xml& xml, int idx) const { xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName())); StaffType::writeProperties(xml); if (!genKeysig()) xml.tag("keysig", genKeysig()); if (!showLedgerLines()) xml.tag("ledgerlines", showLedgerLines()); xml.etag(); }
void WorkerContext::databaseExceededQuota(const String&) { #if !PLATFORM(CHROMIUM) // FIXME: This needs a real implementation; this is a temporary solution for testing. const unsigned long long defaultQuota = 5 * 1024 * 1024; #if ENABLE(GROUP_BASED_DATABASE) DatabaseTracker::tracker(groupName()).setQuota(securityOrigin(), defaultQuota); #else DatabaseTracker::tracker().setQuota(securityOrigin(), defaultQuota); #endif #endif }
INT_PTR __cdecl WhatsAppProto::OnCreateGroup(WPARAM wParam, LPARAM lParam) { ENTER_STRING es = { 0 }; es.cbSize = sizeof(es); es.type = ESF_MULTILINE; es.caption = _T("Enter a subject for new group"); es.szModuleName = m_szModuleName; if (EnterString(&es)) { if (isOnline()) { std::string groupName(T2Utf(es.ptszResult)); m_pConnection->sendCreateGroupChat(groupName); } mir_free(es.ptszResult); } return FALSE; }
void PostedGroupItem::fill() { /* fill in */ #ifdef DEBUG_ITEM std::cerr << "PostedGroupItem::fill()"; std::cerr << std::endl; #endif // No link type at this moment RetroShareLink link; link.createGxsGroupLink(RetroShareLink::TYPE_POSTED, mGroup.mMeta.mGroupId, groupName()); ui->nameLabel->setText(link.toHtml()); // ui->nameLabel->setText(groupName()); ui->descLabel->setText(QString::fromUtf8(mGroup.mDescription.c_str())); //TODO - nice icon for subscribed group if (IS_GROUP_PUBLISHER(mGroup.mMeta.mSubscribeFlags)) { ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png")); } else { ui->logoLabel->setPixmap(QPixmap(":/images/posted_64.png")); } if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags)) { ui->subscribeButton->setEnabled(false); } else { ui->subscribeButton->setEnabled(true); } // if (mIsNew) // { ui->titleLabel->setText(tr("New Posted")); // } // else // { // ui->titleLabel->setText(tr("Updated Posted")); // } if (mIsHome) { /* disable buttons */ ui->clearButton->setEnabled(false); } }
QString RDLogLine::resolveWildcards(QString pattern) { pattern.replace("%n",QString().sprintf("%06u",cartNumber())); pattern.replace("%h",QString().sprintf("%d",effectiveLength())); pattern.replace("%g",groupName()); pattern.replace("%t",title()); pattern.replace("%a",artist()); pattern.replace("%l",album()); pattern.replace("%y",year().toString("yyyy")); pattern.replace("%b",label()); pattern.replace("%c",client()); pattern.replace("%e",agency()); pattern.replace("%m",composer()); pattern.replace("%p",publisher()); pattern.replace("%u",userDefined()); return pattern; }
void StaffTypeTablature::write(Xml& xml, int idx) const { xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName())); StaffType::writeProperties(xml); xml.tag("durations", _genDurations); xml.tag("durationFontName", _durationFontName); xml.tag("durationFontSize", _durationFontSize); xml.tag("durationFontY", _durationFontUserY); xml.tag("fretFontName", _fretFontName); xml.tag("fretFontSize", _fretFontSize); xml.tag("fretFontY", _fretFontUserY); xml.tag("linesThrough", _linesThrough); xml.tag("onLines", _onLines); xml.tag("timesig", _genTimesig); xml.tag("upsideDown", _upsideDown); xml.tag("useNumbers", _useNumbers); xml.etag(); }
void StaffTypeTablature::write(Xml& xml, int idx) const { xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName())); StaffType::writeProperties(xml); xml.tag("durations", _genDurations); xml.tag("durationFontName", _durationFonts[_durationFontIdx].displayName); xml.tag("durationFontSize", _durationFontSize); xml.tag("durationFontY", _durationFontUserY); xml.tag("fretFontName", _fretFonts[_fretFontIdx].displayName); xml.tag("fretFontSize", _fretFontSize); xml.tag("fretFontY", _fretFontUserY); xml.tag("linesThrough", _linesThrough); xml.tag("minimStyle", _minimStyle); xml.tag("onLines", _onLines); xml.tag("showRests", _showRests); xml.tag("stemsDown", _stemsDown); xml.tag("stemsThrough", _stemsThrough); xml.tag("upsideDown", _upsideDown); xml.tag("useNumbers", _useNumbers); xml.etag(); }
void WorkspacePresenter::groupWorkspaces() { auto view = lockView(); auto selected = view->getSelectedWorkspaceNames(); std::string groupName("NewGroup"); // get selected workspaces if (selected.size() < 2) { view->showCriticalUserMessage("Cannot Group Workspaces", "Select at least two workspaces to group "); return; } if (m_adapter->doesWorkspaceExist(groupName)) { if (!view->askUserYesNo("", "Workspace " + groupName + " already exists. Do you want to replace it?")) return; } try { std::string algName("GroupWorkspaces"); Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmManager::Instance().create(algName, -1); alg->initialize(); alg->setProperty("InputWorkspaces", selected); alg->setPropertyValue("OutputWorkspace", groupName); // execute the algorithm bool bStatus = alg->execute(); if (!bStatus) { view->showCriticalUserMessage("MantidPlot - Algorithm error", " Error in GroupWorkspaces algorithm"); } } catch (...) { view->showCriticalUserMessage("MantidPlot - Algorithm error", " Error in GroupWorkspaces algorithm"); } }
bool Foam::fileFormats::NASsurfaceFormat<Face>::read ( const fileName& filename ) { const bool mustTriangulate = this->isTri(); this->clear(); IFstream is(filename); if (!is.good()) { FatalErrorIn ( "fileFormats::NASsurfaceFormat::read(const fileName&)" ) << "Cannot read file " << filename << exit(FatalError); } // Nastran index of points DynamicList<label> pointId; DynamicList<point> dynPoints; DynamicList<Face> dynFaces; DynamicList<label> dynZones; DynamicList<label> dynSizes; Map<label> lookup; // assume the types are not intermixed // leave faces that didn't have a group in 0 bool sorted = true; label zoneI = 0; // Name for face group Map<word> nameLookup; // Ansa tags. Denoted by $ANSA_NAME. // These will appear just before the first use of a type. // We read them and store the PSHELL types which are used to name // the zones. label ansaId = -1; word ansaType, ansaName; // A single warning per unrecognized command HashSet<word> unhandledCmd; while (is.good()) { string line; is.getLine(line); // Ansa extension if (line.substr(0, 10) == "$ANSA_NAME") { string::size_type sem0 = line.find (';', 0); string::size_type sem1 = line.find (';', sem0+1); string::size_type sem2 = line.find (';', sem1+1); if ( sem0 != string::npos && sem1 != string::npos && sem2 != string::npos ) { ansaId = readLabel ( IStringStream(line.substr(sem0+1, sem1-sem0-1))() ); ansaType = line.substr(sem1+1, sem2-sem1-1); string rawName; is.getLine(rawName); if (rawName[rawName.size()-1] == '\r') { rawName = rawName.substr(1, rawName.size()-2); } else { rawName = rawName.substr(1, rawName.size()-1); } string::stripInvalid<word>(rawName); ansaName = rawName; // Info<< "ANSA tag for NastranID:" << ansaId // << " of type " << ansaType // << " name " << ansaName << endl; } } // Hypermesh extension // $HMNAME COMP 1"partName" if ( line.substr(0, 12) == "$HMNAME COMP" && line.find ('"') != string::npos ) { label groupId = readLabel ( IStringStream(line.substr(16, 16))() ); IStringStream lineStream(line.substr(32)); string rawName; lineStream >> rawName; string::stripInvalid<word>(rawName); word groupName(rawName); nameLookup.insert(groupId, groupName); // Info<< "group " << groupId << " => " << groupName << endl; } // Skip empty or comment if (line.empty() || line[0] == '$') { continue; } // Check if character 72 is continuation if (line.size() > 72 && line[72] == '+') { line = line.substr(0, 72); while (true) { string buf; is.getLine(buf); if (buf.size() > 72 && buf[72] == '+') { line += buf.substr(8, 64); } else { line += buf.substr(8, buf.size()-8); break; } } } // Read first word IStringStream lineStream(line); word cmd; lineStream >> cmd; if (cmd == "CTRIA3") { triFace fTri; label groupId = readLabel(IStringStream(line.substr(16,8))()); fTri[0] = readLabel(IStringStream(line.substr(24,8))()); fTri[1] = readLabel(IStringStream(line.substr(32,8))()); fTri[2] = readLabel(IStringStream(line.substr(40,8))()); // Convert groupID into zoneId Map<label>::const_iterator fnd = lookup.find(groupId); if (fnd != lookup.end()) { if (zoneI != fnd()) { // pshell types are intermixed sorted = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(groupId, zoneI); dynSizes.append(0); // Info<< "zone" << zoneI << " => group " << groupId <<endl; } dynFaces.append(fTri); dynZones.append(zoneI); dynSizes[zoneI]++; } else if (cmd == "CQUAD4") { face fQuad(4); UList<label>& f = static_cast<UList<label>&>(fQuad); label groupId = readLabel(IStringStream(line.substr(16,8))()); fQuad[0] = readLabel(IStringStream(line.substr(24,8))()); fQuad[1] = readLabel(IStringStream(line.substr(32,8))()); fQuad[2] = readLabel(IStringStream(line.substr(40,8))()); fQuad[3] = readLabel(IStringStream(line.substr(48,8))()); // Convert groupID into zoneId Map<label>::const_iterator fnd = lookup.find(groupId); if (fnd != lookup.end()) { if (zoneI != fnd()) { // pshell types are intermixed sorted = false; } zoneI = fnd(); } else { zoneI = dynSizes.size(); lookup.insert(groupId, zoneI); dynSizes.append(0); // Info<< "zone" << zoneI << " => group " << groupId <<endl; } if (mustTriangulate) { dynFaces.append(triFace(f[0], f[1], f[2])); dynFaces.append(triFace(f[0], f[2], f[3])); dynZones.append(zoneI); dynZones.append(zoneI); dynSizes[zoneI] += 2; } else { dynFaces.append(Face(f)); dynZones.append(zoneI); dynSizes[zoneI]++; } } else if (cmd == "GRID") { label index = readLabel(IStringStream(line.substr(8,8))()); scalar x = parseNASCoord(line.substr(24, 8)); scalar y = parseNASCoord(line.substr(32, 8)); scalar z = parseNASCoord(line.substr(40, 8)); pointId.append(index); dynPoints.append(point(x, y, z)); } else if (cmd == "GRID*") { // Long format is on two lines with '*' continuation symbol // on start of second line. // Typical line (spaces compacted) // GRID* 126 0 -5.55999875E+02 -5.68730474E+02 // * 2.14897901E+02 label index = readLabel(IStringStream(line.substr(8,16))()); scalar x = parseNASCoord(line.substr(40, 16)); scalar y = parseNASCoord(line.substr(56, 16)); is.getLine(line); if (line[0] != '*') { FatalErrorIn ( "fileFormats::NASsurfaceFormat::read(const fileName&)" ) << "Expected continuation symbol '*' when reading GRID*" << " (double precision coordinate) format" << nl << "Read:" << line << nl << "File:" << is.name() << " line:" << is.lineNumber() << exit(FatalError); } scalar z = parseNASCoord(line.substr(8, 16)); pointId.append(index); dynPoints.append(point(x, y, z)); } else if (cmd == "PSHELL") { // pshell type for zone names with the Ansa extension label groupId = readLabel(IStringStream(line.substr(8,8))()); if (groupId == ansaId && ansaType == "PSHELL") { nameLookup.insert(ansaId, ansaName); // Info<< "group " << groupId << " => " << ansaName << endl; } } else if (unhandledCmd.insert(cmd)) { Info<< "Unhandled Nastran command " << line << nl << "File:" << is.name() << " line:" << is.lineNumber() << endl; } }
bool cAlarmServer::loadAlarmData(TiXmlElement* element, cAlarmData* data) { UtlString codeStr; UtlString idStr; UtlString compStr(""); UtlString sevStr("minor"); UtlString resStr(""); UtlString groupName("disabled"); bool actEmail = true; bool actSms = true; bool actLog = true; bool actTrap = true; int filtMax = INT_MAX; int filtMin = 0; if (element && data) { idStr = element->Attribute("id"); if (idStr.isNull()) { OsSysLog::add(FAC_ALARM, PRI_ERR,"code=%s: alarm ID is required", codeStr.data()); return false; } TiXmlElement* codeElement = element->FirstChildElement("code"); if ( !codeElement ) { OsSysLog::add(FAC_ALARM, PRI_ERR, "id=%s: alarm code is required", element->Attribute("id")); return false; } textContentShallow(codeStr, codeElement); codeElement = element->FirstChildElement("severity"); if ( codeElement ) { textContentShallow(sevStr, codeElement); } else { OsSysLog::add(FAC_ALARM, PRI_WARNING, "id=%s: no severity; assuming %s", idStr.data(), sevStr.data()); } codeElement = element->FirstChildElement("component"); if ( codeElement ) { textContentShallow(compStr, codeElement); } else { OsSysLog::add(FAC_ALARM, PRI_WARNING,"id=%s: no component; set to null", idStr.data()); } codeElement = element->FirstChildElement("action"); actLog = getBoolAttribute(codeElement, "log", true); if ( codeElement ) { // Get the alarm group name used for both regular emails and SMS emails. groupName = codeElement->Attribute("email"); if (strcmp(groupName.data(), "disabled") == 0) { // All regular/SMS notifications for this alarm type must be disabled. actEmail = false; actSms = false; actTrap = false; } } codeElement = element->FirstChildElement("filter"); filtMax = getIntAttribute(codeElement, "max_reports", INT_MAX); filtMin = getIntAttribute(codeElement, "min_threshold"); } else { return false; } data->setAlarmId(idStr); data->setCode(codeStr); data->setSeverity(sevToSyslogPri(sevStr)); data->setComponent(compStr); data->setShortTitle(idStr); // default fallback title is internal id data->setDescription(idStr); // default fallback description is internal id data->setResolution(resStr); data->actions[cAlarmData::eActionLog] = actLog; data->actions[cAlarmData::eActionEmail] = actEmail; data->actions[cAlarmData::eActionSms] = actSms; data->actions[cAlarmData::eActionTrap] = actTrap; data->group_name = groupName; data->max_report = filtMax; data->min_threshold = filtMin; data->resetCount(); return true; }
void NotificationWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_NODE_MONITOR: { _LoadSettings(); break; } case kNotificationMessage: { if (!fShouldRun) break; BMessage reply(B_REPLY); BNotification* notification = new BNotification(message); if (notification->InitCheck() == B_OK) { bigtime_t timeout; if (message->FindInt64("timeout", &timeout) != B_OK) timeout = fTimeout; BString sourceSignature(notification->SourceSignature()); BString sourceName(notification->SourceName()); bool allow = false; appfilter_t::iterator it = fAppFilters .find(sourceSignature.String()); AppUsage* appUsage = NULL; if (it == fAppFilters.end()) { if (sourceSignature.Length() > 0 && sourceName.Length() > 0) { appUsage = new AppUsage(sourceName.String(), sourceSignature.String(), true); fAppFilters[sourceSignature.String()] = appUsage; // TODO save back to settings file } allow = true; } else { appUsage = it->second; allow = appUsage->Allowed(); } if (allow) { BString groupName(notification->Group()); appview_t::iterator aIt = fAppViews.find(groupName); AppGroupView* group = NULL; if (aIt == fAppViews.end()) { group = new AppGroupView(this, groupName == "" ? NULL : groupName.String()); fAppViews[groupName] = group; GetLayout()->AddView(group); } else group = aIt->second; NotificationView* view = new NotificationView(notification, timeout, fIconSize); group->AddInfo(view); _ShowHide(); reply.AddInt32("error", B_OK); } else reply.AddInt32("error", B_NOT_ALLOWED); } else { reply.what = B_MESSAGE_NOT_UNDERSTOOD; reply.AddInt32("error", B_ERROR); } message->SendReply(&reply); break; } case kRemoveGroupView: { AppGroupView* view = NULL; if (message->FindPointer("view", (void**)&view) != B_OK) return; // It's possible that between sending this message, and us receiving // it, the view has become used again, in which case we shouldn't // delete it. if (view->HasChildren()) return; // this shouldn't happen if (fAppViews.erase(view->Group()) < 1) break; view->RemoveSelf(); delete view; _ShowHide(); break; } default: BWindow::MessageReceived(message); } }
const char* StaffType::groupName() const { return groupName(_group); }
int InteractivelyCollectAddresses(const wxArrayString& addresses, const String& bookNameOrig, const String& groupNameOrig, wxFrame *parent) { // by default, select all addresses wxArrayInt selections; size_t count = addresses.GetCount(); for ( size_t n = 0; n < count; n++ ) { selections.Add(n); } if ( count > 1 ) { // now ask the user which ones does he really want count = MDialog_GetSelections ( _("Please select the addresses to save"), _("Save addresses"), addresses, &selections, parent, _T("AddrExtract") ); } //else: don't ask the user to choose when there is one address only if ( count > 0 ) { // ask the user for the book and group names to use // // TODO propose something better - ADB tree dialog for example wxString bookName(bookNameOrig), groupName(groupNameOrig); if ( MDialog_GetText2FromUser ( _("Please select the location in the address\n" "book to save the selected entries to:"), _("Save addresses"), _("Address book name:"), &bookName, _("Group name:"), &groupName, parent ) ) { AdbManager_obj manager; CHECK( manager, -1, _T("can't get AdbManager") ); AdbBook_obj autocollectbook(manager->CreateBook(bookName)); if ( !autocollectbook ) { wxLogError(_("Failed to create the address book '%s' " "for autocollected e-mail addresses."), bookName.c_str()); // TODO ask the user for another book name return -1; } AdbEntryGroup_obj group(autocollectbook->CreateGroup(groupName)); if ( !group ) { wxLogError(_("Failed to create group '%s' in the address " "book '%s'."), groupName.c_str(), bookName.c_str()); return -1; } // create all entries in this group size_t saved = 0; for ( size_t n = 0; n < count; n++ ) { AddressList_obj addrList(addresses[selections[n]]); for ( Address *addr = addrList->GetFirst(); addr; addr = addrList->GetNext(addr) ) { String name = addr->GetName(), email = addr->GetEMail(); if ( name.empty() || name == email ) { name = addr->GetMailbox(); } AdbEntry_obj entry(group->CreateEntry(name)); entry->SetField(AdbField_NickName, name); entry->SetField(AdbField_FullName, name); entry->SetField(AdbField_EMail, email); saved++; } } wxLogStatus(parent, _("Saved %u addresses."), saved); } //else: cancelled } else // cancelled by user or nothing selected { wxLogStatus(parent, _("No addresses to save.")); } return count; }
void StaffType::write(Xml& xml, int idx) const { xml.stag(QString("StaffType idx=\"%1\" group=\"%2\"").arg(idx).arg(groupName())); writeProperties(xml); xml.etag(); }
void GxsChannelPostItem::fill() { /* fill in */ if (isLoading()) { /* Wait for all requests */ return; } #ifdef DEBUG_ITEM std::cerr << "GxsChannelPostItem::fill()"; std::cerr << std::endl; #endif mInFill = true; QString title; if (!mIsHome) { if (mCloseOnRead && !IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { removeItem(); } title = tr("Channel Feed") + ": "; RetroShareLink link; link.createGxsGroupLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, groupName()); title += link.toHtml(); ui->titleLabel->setText(title); RetroShareLink msgLink; msgLink.createGxsMessageLink(RetroShareLink::TYPE_CHANNEL, mPost.mMeta.mGroupId, mPost.mMeta.mMsgId, messageName()); ui->subjectLabel->setText(msgLink.toHtml()); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->unsubscribeButton->setEnabled(true); } else { ui->unsubscribeButton->setEnabled(false); } ui->readButton->hide(); ui->newLabel->hide(); ui->copyLinkButton->hide(); if (IS_MSG_NEW(mPost.mMeta.mMsgStatus)) { mCloseOnRead = true; } } else { /* subject */ ui->titleLabel->setText(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); ui->subjectLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); //QString score = QString::number(post.mTopScore); // scoreLabel->setText(score); /* disable buttons: deletion facility not enabled with cache services yet */ ui->clearButton->setEnabled(false); ui->unsubscribeButton->setEnabled(false); ui->clearButton->hide(); ui->readAndClearButton->hide(); ui->unsubscribeButton->hide(); ui->copyLinkButton->show(); if (IS_GROUP_SUBSCRIBED(mGroup.mMeta.mSubscribeFlags) || IS_GROUP_ADMIN(mGroup.mMeta.mSubscribeFlags)) { ui->readButton->setVisible(true); setReadStatus(IS_MSG_NEW(mPost.mMeta.mMsgStatus), IS_MSG_UNREAD(mPost.mMeta.mMsgStatus) || IS_MSG_NEW(mPost.mMeta.mMsgStatus)); } else { ui->readButton->setVisible(false); ui->newLabel->setVisible(false); } mCloseOnRead = false; } // differences between Feed or Top of Comment. if (mFeedHolder) { if (mIsHome) { ui->commentButton->show(); } else { ui->commentButton->hide(); } // THIS CODE IS doesn't compile - disabling until fixed. #if 0 if (post.mComments) { QString commentText = QString::number(post.mComments); commentText += " "; commentText += tr("Comments"); ui->commentButton->setText(commentText); } else { ui->commentButton->setText(tr("Comment")); } #endif } else { ui->commentButton->hide(); } // disable voting buttons - if they have already voted. /*if (post.mMeta.mMsgStatus & GXS_SERV::GXS_MSG_STATUS_VOTE_MASK) { voteUpButton->setEnabled(false); voteDownButton->setEnabled(false); }*/ ui->msgLabel->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mMsg.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->msgFrame->setVisible(!mPost.mMsg.empty()); ui->datetimelabel->setText(DateTime::formatLongDateTime(mPost.mMeta.mPublishTs)); ui->filelabel->setText(QString("(%1 %2) %3").arg(mPost.mCount).arg(tr("Files")).arg(misc::friendlyUnit(mPost.mSize))); if (mFileItems.empty() == false) { std::list<SubFileItem *>::iterator it; for(it = mFileItems.begin(); it != mFileItems.end(); ++it) { delete(*it); } mFileItems.clear(); } std::list<RsGxsFile>::const_iterator it; for(it = mPost.mFiles.begin(); it != mPost.mFiles.end(); ++it) { /* add file */ std::string path; SubFileItem *fi = new SubFileItem(it->mHash, it->mName, path, it->mSize, SFI_STATE_REMOTE | SFI_TYPE_CHANNEL, RsPeerId()); mFileItems.push_back(fi); /* check if the file is a media file */ if (!misc::isPreviewable(QFileInfo(QString::fromUtf8(it->mName.c_str())).suffix())) { fi->mediatype(); /* check if the file is not a media file and change text */ ui->playButton->setText(tr("Open")); ui->playButton->setToolTip(tr("Open File")); } else { ui->playButton->setText(tr("Play")); ui->playButton->setToolTip(tr("Play Media")); } QLayout *layout = ui->expandFrame->layout(); layout->addWidget(fi); } if(mPost.mThumbnail.mData != NULL) { QPixmap thumbnail; thumbnail.loadFromData(mPost.mThumbnail.mData, mPost.mThumbnail.mSize, "PNG"); // Wiping data - as its been passed to thumbnail. ui->logoLabel->setPixmap(thumbnail); } mInFill = false; }
QString RDLogLine::xml(int line) const { QString ret; #ifndef WIN32 ret+=" <logLine>\n"; ret+=" "+RDXmlField("line",line); ret+=" "+RDXmlField("id",id()); ret+=" "+RDXmlField("type",RDLogLine::typeText(type())); ret+=" "+RDXmlField("cartType",RDCart::typeText(cartType())); ret+=" "+RDXmlField("cartNumber",cartNumber()); ret+=" "+RDXmlField("cutNumber",cutNumber()); ret+=" "+RDXmlField("groupName",groupName()); ret+=" "+RDXmlField("groupColor",groupColor().name()); ret+=" "+RDXmlField("title",title()); ret+=" "+RDXmlField("artist",artist()); ret+=" "+RDXmlField("publisher",publisher()); ret+=" "+RDXmlField("composer",composer()); ret+=" "+RDXmlField("album",album()); ret+=" "+RDXmlField("label",label()); if(year().isValid()) { ret+=" "+RDXmlField("year",year().year()); } else { ret+=" "+RDXmlField("year"); } ret+=" "+RDXmlField("client",client()); ret+=" "+RDXmlField("agency",agency()); ret+=" "+RDXmlField("userDefined",userDefined()); ret+=" "+RDXmlField("usageCode",usageCode()); ret+=" "+RDXmlField("enforceLength",enforceLength()); ret+=" "+RDXmlField("forcedLength",RDGetTimeLength(forcedLength(),true)); ret+=" "+RDXmlField("evergreen",evergreen()); ret+=" "+RDXmlField("source",RDLogLine::sourceText(source())); ret+=" "+RDXmlField("timeType",RDLogLine::timeTypeText(timeType())); if(startTime(RDLogLine::Logged).isValid()&& (!startTime(RDLogLine::Logged).isNull())) { ret+=" "+RDXmlField("startTime",startTime(RDLogLine::Logged). toString("hh:mm:ss.zzz")); } else { ret+=" "+RDXmlField("startTime"); } ret+=" "+RDXmlField("transitionType",RDLogLine::transText(transType())); ret+=" "+RDXmlField("cutQuantity",cutQuantity()); ret+=" "+RDXmlField("lastCutPlayed",lastCutPlayed()); ret+=" "+RDXmlField("markerComment",markerComment()); ret+=" "+RDXmlField("markerLabel",markerLabel()); ret+=" "+RDXmlField("originUser",originUser()); ret+=" "+RDXmlField("originDateTime",originDateTime()); ret+=" "+RDXmlField("startPoint",startPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("startPoint",startPoint(RDLogLine::LogPointer), "src=\"log\""); ret+=" "+RDXmlField("endPoint",endPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("endPoint",endPoint(RDLogLine::LogPointer), "src=\"log\""); ret+=" "+RDXmlField("segueStartPoint", segueStartPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("segueStartPoint", segueStartPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("segueEndPoint", segueEndPoint(RDLogLine::CartPointer), "src=\"cart\""); ret+=" "+RDXmlField("segueEndPoint", segueEndPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("segueGain",segueGain()); ret+=" "+RDXmlField("fadeupPoint", fadeupPoint(RDLogLine::CartPointer),"src=\"cart\""); ret+=" "+RDXmlField("fadeupPoint", fadeupPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("fadeupGain",fadeupGain()); ret+=" "+RDXmlField("fadedownPoint", fadedownPoint(RDLogLine::CartPointer),"src=\"cart\""); ret+=" "+RDXmlField("fadedownPoint", fadedownPoint(RDLogLine::LogPointer),"src=\"log\""); ret+=" "+RDXmlField("duckUpGain",duckUpGain()); ret+=" "+RDXmlField("duckDownGain",duckDownGain()); ret+=" "+RDXmlField("talkStartPoint",talkStartPoint()); ret+=" "+RDXmlField("talkEndPoint",talkEndPoint()); ret+=" "+RDXmlField("hookMode",hookMode()); ret+=" "+RDXmlField("hookStartPoint",hookStartPoint()); ret+=" "+RDXmlField("hookEndPoint",hookEndPoint()); ret+=" </logLine>\n"; #endif // WIN32 return ret; }
// MilkShape 3D void ExportMS3D_M2(Attachment *att, Model *m, const char *fn, bool init) { wxFFileOutputStream f(wxString(fn, wxConvUTF8), wxT("w+b")); if (!f.IsOk()) { wxLogMessage(wxT("Error: Unable to open file '%s'. Could not export model."), fn); return; } LogExportData(wxT("MS3D"),m->modelname,wxString(fn, wxConvUTF8)); unsigned short numVerts = 0; unsigned short numFaces = 0; unsigned short numGroups = 0; ModelData *verts = NULL; GroupData *groups = NULL; //we need the initial position anyway InitCommon(att, true, verts, groups, numVerts, numGroups, numFaces); //wxLogMessage(wxT("Num Verts: %i, Num Faces: %i, Num Groups: %i"), numVerts, numFaces, numGroups); //wxLogMessage(wxT("Vert[0] BoneID: %i, Group[0].m.name = %s"),verts[0].boneid, groups[0].m->name); wxLogMessage(wxT("Init Common Complete.")); // Write the header ms3d_header_t header; strncpy(header.id, "MS3D000000", sizeof(header.id)); header.version = 4; // Header f.Write(reinterpret_cast<char *>(&header), sizeof(ms3d_header_t)); wxLogMessage(wxT("Header Data Written.")); // Vertex Count f.Write(reinterpret_cast<char *>(&numVerts), sizeof(numVerts)); //wxLogMessage(wxT("NumVerts: %i"),numVerts); // Write Vertex data? for (size_t i=0; i<numVerts; i++) { ms3d_vertex_t vert; vert.boneId = verts[i].boneid; vert.flags = 0; //SELECTED; vert.referenceCount = 0; // what the? vert.vertex[0] = verts[i].vertex.x; vert.vertex[1] = verts[i].vertex.y; vert.vertex[2] = verts[i].vertex.z; f.Write(reinterpret_cast<char *>(&vert), sizeof(ms3d_vertex_t)); } wxLogMessage(wxT("Vertex Data Written.")); // --------------------------- // Triangle Count f.Write(reinterpret_cast<char *>(&numFaces), sizeof(numFaces)); //wxLogMessage(wxT("NumFaces: %i"),numFaces); // Write Triangle Data? for (size_t i=0; i<(unsigned int)numVerts; i+=3) { ms3d_triangle_t tri; tri.flags = 0; //SELECTED; tri.groupIndex = (unsigned char)verts[i].groupIndex; tri.smoothingGroup = 1; // 1 - 32 for (ssize_t j=0; j<3; j++) { tri.vertexIndices[j] = (word)i+j; tri.s[j] = verts[i+j].tu; tri.t[j] = verts[i+j].tv; tri.vertexNormals[j][0] = verts[i+j].normal.x; tri.vertexNormals[j][1] = verts[i+j].normal.y; tri.vertexNormals[j][2] = verts[i+j].normal.z; } f.Write(reinterpret_cast<char *>(&tri), sizeof(ms3d_triangle_t)); } wxLogMessage(wxT("Triangle Data Written.")); // --------------------------- // Number of groups f.Write(reinterpret_cast<char *>(&numGroups), sizeof(numGroups)); //wxLogMessage(wxT("NumGroups: %i"),numGroups); unsigned short indiceCount = 0; for (unsigned short i=0; i<(unsigned int)numGroups; i++) { wxString groupName(wxString::Format(wxT("Geoset_%i"), i)); const char flags = 0; // SELECTED f.Write(&flags, sizeof(flags)); char name[32]; strncpy(name, groupName.mb_str(), sizeof(name)); f.Write(name, sizeof(name)); unsigned short faceCount = groups[i].p.indexCount / 3; f.Write(reinterpret_cast<char *>(&faceCount), sizeof(faceCount)); for (ssize_t k=0; k<faceCount; k++) { //triIndices[k] = indiceCount; f.Write(reinterpret_cast<char *>(&indiceCount), sizeof(indiceCount)); indiceCount++; } unsigned char gIndex = (char)i; f.Write(reinterpret_cast<char *>(&gIndex), sizeof(gIndex)); } wxLogMessage(wxT("Group Data Written.")); // Number of materials (pretty much identical to groups, each group has its own material) f.Write(reinterpret_cast<char *>(&numGroups), sizeof(numGroups)); for (unsigned short i=0; i<(unsigned int)numGroups; i++) { wxString matName(wxString::Format(wxT("Material_%i"), i)); ModelRenderPass p = groups[i].p; if (p.init(groups[i].m)) { ms3d_material_t mat; memset(mat.alphamap, '\0', sizeof(mat.alphamap)); strncpy(mat.name, matName.mb_str(), sizeof(mat.name)); mat.ambient[0] = 0.7f; mat.ambient[1] = 0.7f; mat.ambient[2] = 0.7f; mat.ambient[3] = 1.0f; mat.diffuse[0] = p.ocol.x; mat.diffuse[1] = p.ocol.y; mat.diffuse[2] = p.ocol.z; mat.diffuse[3] = p.ocol.w; mat.specular[0] = 0.0f; mat.specular[1] = 0.0f; mat.specular[2] = 0.0f; mat.specular[3] = 1.0f; mat.emissive[0] = p.ecol.x; mat.emissive[1] = p.ecol.y; mat.emissive[2] = p.ecol.z; mat.emissive[3] = p.ecol.w; mat.transparency = p.ocol.w; if (p.useEnvMap) { mat.shininess = 30.0f; mat.mode = 1; } else { mat.shininess = 0.0f; mat.mode = 0; } /* unsigned int bindtex = 0; if (groups[i].m->specialTextures[p.tex]==-1) bindtex = groups[i].m->textures[p.tex]; else bindtex = groups[i].m->replaceTextures[groups[i].m->specialTextures[p.tex]]; */ wxString texName = GetM2TextureName(m,p,i); texName << wxT(".tga"); strncpy(mat.texture, texName.mb_str(), sizeof(mat.texture)); f.Write(reinterpret_cast<char *>(&mat), sizeof(ms3d_material_t)); wxString texFilename(fn, wxConvUTF8); texFilename = texFilename.BeforeLast(SLASH); texFilename += SLASH; texFilename += texName; wxLogMessage(wxT("Exporting Image: %s"),texFilename.c_str()); SaveTexture(texFilename); } } wxLogMessage(wxT("Material Data Written.")); if (init) { float fps = 1.0f; float fCurTime = 0.0f; int totalFrames = 0; f.Write(reinterpret_cast<char *>(&fps), sizeof(fps)); f.Write(reinterpret_cast<char *>(&fCurTime), sizeof(fCurTime)); f.Write(reinterpret_cast<char *>(&totalFrames), sizeof(totalFrames)); // number of joints unsigned short numJoints = 0; f.Write(reinterpret_cast<char *>(&numJoints), sizeof(numJoints)); } else { float fps = 25.0f; float fCurTime = 0.0f; int totalFrames = ceil((m->anims[m->anim].timeEnd - m->anims[m->anim].timeStart) / 1000.0f * fps); f.Write(reinterpret_cast<char *>(&fps), sizeof(fps)); f.Write(reinterpret_cast<char *>(&fCurTime), sizeof(fCurTime)); f.Write(reinterpret_cast<char *>(&totalFrames), sizeof(totalFrames)); // number of joints unsigned short numJoints = (unsigned short)m->header.nBones; f.Write(reinterpret_cast<char *>(&numJoints), sizeof(numJoints)); for (size_t i=0; i<numJoints; i++) { ms3d_joint_t joint; int parent = m->bones[i].parent; joint.flags = 0; // SELECTED memset(joint.name, '\0', sizeof(joint.name)); snprintf(joint.name, sizeof(joint.name), "Bone_%i", i); memset(joint.parentName, '\0', sizeof(joint.parentName)); if (parent != -1) snprintf(joint.parentName, sizeof(joint.parentName), "Bone_%i", parent); joint.rotation[0] = 0; joint.rotation[1] = 0; joint.rotation[2] = 0; Vec3D p = FixPivot(m, (int)i, m->bones[i].pivot); joint.position[0] = p.x; joint.position[1] = p.y; joint.position[2] = p.z; joint.numKeyFramesRot = (unsigned short)m->bones[i].rot.data[m->anim].size(); joint.numKeyFramesTrans = (unsigned short)m->bones[i].trans.data[m->anim].size(); f.Write(reinterpret_cast<char *>(&joint), sizeof(ms3d_joint_t)); if (joint.numKeyFramesRot > 0) { ms3d_keyframe_rot_t *keyFramesRot = new ms3d_keyframe_rot_t[joint.numKeyFramesRot]; for (size_t j=0; j<joint.numKeyFramesRot; j++) { keyFramesRot[j].time = m->bones[i].rot.times[m->anim][j] / 1000.0f; Vec3D euler = QuatToEuler(m->bones[i].rot.data[m->anim][j]); keyFramesRot[j].rotation[0] = euler.x; keyFramesRot[j].rotation[1] = euler.y; keyFramesRot[j].rotation[2] = euler.z; } f.Write(reinterpret_cast<char *>(keyFramesRot), sizeof(ms3d_keyframe_rot_t) * joint.numKeyFramesRot); wxDELETEA(keyFramesRot); } if (joint.numKeyFramesTrans > 0) { ms3d_keyframe_pos_t *keyFramesTrans = new ms3d_keyframe_pos_t[joint.numKeyFramesTrans]; for (size_t j=0; j<joint.numKeyFramesTrans; j++) { keyFramesTrans[j].time = m->bones[i].trans.times[m->anim][j] / 1000.0f; keyFramesTrans[j].position[0] = m->bones[i].trans.data[m->anim][j].x; keyFramesTrans[j].position[1] = m->bones[i].trans.data[m->anim][j].y; keyFramesTrans[j].position[2] = m->bones[i].trans.data[m->anim][j].z; } f.Write(reinterpret_cast<char *>(keyFramesTrans), sizeof(ms3d_keyframe_pos_t) * joint.numKeyFramesTrans); wxDELETEA(keyFramesTrans); } } } f.Close(); wxLogMessage(wxT("Finished Milkshape Export.")); if (verts){ //wxLogMessage("verts found. Deleting..."); wxDELETEA(verts); } if (groups){ //wxLogMessage("groups found. Deleting..."); wxDELETEA(groups); } //wxLogMessage(wxT("Finished Milkshape Cleanup.\n")); }
TEST_F(LuaMobileTest, LuaMobileTemplatesTest) { CreatureTemplateManager::DEBUG_MODE = 1; // Verify that all mobiles load ASSERT_EQ(CreatureTemplateManager::instance()->loadTemplates(), 0); // Verify loot group map loaded ASSERT_EQ(LootGroupMap::ERROR_CODE, 0); // Verify factions load FactionManager::instance()->loadData(); ASSERT_FALSE(FactionManager::instance()->getFactionMap()->isEmpty()); // Load Templates ASSERT_TRUE( TemplateManager::instance() != NULL ); if( TemplateManager::instance()->loadedTemplatesCount == 0 ){ TemplateManager::instance()->loadLuaTemplates(); ASSERT_EQ(TemplateManager::ERROR_CODE, 0); } // verify DNA manager loads DnaManager::instance()->loadSampleData(); ASSERT_TRUE( DnaManager::instance() != NULL); // Test Creature Templates HashTableIterator<uint32, Reference<CreatureTemplate*> > creatureIterator = CreatureTemplateManager::instance()->iterator(); while (creatureIterator.hasNext()) { CreatureTemplate* creature = creatureIterator.next(); std::string templateName( creature->getTemplateName().toCharArray() ); //Verify non-empty objectName is a valid string String objName = creature->getObjectName(); if (!objName.isEmpty()) { std::string name = objName.toCharArray(); EXPECT_TRUE( mobNames.contains(objName) ) << "Mobile " << templateName << " has invalid objectName: " << name; } // Check configured templates Vector<String> objTemps = creature->getTemplates(); EXPECT_FALSE( objTemps.isEmpty() ) << "Mobile " << templateName << " does not have any templates configured"; int objectType = 0; for( int j=0; j< objTemps.size(); j++ ){ SharedObjectTemplate* templateData = templateManager->getTemplate(objTemps.get(j).hashCode()); std::string objName = objTemps.get(j).toCharArray(); EXPECT_TRUE( templateData != NULL ) << "Mobile " << templateName << " has invalid template configured: " << objName; // Check Template Genetics math to find invalid mobs if (templateData != NULL) { SharedCreatureObjectTemplate* creoData = dynamic_cast<SharedCreatureObjectTemplate*> (templateData); if (creoData != NULL) { } } if (objectType == 0) { objectType = templateData->getGameObjectType(); } } // Verify that control device template is valid String controlDeviceTemplate = creature->getControlDeviceTemplate(); if (!controlDeviceTemplate.isEmpty()) { SharedObjectTemplate* controlDeviceTemplateData = templateManager->getTemplate(controlDeviceTemplate.hashCode()); EXPECT_TRUE( controlDeviceTemplateData != NULL ) << "Control device template " << controlDeviceTemplate.toCharArray() << " from " << templateName << " does not exist."; EXPECT_TRUE( controlDeviceTemplate.beginsWith("object/intangible/pet/") ) << "Control device template " << controlDeviceTemplate.toCharArray() << " from " << templateName << " is not a pet/droid control device template."; } // Verify that faction is valid String faction = creature->getFaction(); if (!faction.isEmpty()) { EXPECT_TRUE( FactionManager::instance()->isFaction(faction) ) << "Faction, " << faction.toCharArray() << ", from mobile template " << templateName << " does not exist."; } // Verify level int level = creature->getLevel(); EXPECT_TRUE( level > 0 ) << "Level is not a positive value on mobile: " << templateName; // Verify hit chance float hitChance = creature->getChanceHit(); EXPECT_TRUE( hitChance > 0 ) << "ChanceHit is not a positive value on mobile: " << templateName; // Verify xp int xp = creature->getBaseXp(); EXPECT_TRUE( xp >= 0 ) << "Xp has a negative value on mobile: " << templateName; // Verify damage int minDamage = creature->getDamageMin(); int maxDamage = creature->getDamageMax(); EXPECT_TRUE( minDamage > 0 ) << "Min damage is not a positive value on mobile: " << templateName; EXPECT_TRUE( maxDamage >= minDamage ) << "Max damage is lower than min damage on mobile: " << templateName; // Verify HAM int minHam = creature->getBaseHAM(); int maxHam = creature->getBaseHAMmax(); EXPECT_TRUE( minHam > 0 ) << "Base ham is not a positive value on mobile: " << templateName; EXPECT_TRUE( maxHam >= minHam ) << "Base ham max is lower than base ham on mobile: " << templateName; // Verify armor int armor = creature->getArmor(); EXPECT_TRUE( armor >= 0 && armor <= 3 ) << "Armor is not a valid value on mobile: " << templateName; // Verify resists float kinetic = creature->getKinetic(); EXPECT_TRUE( kinetic >= -1 && kinetic <= 200 ) << "Kinetic resist is not a valid value on mobile: " << templateName; float energy = creature->getEnergy(); EXPECT_TRUE( energy >= -1 && energy <= 200 ) << "Energy resist is not a valid value on mobile: " << templateName; float electricity = creature->getElectricity(); EXPECT_TRUE( electricity >= -1 && electricity <= 200 ) << "Electricity resist is not a valid value on mobile: " << templateName; float stun = creature->getStun(); EXPECT_TRUE( stun >= -1 && stun <= 200 ) << "Stun resist is not a valid value on mobile: " << templateName; float blast = creature->getBlast(); EXPECT_TRUE( blast >= -1 && blast <= 200 ) << "Blast resist is not a valid value on mobile: " << templateName; float heat = creature->getHeat(); EXPECT_TRUE( heat >= -1 && heat <= 200 ) << "Heat resist is not a valid value on mobile: " << templateName; float cold = creature->getCold(); EXPECT_TRUE( cold >= -1 && cold <= 200 ) << "Cold resist is not a valid value on mobile: " << templateName; float acid = creature->getAcid(); EXPECT_TRUE( acid >= -1 && acid <= 200 ) << "Acid resist is not a valid value on mobile: " << templateName; float lightSaber = creature->getLightSaber(); EXPECT_TRUE( lightSaber >= -1 && lightSaber <= 200 ) << "LightSaber resist is not a valid value on mobile: " << templateName; // Verify creature resources String meat = creature->getMeatType(); float meatMax = creature->getMeatMax(); if (!meat.isEmpty()) { String meatResources = "meat_domesticated,meat_wild,meat_herbivore,meat_carnivore,meat_reptilian,meat_avian,meat_insect"; StringTokenizer tokenizer(meatResources); tokenizer.setDelimeter(","); bool match = false; String token; while (tokenizer.hasMoreTokens()) { tokenizer.getStringToken(token); if (meat == token) match = true; } EXPECT_TRUE( match ) << "Meat type on mobile " << templateName << " is not a valid meat resource"; EXPECT_TRUE( meatMax > 0 ) << "Meat amount on mobile " << templateName << " is zero."; } else { EXPECT_TRUE( meatMax == 0 ) << "MeatAmount is not zero yet has no type defined on mobile " << templateName; } String hide = creature->getHideType(); float hideMax = creature->getHideMax(); if (!hide.isEmpty()) { String hideResources = "hide_bristley,hide_leathery,hide_scaley,hide_wooly"; StringTokenizer tokenizer(hideResources); tokenizer.setDelimeter(","); bool match = false; String token; while (tokenizer.hasMoreTokens()) { tokenizer.getStringToken(token); if (hide == token) match = true; } EXPECT_TRUE( match ) << "Hide type on mobile " << templateName << " is not a valid hide resource"; EXPECT_TRUE( hideMax > 0 ) << "Hide amount on mobile " << templateName << " is zero."; } else { EXPECT_TRUE( hideMax == 0 ) << "HideAmount is not zero yet has no type defined on mobile " << templateName; } String bone = creature->getBoneType(); float boneMax = creature->getBoneMax(); if (!bone.isEmpty()) { String boneResources = "bone_avian,bone_mammal"; StringTokenizer tokenizer(boneResources); tokenizer.setDelimeter(","); bool match = false; String token; while (tokenizer.hasMoreTokens()) { tokenizer.getStringToken(token); if (bone == token) match = true; } EXPECT_TRUE( match ) << "Bone type on mobile " << templateName << " is not a valid bone resource"; EXPECT_TRUE( boneMax > 0 ) << "Bone amount on mobile " << templateName << " is zero."; } else { EXPECT_TRUE( boneMax == 0 ) << "BoneAmount is not zero yet has no type defined on mobile " << templateName; } String milk = creature->getMilkType(); float milkMax = creature->getMilk(); if (!milk.isEmpty()) { String milkResources = "milk_domesticated,milk_wild"; StringTokenizer tokenizer(milkResources); tokenizer.setDelimeter(","); bool match = false; String token; while (tokenizer.hasMoreTokens()) { tokenizer.getStringToken(token); if (milk == token) match = true; } EXPECT_TRUE( match ) << "Milk type on mobile " << templateName << " is not a valid milk resource"; EXPECT_TRUE( milkMax > 0 ) << "Milk amount on mobile " << templateName << " is zero."; } else { EXPECT_TRUE( milkMax == 0 ) << "Milk is not zero yet has no type defined on mobile " << templateName; } // Verify taming chance float tamingChance = creature->getTame(); EXPECT_TRUE( tamingChance >= 0 && tamingChance <= 1 ) << "Taming chance is not a valid value on mobile: " << templateName; // Verify diet on creatures if (boneMax > 0 || hideMax > 0 || meatMax > 0 || milkMax > 0 || tamingChance > 0) { uint32 diet = creature->getDiet(); EXPECT_TRUE( diet != 0 ) << "Diet is NONE on creature type mobile " << templateName; } // Verify scale float scale = creature->getScale(); EXPECT_TRUE( scale > 0 ) << "Scale is not a positive value on mobile: " << templateName; // Verify PACK mobs have a social group uint32 creatureBitmask = creature->getCreatureBitmask(); String socialGroup = creature->getSocialGroup(); if (creatureBitmask & CreatureFlag::PACK) { EXPECT_FALSE( socialGroup.isEmpty() ) << "Social group is empty on pack mobile: " << templateName; } // Verify loot group percentages LootGroupCollection* groupCollection = creature->getLootGroups(); if( groupCollection->count() > 0 ){ for( int i = 0; i < groupCollection->count(); i++ ){ LootGroupCollectionEntry* collectionEntry = groupCollection->get(i); LootGroups* groups = collectionEntry->getLootGroups(); if( groups->count() > 0){ int totalChance = 0; for( int j = 0; j < groups->count(); j++ ){ LootGroupEntry* lootGroup = groups->get(j); totalChance += lootGroup->getLootChance(); // Verify loot group is configured correctly LootGroupTemplate* foundGroup = lootGroupMap->getLootGroupTemplate( lootGroup->getLootGroupName() ); std::string groupName( lootGroup->getLootGroupName().toCharArray() ); EXPECT_TRUE( foundGroup != NULL ) << "Loot group " << groupName << " from " << templateName << " was not found in LootGroupMap"; } EXPECT_EQ( 10000000, totalChance ) << "Loot groups total chance is incorrect " << templateName; } } } // Verify weapon groups exist Vector<String> weapons = creature->getWeapons(); for (int i = 0; i < weapons.size(); i++) { String weaponGroup = weapons.get(i); std::string groupName( weaponGroup.toCharArray() ); Vector<String> group = CreatureTemplateManager::instance()->getWeapons(weaponGroup); EXPECT_TRUE( group.size() > 0 ) << "Weapon group " << groupName << " from " << templateName << " was not found in weaponMap"; } // Verify conversation template exist, and the mob has converse option bit uint32 convoTemplate = creature->getConversationTemplate(); uint32 optionsBitmask = creature->getOptionsBitmask(); if (convoTemplate != 0) { ConversationTemplate* convoTemp = CreatureTemplateManager::instance()->getConversationTemplate(convoTemplate); EXPECT_TRUE( convoTemp != NULL ) << "Conversation template from " << templateName << " was not found."; EXPECT_TRUE( optionsBitmask & OptionBitmask::CONVERSE ) << templateName << " has a convo template but not the CONVERSE options bit."; } // Verify that mobs with converse option bit have a convo template if (optionsBitmask & OptionBitmask::CONVERSE) { EXPECT_TRUE( convoTemplate != 0 ) << templateName << " has the CONVERSE options bit but not a convo template."; } // Verify that outfits exist String outfit = creature->getOutfit(); if (!outfit.isEmpty()) { MobileOutfitGroup* outfitGroup = CreatureTemplateManager::instance()->getMobileOutfitGroup(outfit); EXPECT_TRUE( outfitGroup != NULL ) << "Outfit group " << outfit.toCharArray() << " from " << templateName << " was not found."; } // Verify attacks are valid commands CreatureAttackMap* cam = creature->getAttacks(); for (int i = 0; i < cam->size(); i++) { String commandName = cam->getCommand(i); EXPECT_TRUE( commandName.isEmpty() || commandConfigManager->contains(commandName) ) << "Attack: " << commandName.toCharArray() << " is not a valid command in mobile template: " << templateName; } // Very attackable npcs uint32 pvpBitmask = creature->getPvpBitmask(); if ((pvpBitmask & CreatureFlag::ATTACKABLE) && objectType == 1025) { // Verify attackable npcs have attacks EXPECT_TRUE( cam->size() > 0 ) << "Attackable npc " << templateName << " does not have attacks."; } } // Test Lair Templates HashTableIterator<uint32, Reference<LairTemplate*> > lairIterator = CreatureTemplateManager::instance()->lairTemplateIterator(); while (lairIterator.hasNext()) { LairTemplate* lair = lairIterator.next(); std::string templateName( lair->getName().toCharArray() ); // Verify that mobiles exist and that their weighting is positive VectorMap<String, int>* mobiles = lair->getMobiles(); for (int i = 0; i < mobiles->size(); i++) { int weighting = mobiles->elementAt(i).getValue(); String mobile = mobiles->elementAt(i).getKey(); std::string mobName = mobile.toCharArray(); EXPECT_TRUE( CreatureTemplateManager::instance()->getTemplate(mobile) != NULL ) << "Mobile " << mobName << " in lair template " << templateName << " does not exist"; EXPECT_TRUE( weighting > 0 ) << "Mobile " << mobName << " in lair template " << templateName << " has a non positive weighting"; } // Verify that boss mobiles exist and that their count is positive VectorMap<String, int>* bossMobiles = lair->getBossMobiles(); for (int i = 0; i < bossMobiles->size(); i++) { int count = bossMobiles->elementAt(i).getValue(); String bossMob = bossMobiles->elementAt(i).getKey(); std::string bossName = bossMob.toCharArray(); EXPECT_TRUE( CreatureTemplateManager::instance()->getTemplate(bossMob) != NULL ) << "Boss mobile " << bossName << " in lair template " << templateName << " does not exist"; EXPECT_TRUE( count > 0 ) << "Boss mobile " << bossName << " in lair template " << templateName << " has a non positive spawn count"; } // Verify spawn limit is positive int limit = lair->getSpawnLimit(); EXPECT_TRUE( limit > 0 ) << "Spawn limit in lair template " << templateName << " is not positive"; // Verify any configured buildings exist int buildingCount = 0; for(int i=0; i<=4; i++){ Vector<String>* buildings = lair->getBuildings( i ); if( buildings == NULL ) continue; buildingCount += buildings->size(); for( int j=0; j < buildings->size(); j++ ){ String buildingTemplate = buildings->get(j); std::string buildingStr = buildingTemplate.toCharArray(); SharedObjectTemplate* templateObject = templateManager->getTemplate(buildingTemplate.hashCode()); EXPECT_TRUE( templateObject != NULL && templateObject->isSharedTangibleObjectTemplate() ) << "Building template " << buildingStr << " in lair template " << templateName << " does not exist"; if( lair->getBuildingType() == LairTemplate::LAIR ){ EXPECT_TRUE( buildingTemplate.beginsWith( "object/tangible/lair/") ) << "Building template " << buildingStr << " in lair template " << templateName << " is not a child of object/tangible/lair/"; } if( lair->getBuildingType() == LairTemplate::THEATER ){ EXPECT_TRUE( buildingTemplate.beginsWith( "object/building/poi/") ) << "Building template " << buildingStr << " in lair template " << templateName << " is not a child of object/building/poi/"; } } } // Verify mission buildings exist and are lairs String missionBuilding = lair->getMissionBuilding(10); if (!missionBuilding.isEmpty()) { std::string buildingStr = missionBuilding.toCharArray(); SharedObjectTemplate* templateObject = templateManager->getTemplate(missionBuilding.hashCode()); EXPECT_TRUE( templateObject != NULL && templateObject->isSharedTangibleObjectTemplate() ) << "Mission building template " << buildingStr << " in lair template " << templateName << " does not exist"; EXPECT_TRUE( missionBuilding.beginsWith( "object/tangible/lair/") ) << "Mission building template " << buildingStr << " in lair template " << templateName << " is not a child of object/tangible/lair/"; } if( lair->getBuildingType() == LairTemplate::THEATER ){ EXPECT_TRUE( buildingCount > 0 ) << "There are no buildings configured in theater type lair template " << templateName; } if( lair->getBuildingType() == LairTemplate::NONE ){ EXPECT_TRUE( buildingCount == 0 ) << "There are buildings configured in 'none' type lair template " << templateName; } if( lair->getBuildingType() == LairTemplate::LAIR ){ EXPECT_TRUE( buildingCount > 0 ) << "There are no buildings configured in lair type lair template " << templateName; } } // Test Spawn Groups HashTableIterator<uint32, Reference<SpawnGroup*> > spawnIterator = CreatureTemplateManager::instance()->spawnGroupIterator(); while (spawnIterator.hasNext()) { SpawnGroup* group = spawnIterator.next(); std::string templateName( group->getTemplateName().toCharArray() ); Vector<String> lairTemplates; // Verify spawn list Vector<Reference<LairSpawn*> >* spawnList = group->getSpawnList(); for (int i = 0; i < spawnList->size(); i++) { LairSpawn* spawn = spawnList->get(i); std::string lairName( spawn->getLairTemplateName().toCharArray() ); // Verify lair template exists and isn't duplicated in the group String lairTemplateName = spawn->getLairTemplateName(); Reference<LairTemplate*> lairTemplate = CreatureTemplateManager::instance()->getLairTemplate(lairTemplateName.hashCode()); EXPECT_TRUE( lairTemplate != NULL ) << "Lair template " << lairName << " in spawn group " << templateName << " does not exist."; EXPECT_FALSE( lairTemplates.contains(lairTemplateName) ) << "Lair template " << lairName << " is duplicated in spawn group " << templateName; lairTemplates.add(lairTemplateName); // Verify spawn limit is at least -1 float spawnLimit = spawn->getSpawnLimit(); EXPECT_TRUE( spawnLimit >= -1 ) << "SpawnLimit for lairTemplate " << lairName << " in spawn group " << templateName << " is less than -1."; // Verify difficulties int minDiff = spawn->getMinDifficulty(); int maxDiff = spawn->getMaxDifficulty(); EXPECT_TRUE( minDiff > 0 ) << "MinDifficulty for lairTemplate " << lairName << " in spawn group " << templateName << " is not positive."; EXPECT_TRUE( maxDiff >= minDiff ) << "MaxDifficulty for lairTemplate " << lairName << " in spawn group " << templateName << " is less than min difficulty."; // Verify number to spawn is not negative int numberToSpawn = spawn->getNumberToSpawn(); EXPECT_TRUE( numberToSpawn >= 0 ) << "NumberToSpawn for lairTemplate " << lairName << " in spawn group " << templateName << " is negative."; // Verify weighting is positive int weighting = spawn->getWeighting(); EXPECT_TRUE( weighting > 0 ) << "Weighting for lairTemplate " << lairName << " in spawn group " << templateName << " is not positive."; // Verify size is at least 1 float size = spawn->getSize(); EXPECT_TRUE( size >= 1 ) << "Size for lairTemplate " << lairName << " in spawn group " << templateName << " is less than 1."; } } // Test Destroy Mission Spawn Groups HashTableIterator<uint32, Reference<SpawnGroup*> > missionIterator = CreatureTemplateManager::instance()->destroyMissionGroupIterator(); while (missionIterator.hasNext()) { SpawnGroup* group = missionIterator.next(); std::string templateName( group->getTemplateName().toCharArray() ); Vector<String> lairTemplates; // Verify spawn list Vector<Reference<LairSpawn*> >* spawnList = group->getSpawnList(); for (int i = 0; i < spawnList->size(); i++) { LairSpawn* spawn = spawnList->get(i); std::string lairName( spawn->getLairTemplateName().toCharArray() ); // Verify lair template exists String lairTemplateName = spawn->getLairTemplateName(); Reference<LairTemplate*> lairTemplate = CreatureTemplateManager::instance()->getLairTemplate(lairTemplateName.hashCode()); EXPECT_TRUE( lairTemplate != NULL ) << "Lair template " << lairName << " in destroy mission spawn group " << templateName << " does not exist."; EXPECT_FALSE( lairTemplates.contains(lairTemplateName) ) << "Lair template " << lairName << " is duplicated in destroy mission spawn group " << templateName; lairTemplates.add(lairTemplateName); if (lairTemplate != NULL) { // Verify that lair template has a valid mission building or is of type LAIR String missionBuilding = lairTemplate->getMissionBuilding(10); if (!missionBuilding.isEmpty()) { std::string buildingStr = missionBuilding.toCharArray(); SharedObjectTemplate* templateObject = templateManager->getTemplate(missionBuilding.hashCode()); EXPECT_TRUE( templateObject != NULL && templateObject->isSharedTangibleObjectTemplate() ) << "Mission building template " << buildingStr << " in lair template " << lairName << ", part of destroy mission group " << templateName << " does not exist"; EXPECT_TRUE( missionBuilding.beginsWith( "object/tangible/lair/") ) << "Mission building template " << buildingStr << " in lair template " << lairName << ", part of destroy mission group " << templateName << " is not a child of object/tangible/lair/"; } else { EXPECT_TRUE( lairTemplate->getBuildingType() == LairTemplate::LAIR ) << "Lair template " << lairName << ", part of destroy mission group " << templateName << " is not of type LAIR"; } } // Verify difficulties int minDiff = spawn->getMinDifficulty(); int maxDiff = spawn->getMaxDifficulty(); EXPECT_TRUE( minDiff > 0 ) << "MinDifficulty for lairTemplate " << lairName << " in destroy mission spawn group " << templateName << " is not positive."; EXPECT_TRUE( maxDiff >= minDiff ) << "MaxDifficulty for lairTemplate " << lairName << " in destroy mission spawn group " << templateName << " is less than min difficulty."; // Verify size is at least 1 float size = spawn->getSize(); EXPECT_TRUE( size >= 1 ) << "Size for lairTemplate " << lairName << " in destroy mission spawn group " << templateName << " is less than 1."; } } }
void NotificationWindow::MessageReceived(BMessage* message) { switch (message->what) { case B_NODE_MONITOR: { _LoadSettings(); _LoadAppFilters(); break; } case B_COUNT_PROPERTIES: { BMessage reply(B_REPLY); BMessage specifier; const char* property = NULL; bool messageOkay = true; if (message->FindMessage("specifiers", 0, &specifier) != B_OK) messageOkay = false; if (specifier.FindString("property", &property) != B_OK) messageOkay = false; if (strcmp(property, "message") != 0) messageOkay = false; if (messageOkay) reply.AddInt32("result", fViews.size()); else { reply.what = B_MESSAGE_NOT_UNDERSTOOD; reply.AddInt32("error", B_ERROR); } message->SendReply(&reply); break; } case B_CREATE_PROPERTY: case kNotificationMessage: { BMessage reply(B_REPLY); BNotification* notification = new BNotification(message); if (notification->InitCheck() == B_OK) { bigtime_t timeout; if (message->FindInt64("timeout", &timeout) != B_OK) timeout = -1; BMessenger messenger = message->ReturnAddress(); app_info info; if (messenger.IsValid()) be_roster->GetRunningAppInfo(messenger.Team(), &info); else be_roster->GetAppInfo("application/x-vnd.Be-SHEL", &info); NotificationView* view = new NotificationView(this, notification, timeout); bool allow = false; appfilter_t::iterator it = fAppFilters.find(info.signature); if (it == fAppFilters.end()) { AppUsage* appUsage = new AppUsage(notification->Group(), true); appUsage->Allowed(notification->Title(), notification->Type()); fAppFilters[info.signature] = appUsage; allow = true; } else { allow = it->second->Allowed(notification->Title(), notification->Type()); } if (allow) { BString groupName(notification->Group()); appview_t::iterator aIt = fAppViews.find(groupName); AppGroupView* group = NULL; if (aIt == fAppViews.end()) { group = new AppGroupView(this, groupName == "" ? NULL : groupName.String()); fAppViews[groupName] = group; GetLayout()->AddView(group); } else group = aIt->second; group->AddInfo(view); _ResizeAll(); reply.AddInt32("error", B_OK); } else reply.AddInt32("error", B_NOT_ALLOWED); } else { reply.what = B_MESSAGE_NOT_UNDERSTOOD; reply.AddInt32("error", B_ERROR); } message->SendReply(&reply); break; } case kRemoveView: { NotificationView* view = NULL; if (message->FindPointer("view", (void**)&view) != B_OK) return; views_t::iterator it = find(fViews.begin(), fViews.end(), view); if (it != fViews.end()) fViews.erase(it); _ResizeAll(); break; } default: BWindow::MessageReceived(message); } }
/*! Returns the name of this telephony service, which is the same as its group name. */ QString QTelephonyService::service() const { return groupName(); }
void IddFile_Impl::parse(std::istream& is) { // keep track of line number in the idd int lineNum = 0; // number of object in the idd, 1 is first object int objectNum = 0; // stream for header std::stringstream header; // have we read the entire header yet bool headerClosed = false; std::string currentGroup = ""; // fake a comment only object and put it in the object list and object map OptionalIddObject commentOnlyObject = IddObject::load(iddRegex::commentOnlyObjectName(), currentGroup, iddRegex::commentOnlyObjectText(), IddObjectType::CommentOnly); OS_ASSERT(commentOnlyObject); m_objects.push_back(*commentOnlyObject); // temp string to read file std::string line; // this will contain matches to regular expressions boost::smatch matches; // read in the version from the first line getline(is, line); if (boost::regex_search(line, matches, iddRegex::version())){ m_version = std::string(matches[1].first,matches[1].second); // this line belongs to the header header << line << std::endl; }else{ // idd file must have a version on the first line of input LOG_AND_THROW("Idd file does not contain version on first line: '" << line << "'"); } // read the rest of the file line by line // todo, do this by regex while(getline(is, line)){ ++lineNum; // remove whitespace boost::trim(line); if (line.empty()){ headerClosed = true; // empty line continue; }else if (boost::regex_search(line, matches, iddRegex::build())) { m_build = std::string(matches[1].first,matches[1].second); // this line belongs to the header header << line << std::endl; }else if (boost::regex_match(line, iddRegex::commentOnlyLine())){ if (!headerClosed){ header << line << std::endl; } // comment only line continue; }else if (boost::regex_search(line, matches, iddRegex::group())){ headerClosed = true; // get the group name std::string groupName(matches[1].first, matches[1].second); boost::trim(groupName); // set the current group currentGroup = groupName; continue; }else{ headerClosed = true; //int beginLineNum(lineNum); bool foundClosingLine(false); // a valid idd object to parse ++objectNum; // peek at the object name for indexing in map std::string objectName; if (boost::regex_search(line, matches, iddRegex::line())){ objectName = std::string(matches[1].first, matches[1].second); boost::trim(objectName); }else{ // can't figure out the object's name LOG_AND_THROW("Cannot determine object name on line " << lineNum << ": '" << line << "'"); } // put the text for this object in a new string std::string text(line); // check if the object has no fields if (boost::regex_match(line, iddRegex::objectNoFields())){ foundClosingLine = true; } // check if the object has fields, and last field on this line if (boost::regex_match(line, iddRegex::closingField())){ foundClosingLine = true; } // continue reading until we have seen the entire object // last line will be thrown away, requires empty line between objects in idd while(getline(is, line)){ ++lineNum; // remove whitespace boost::trim(line); // found last field and this is not a field comment if (foundClosingLine && (!boost::regex_match(line, iddRegex::metaDataComment()))){ break; } if (!line.empty()){ // if the line is not empty add it to the text // note, text does not include newlines text += line; // check if we have found the last field if (boost::regex_match(line, iddRegex::closingField())){ foundClosingLine = true; } } } // construct the IddObject using default UserCustom type OptionalIddObject object = IddObject::load(objectName, currentGroup, text); // construct a new object and put it in the object vector if (object) { m_objects.push_back(*object); } else { LOG_AND_THROW("Unable to construct IddObject from text: " << std::endl << text); } } } // set header m_header = header.str(); }