这篇教程C++ toInt函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中toInt函数的典型用法代码示例。如果您正苦于以下问题:C++ toInt函数的具体用法?C++ toInt怎么用?C++ toInt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了toInt函数的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: popFirstIntvoid MenuPowers::loadPower(FileParser &infile) { // @ATTR power.id|integer|A power id from powers/powers.txt for this slot. if (infile.key == "id") { int id = popFirstInt(infile.val); if (id > 0) { skip_section = false; power_cell.back().id = static_cast<short>(id); } else { infile.error("MenuPowers: Power index out of bounds 1-%d, skipping power.", INT_MAX); } return; } if (power_cell.back().id <= 0) { skip_section = true; power_cell.pop_back(); slots.pop_back(); upgradeButtons.pop_back(); logError("MenuPowers: There is a power without a valid id as the first attribute. IDs must be the first attribute in the power menu definition."); } if (skip_section) return; // @ATTR power.tab|integer|Tab index to place this power on, starting from 0. if (infile.key == "tab") power_cell.back().tab = static_cast<short>(toInt(infile.val)); // @ATTR power.position|x (integer), y (integer)|Position of this power icon; relative to MenuPowers "pos". else if (infile.key == "position") power_cell.back().pos = toPoint(infile.val); // @ATTR power.requires_physoff|integer|Power requires Physical and Offense stat of this value. else if (infile.key == "requires_physoff") power_cell.back().requires_physoff = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_physdef|integer|Power requires Physical and Defense stat of this value. else if (infile.key == "requires_physdef") power_cell.back().requires_physdef = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_mentoff|integer|Power requires Mental and Offense stat of this value. else if (infile.key == "requires_mentoff") power_cell.back().requires_mentoff = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_mentdef|integer|Power requires Mental and Defense stat of this value. else if (infile.key == "requires_mentdef") power_cell.back().requires_mentdef = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_defense|integer|Power requires Defense stat of this value. else if (infile.key == "requires_defense") power_cell.back().requires_defense = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_offense|integer|Power requires Offense stat of this value. else if (infile.key == "requires_offense") power_cell.back().requires_offense = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_physical|integer|Power requires Physical stat of this value. else if (infile.key == "requires_physical") power_cell.back().requires_physical = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_mental|integer|Power requires Mental stat of this value. else if (infile.key == "requires_mental") power_cell.back().requires_mental = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_point|boolean|Power requires a power point to unlock. else if (infile.key == "requires_point") power_cell.back().requires_point = toBool(infile.val); // @ATTR power.requires_level|integer|Power requires at least this level for the hero. else if (infile.key == "requires_level") power_cell.back().requires_level = static_cast<short>(toInt(infile.val)); // @ATTR power.requires_power|integer|Power requires another power id. else if (infile.key == "requires_power") power_cell.back().requires_power.push_back(static_cast<short>(toInt(infile.val))); // @ATTR power.visible_requires_status|string|Hide the power if we don't have this campaign status. else if (infile.key == "visible_requires_status") power_cell.back().visible_requires_status.push_back(infile.val); // @ATTR power.visible_requires_not_status|string|Hide the power if we have this campaign status. else if (infile.key == "visible_requires_not_status") power_cell.back().visible_requires_not.push_back(infile.val); // @ATTR power.upgrades|id (integer), ...|A list of upgrade power ids that this power slot can upgrade to. Each of these powers should have a matching upgrade section. else if (infile.key == "upgrades") { upgradeButtons.back() = new WidgetButton("images/menus/buttons/button_plus.png"); std::string repeat_val = infile.nextValue(); while (repeat_val != "") { power_cell.back().upgrades.push_back(static_cast<short>(toInt(repeat_val))); repeat_val = infile.nextValue(); } if (!power_cell.back().upgrades.empty()) power_cell.back().upgrade_level = 1; } else infile.error("MenuPowers: '%s' is not a valid key.", infile.key.c_str());}
开发者ID:Jeffry84,项目名称:flare-engine,代码行数:75,
示例2: switch//在interpreter中检测table是否存在//与record交互,根据条件获取表中信息vector<Row> APIManager::select(string tablename, vector<Conditions>& condition){ int tableIndex = catalogmanager.findTable(tablename); vector<Row> result; CONDITION_TYPE conditionType; conditionType = condition[0].condition_type; // where clause's type int attributeIndex = catalogmanager.getAttriNum(catalogmanager.Vtable[tableIndex], condition[0].attribute); int type = catalogmanager.Vtable[tableIndex].attributes[attributeIndex].type; if(catalogmanager.Vtable[tableIndex].attributes[attributeIndex].indexName == "NULL") // no index { switch (conditionType) { case EQUAL: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), EQUAL); break; case FLOAT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toFloat(condition[0].attributeValue), EQUAL); break; case CHAR: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, condition[0].attributeValue, EQUAL); break; } break; } case NOT_EQUAL: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), NOT_EQUAL); break; case FLOAT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toFloat(condition[0].attributeValue), NOT_EQUAL); break; case CHAR: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, condition[0].attributeValue, NOT_EQUAL); break; } break; } case GREATER: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), GREATER); break; case FLOAT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toFloat(condition[0].attributeValue), GREATER); break; case CHAR: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, condition[0].attributeValue, GREATER); break; } break; } case GREATER_EQUAL: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), GREATER_EQUAL); break; case FLOAT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toFloat(condition[0].attributeValue), GREATER_EQUAL); break; case CHAR: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, condition[0].attributeValue, GREATER_EQUAL); break; } break; } case SMALLER: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), SMALLER); break; case FLOAT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toFloat(condition[0].attributeValue), SMALLER); break; case CHAR: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, condition[0].attributeValue, SMALLER); break; } break; } case SMALLER_EQUAL: { switch (type) { case INT: result = recordmanager.select(catalogmanager.Vtable[tableIndex], condition[0].attribute, toInt(condition[0].attributeValue), SMALLER_EQUAL);//.........这里部分代码省略.........
开发者ID:crabyh,项目名称:MiniSQL,代码行数:101,
示例3: channelLockervoid DrawWidget::drawChannel(QPaintDevice &pd, Channel *ch, QPainter &p, double leftTime, double currentTime, double zoomX, double viewBottom, double zoomY, int viewType){ ZoomLookup *z; if(viewType == DRAW_VIEW_SUMMARY) z = &ch->summaryZoomLookup; else z = &ch->normalZoomLookup; ChannelLocker channelLocker(ch); QColor current = ch->color; QColor invert(255 - current.red(), 255 - current.green(), 255 - current.blue()); p.setPen(current); int viewBottomOffset = toInt(viewBottom / zoomY); printf("viewBottomOffset=%d, %f, %f/n", viewBottomOffset, viewBottom, zoomY); viewBottom = double(viewBottomOffset) * zoomY; // baseX is the no. of chunks a pixel must represent. double baseX = zoomX / ch->timePerChunk(); z->setZoomLevel(baseX); double currentChunk = ch->chunkFractionAtTime(currentTime); double leftFrameTime = currentChunk - ((currentTime - leftTime) / ch->timePerChunk()); //double leftFrameTime = leftTime / ch->timePerChunk(); double frameTime = leftFrameTime; //if(frameTime < 0.0) frameTime = 0.0; int n = 0; int baseElement = int(floor(frameTime / baseX)); if(baseElement < 0) { n -= baseElement; baseElement = 0; } int lastBaseElement = int(floor(double(ch->totalChunks()) / baseX)); Q3PointArray pointArray(pd.width()*2); //QPointArray topPoints(width()*2); //QPointArray bottomPoints(width()*2); //int pointIndex = 0; //int pointIndex = 0; if (baseX > 1) { // More samples than pixels int theWidth = pd.width(); //if(baseElement + theWidth > z->size()) z->setSize(baseElement + theWidth); if(lastBaseElement > z->size()) z->setSize(lastBaseElement); for(; n < theWidth && baseElement < lastBaseElement; n++, baseElement++) { myassert(baseElement >= 0); ZoomElement &ze = z->at(baseElement); if(!ze.isValid()) { if(calcZoomElement(ch, ze, baseElement, baseX)) continue; } if(ze.high() != 0.0f && ze.high() - ze.low() < 1.0) { //if range is closer than one semi-tone then draw a line between them //if(ze.noteLow > 0) { p.setPen(ze.color()); //p.setPen(QPen(ze.color(), lineWidth)); //Note: lineTo doen't draw a pixel on the last point of the line p.drawLine(n, pd.height() - lineTopHalfWidth - toInt(ze.high() / zoomY) + viewBottomOffset, n, pd.height() + lineBottomHalfWidth - toInt(ze.low() / zoomY) + viewBottomOffset); //pointArray.setPoint(pointIndex++, n, height() - lineTopHalfWidth - toInt(ze.high / zoomY) + viewBottomOffset); //pointArray.setPoint(pointIndex++, n, height() + lineBottomHalfWidth - toInt(ze.low / zoomY) + viewBottomOffset); } } //myassert(pointIndex <= width()*2); //p.setPen(ch->color); //p.drawLineSegments(pointArray, 0, pointIndex/2); } else { // More pixels than samples float err = 0.0, pitch = 0.0, prevPitch = 0.0, vol; int intChunk = (int) floor(frameTime); // Integer version of frame time if(intChunk < 0) intChunk = 0; double stepSize = 1.0 / baseX; // So we skip some pixels int x = 0, y; //double start = 0 - stepSize; double start = (double(intChunk) - frameTime) * stepSize; double stop = pd.width() + (2 * stepSize); int squareSize = (int(sqrt(stepSize)) / 2) * 2 + 1; //make it an odd number int halfSquareSize = squareSize/2; int penX=0, penY=0; //topPoints.setPoint(pointIndex, toInt(start), 0); //bottomPoints.setPoint(pointIndex++, toInt(start), height()); for (double n = start; n < stop && intChunk < (int)ch->totalChunks(); n += stepSize, intChunk++) { myassert(intChunk >= 0); //if (intChunk < 0) continue; // So we don't go off the beginning of the array AnalysisData *data = ch->dataAtChunk(intChunk); err = data->getCorrelation(); //vol = dB2ViewVal(data->logrms(), ch->rmsCeiling, ch->rmsFloor); vol = dB2Normalised(data->getLogRms(), ch->rmsCeiling, ch->rmsFloor); //if (err >= CERTAIN_THRESHOLD) { //float val = MIN(ch->dataAtChunk(intChunk)->volumeValue, 1.0); if(gdata->pitchContourMode() == 0) //p.setPen(QPen(colorBetween(colorGroup().background(), ch->color, err*2.0-1.0), lineWidth)); //p.setPen(QPen(colorBetween(gdata->backgroundColor(), ch->color, err*sqrt(data->rms)*10.0), lineWidth)); if(viewType == DRAW_VIEW_PRINT) p.setPen(QPen(colorBetween(QColor(255, 255, 255), ch->color, err*vol), lineWidth)); else p.setPen(QPen(colorBetween(gdata->backgroundColor(), ch->color, err*vol), lineWidth)); else p.setPen(QPen(ch->color, lineWidth)); //.........这里部分代码省略.........
开发者ID:nsauzede,项目名称:tartini,代码行数:101,
示例4: toIntVal Float64Impl::ToInt() const { return toInt(GetLayout()); }
开发者ID:eval1749,项目名称:tiny-common-lisp,代码行数:2,
示例5: toIntint toInt( const std::string& number ){ return toInt( number.c_str() );}
开发者ID:b606,项目名称:caesaria-game,代码行数:4,
示例6: toIntstd::int32_t Decimal128::toInt(RoundingMode roundMode) const { std::uint32_t throwAwayFlag = 0; return toInt(&throwAwayFlag, roundMode);}
开发者ID:EvgeniyPatlan,项目名称:percona-server-mongodb,代码行数:4,
示例7: getUndoTextBufferIntgetUndoTextBuffer(TextBuffer tb){ long caret = -1; if ( tb->undo_buffer != NULL ) { UndoBuffer ub = tb->undo_buffer; UndoCell cell; if ( (cell = ub->current) == NULL ) /* No further undo's */ fail; while(cell != NULL) { DEBUG(NAME_undo, Cprintf("Undo using cell %d: ", Distance(cell, ub->buffer))); switch( cell->type ) { case UNDO_DELETE: { UndoDelete d = (UndoDelete) cell; string s; s.size = d->len; s.iswide = d->iswide; if ( d->iswide ) s.s_textA = d->text.A; else s.s_textW = d->text.W; DEBUG(NAME_undo, Cprintf("Undo delete at %ld, len=%ld/n", d->where, d->len)); insert_textbuffer(tb, d->where, 1, &s); caret = max(caret, d->where + d->len); break; } case UNDO_INSERT: { UndoInsert i = (UndoInsert) cell; DEBUG(NAME_undo, Cprintf("Undo insert at %ld, len=%ld/n", i->where, i->len)); delete_textbuffer(tb, i->where, i->len); caret = max(caret, i->where); break; } case UNDO_CHANGE: { UndoChange c = (UndoChange) cell; string s; s.size = c->len; s.iswide = c->iswide; if ( c->iswide ) s.s_textA = c->text.A; else s.s_textW = c->text.W; DEBUG(NAME_undo, Cprintf("Undo change at %ld, len=%ld/n", c->where, c->len)); change_textbuffer(tb, c->where, &s); caret = max(caret, c->where + c->len); break; } } cell = cell->previous; if ( cell == NULL || cell->marked == TRUE ) { ub->current = cell; if ( cell == ub->checkpoint ) /* reached non-modified checkpoint */ { DEBUG(NAME_undo, Cprintf("Reset modified to @off/n")); CmodifiedTextBuffer(tb, OFF); } changedTextBuffer(tb); ub->undone = TRUE; answer(toInt(caret)); } } } fail;}
开发者ID:brayc0,项目名称:nlfetdb,代码行数:80,
示例8: fNamebool SBMLModelSimulation::LoadSettings(const string& settingsFName){ string fName(settingsFName); if(!fName.size()) { Log(Logger::LOG_ERROR)<<"Empty file name for setings file"; return false; } else { map<string, string> settings; map<string, string>::iterator it; //Read each line in the settings file vector<string> lines = getLinesInFile(fName); for(u_int i = 0; i < lines.size(); i++) { vector<string> line = splitString(lines[i], ":"); if(line.size() == 2) { settings.insert( pair<string, string>(line[0], line[1])); } else { Log(lDebug2)<<"Empty line in settings file: "<<lines[i]; } } Log(lDebug3)<<"Settings File ============="; for (it = settings.begin() ; it != settings.end(); it++ ) { Log(lDebug) << (*it).first << " => " << (*it).second; } Log(lDebug)<<"==========================="; //Assign values it = settings.find("start"); mSettings.start = (it != settings.end()) ? toDouble((*it).second) : 0; it = settings.find("duration"); mSettings.duration = (it != settings.end()) ? toDouble((*it).second) : 0; it = settings.find("steps"); mSettings.steps = (it != settings.end()) ? toInt((*it).second) : 50; it = settings.find("absolute"); mSettings.absolute = (it != settings.end()) ? toDouble((*it).second) : 1.e-7; it = settings.find("relative"); mSettings.relative = (it != settings.end()) ? toDouble((*it).second) : 1.e-4; it = settings.find("variables"); if(it != settings.end()) { vector<string> vars = splitString((*it).second, ","); for(u_int i = 0; i < vars.size(); i++) { mSettings.variables.push_back(trim(vars[i])); } } it = settings.find("amount"); if(it != settings.end()) { vector<string> vars = splitString((*it).second, ","); for(u_int i = 0; i < vars.size(); i++) { string rec = trim(vars[i]); if(rec.size()) { mSettings.amounts.push_back(rec); } } } it = settings.find("concentration"); if(it != settings.end()) { vector<string> vars = splitString((*it).second, ","); for(u_int i=0; i < vars.size(); i++) { string rec = trim(vars[i]); if(rec.size()) { mSettings.concentrations.push_back(rec); } } } } if(mEngine) { mEngine->setSimulateOptions(mSettings); } return true;}
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:97,
示例9: toIntlong long BigInteger::getAsNumber(){ return toInt(number);}
开发者ID:thatguyandy27,项目名称:ProjectEuler,代码行数:3,
示例10: makePair Input::NamedPair makePair(ChannelType type, Action action, const QString& name) { auto input = Input(UserInputMapper::ACTIONS_DEVICE, toInt(action), type); return Input::NamedPair(input, name); }
开发者ID:CryptArc,项目名称:hifi,代码行数:4,
示例11: switchQVariant QDBusDemarshaller::toVariantInternal(){ switch (q_dbus_message_iter_get_arg_type(&iterator)) { case DBUS_TYPE_BYTE: return QVariant::fromValue(toByte()); case DBUS_TYPE_INT16: return QVariant::fromValue(toShort()); case DBUS_TYPE_UINT16: return QVariant::fromValue(toUShort()); case DBUS_TYPE_INT32: return toInt(); case DBUS_TYPE_UINT32: return toUInt(); case DBUS_TYPE_DOUBLE: return toDouble(); case DBUS_TYPE_BOOLEAN: return toBool(); case DBUS_TYPE_INT64: return toLongLong(); case DBUS_TYPE_UINT64: return toULongLong(); case DBUS_TYPE_STRING: return toStringUnchecked(); case DBUS_TYPE_OBJECT_PATH: return QVariant::fromValue(toObjectPathUnchecked()); case DBUS_TYPE_SIGNATURE: return QVariant::fromValue(toSignatureUnchecked()); case DBUS_TYPE_VARIANT: return QVariant::fromValue(toVariant()); case DBUS_TYPE_ARRAY: switch (q_dbus_message_iter_get_element_type(&iterator)) { case DBUS_TYPE_BYTE: // QByteArray return toByteArrayUnchecked(); case DBUS_TYPE_STRING: return toStringListUnchecked(); case DBUS_TYPE_DICT_ENTRY: return QVariant::fromValue(duplicate()); default: return QVariant::fromValue(duplicate()); } case DBUS_TYPE_STRUCT: return QVariant::fromValue(duplicate()); case DBUS_TYPE_UNIX_FD: if (capabilities & QDBusConnection::UnixFileDescriptorPassing) return QVariant::fromValue(toUnixFileDescriptor()); // fall through default:// qWarning("QDBusDemarshaller: Found unknown D-Bus type %d '%c'",// q_dbus_message_iter_get_arg_type(&iterator),// q_dbus_message_iter_get_arg_type(&iterator)); char *ptr = 0; ptr += q_dbus_message_iter_get_arg_type(&iterator); q_dbus_message_iter_next(&iterator); // I hope you never dereference this pointer! return QVariant::fromValue<void *>(ptr); };}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:64,
示例12: parse_durationvoid StatBlock::loadHeroStats() { // set the default global cooldown cooldown = parse_duration("66ms"); // Redefine numbers from config file if present FileParser infile; // @CLASS StatBlock: Hero stats|Description of engine/stats.txt if (infile.open("engine/stats.txt")) { while (infile.next()) { int value = toInt(infile.val); bool valid = loadCoreStat(&infile); if (infile.key == "max_points_per_stat") { // @ATTR max_points_per_stat|int|Maximum points for each primary stat. max_points_per_stat = value; } else if (infile.key == "sfx_step") { // @ATTR sfx_step|string|An id for a set of step sound effects. See items/step_sounds.txt. sfx_step = infile.val; } else if (infile.key == "stat_points_per_level") { // @ATTR stat_points_per_level|int|The amount of stat points awarded each level. stat_points_per_level = value; } else if (infile.key == "power_points_per_level") { // @ATTR power_points_per_level|int|The amount of power points awarded each level. power_points_per_level = value; } else if (!valid) { infile.error("StatBlock: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } if (max_points_per_stat == 0) max_points_per_stat = max_spendable_stat_points / 4 + 1; statsLoaded = true; // load the XP table // @CLASS StatBlock: XP table|Description of engine/xp_table.txt if (infile.open("engine/xp_table.txt")) { while(infile.next()) { if (infile.key == "level") { // @ATTR level|int, int : Level, XP|The amount of XP required for this level. unsigned lvl_id = popFirstInt(infile.val); unsigned long lvl_xp = toUnsignedLong(popFirstString(infile.val)); if (lvl_id > xp_table.size()) xp_table.resize(lvl_id); xp_table[lvl_id - 1] = lvl_xp; } } infile.close(); } if (xp_table.empty()) { logError("StatBlock: No XP table defined."); xp_table.push_back(0); } max_spendable_stat_points = static_cast<int>(xp_table.size()) * stat_points_per_level;}
开发者ID:igorko,项目名称:flare-engine,代码行数:64,
示例13: processRegulationsvoid AddPresetItemAction::processRegulations(QStandardItem *item){ int remoteStationId = item->parent()->data(UserRoles::RemoteStationIdRole).toInt(); reportPreset->addCurrentPresetContent(toInt(ObjectTypes::Regulations), remoteStationId);}
开发者ID:e-al,项目名称:misc,代码行数:5,
示例14: popFirstStringvoid MenuDevConsole::execute() { std::string command = input_box->getText(); if (command == "") return; input_scrollback.push_back(command); input_scrollback_pos = input_scrollback.size(); input_box->setText(""); log_history->add(command, false, &color_echo); std::vector<std::string> args; command += ' '; std::string arg = popFirstString(command, ' '); while (arg != "") { args.push_back(arg); arg = popFirstString(command, ' '); } if (args.empty()) { return; } if (args[0] == "help") { log_history->add("teleport - " + msg->get("teleports the player to a specific tile, and optionally, a specific map"), false); log_history->add("unset_status - " + msg->get("unsets the given campaign statuses if they are set"), false); log_history->add("set_status - " + msg->get("sets the given campaign statuses"), false); log_history->add("give_xp - " + msg->get("rewards the player with the specified amount of experience points"), false); log_history->add("give_currency - " + msg->get("adds the specified amount of currency to the player's inventory"), false); log_history->add("give_item - " + msg->get("adds an item to the player's inventory"), false); log_history->add("spawn_enemy - " + msg->get("spawns an enemy matching the given category next to the player"), false); log_history->add("toggle_devhud - " + msg->get("turns on/off the developer hud"), false); log_history->add("clear - " + msg->get("clears the command history"), false); log_history->add("help - " + msg->get("displays this text"), false); } else if (args[0] == "clear") { log_history->clear(); } else if (args[0] == "toggle_devhud") { DEV_HUD = !DEV_HUD; log_history->add(msg->get("Toggled the developer hud"), false); } else if (args[0] == "spawn_enemy") { if (args.size() > 1) { Enemy_Level el = enemyg->getRandomEnemy(args[1], 0, 0); if (el.type != "") { Point spawn_pos = floor(mapr->collider.get_random_neighbor(floor(pc->stats.pos), 1)); powers->spawn(args[1], spawn_pos); log_history->add(msg->get("Spawning enemy from category: ") + args[1]); } else { log_history->add(msg->get("ERROR: Invalid enemy category"), false, &color_error); } } else { log_history->add(msg->get("ERROR: Too few arguments"), false, &color_error); } } else if (args[0] == "give_item") { if (args.size() > 1) { int id = toInt(args[1]); if (id <= 0 || (unsigned)id >= items->items.size() || items->items[id].name == "") { log_history->add(msg->get("ERROR: Invalid item ID"), false, &color_error); return; } int quantity = (args.size() > 2) ? toInt(args[2]) : 1; if (quantity > 0) { if (id == CURRENCY_ID) { camp->rewardCurrency(quantity); } else { ItemStack stack; stack.item = id; stack.quantity = quantity; camp->rewardItem(stack); } log_history->add(msg->get("Added item: ") + items->items[id].name + " (" + toString(typeid(int), &quantity) + ")", false); } } else { log_history->add(msg->get("ERROR: Too few arguments"), false, &color_error); } } else if (args[0] == "give_currency") { int quantity = (args.size() > 1) ? toInt(args[1]) : 0; if (quantity > 0) { camp->rewardCurrency(quantity); log_history->add(msg->get("Added currency: ") + toString(typeid(int), &quantity), false); } if (args.size() < 2) { log_history->add(msg->get("ERROR: Too few arguments"), false, &color_error); } } else if (args[0] == "give_xp") { int quantity = (args.size() > 1) ? toInt(args[1]) : 0; if (quantity > 0) { camp->rewardXP(quantity, true);//.........这里部分代码省略.........
开发者ID:stefanbeller,项目名称:flare-engine,代码行数:101,
示例15: processCommandvoid AddPresetItemAction::processCommand(QStandardItem *item){ model::UnitItemId commandId = item->data(UserRoles::CommandIdRole).value<model::UnitItemId>(); model::UnitItemId senderId = item->data(UserRoles::ControlObjectIdRole).value<model::UnitItemId>(); reportPreset->addCurrentPresetContent(toInt(ObjectTypes::Command), senderId, commandId);}
开发者ID:e-al,项目名称:misc,代码行数:6,
示例16: ifTEftpState FTPServer::parseCommand(String response, String &info) { TEftpState newState = TEftpState_Unknown; auto posEnd = response.indexOf('/r'); if (response.startsWith("USER")) { receivedCredentials.username = response.substring(String("USER ").length(), posEnd); info = receivedCredentials.username; newState = TEftpState_User; } else if (response.startsWith("PASS")) { receivedCredentials.password = response.substring(String("PASS ").length(), posEnd); if ((credentials.username == receivedCredentials.username) && (credentials.password == receivedCredentials.password)) newState = TEftpState_AuthOk; else newState = TEftpState_AuthFail; } else if (response.startsWith("PORT")) { auto lastComma = response.lastIndexOf(","); auto secondLastComma = response.lastIndexOf(",", lastComma - 1); auto hiPort = response.substring(secondLastComma + 1, lastComma); auto loPort = response.substring(lastComma + 1, posEnd); activeDataPortHi = hiPort.toInt(); activeDataPortLo = loPort.toInt(); newState = TEftpState_Port; } else if (response.startsWith("PWD")) newState = TEftpState_CurrentDir; else if (response.startsWith("QUIT")) newState = TEftpState_Quit; else if (response.startsWith("FEAT")) newState = TEftpState_Features; else if (response.startsWith("SYST")) newState = TEftpState_System; else if (response.startsWith("PASV")) newState = TEftpState_Passive; else if (response.startsWith("LIST")) newState = TEftpState_List; else if (response.startsWith("TYPE")) newState = TEftpState_Type; else if (response.startsWith("CDUP")) newState = TEftpState_ParentDir; else if (response.startsWith("CLIENT")) newState = TEftpState_Client, info = response.substring(String("CLIENT ").length(), posEnd); else if (response.startsWith("REST")) newState = TEftpState_RestartAt, info = response.substring(String("REST ").length(), posEnd); else if (response.startsWith("RETR")) newState = TEftpState_RetrieveFile, info = response.substring(String("RETR ").length(), posEnd); else if (response.startsWith("DELE")) newState = TEftpState_DeleteFile, info = response.substring(String("DELE ").length(), posEnd); else if (response.startsWith("STOR")) newState = TEftpState_Store, info = response.substring(String("STOR ").length(), posEnd); else if (response.startsWith("MKD")) newState = TEftpState_MakeDir, info = response.substring(String("MKD ").length(), posEnd); else if (response.startsWith("APPE")) newState = TEftpState_Append, info = response.substring(String("APPE ").length(), posEnd); else if (response.startsWith("CWD")) newState = TEftpState_ChangeDir, info = response.substring(String("CWD ").length(), posEnd); else if (response.startsWith("RNFR")) newState = TEftpState_RenameFrom, info = response.substring(String("RNFR ").length(), posEnd); else if (response.startsWith("RNTO")) newState = TEftpState_RenameTo, info = response.substring(String("RNTO ").length(), posEnd); else if (response.startsWith("RMD")) newState = TEftpState_DeleteDir, info = response.substring(String("RMD ").length(), posEnd); else info = response.substring(0, posEnd); if ((-1 != aliveTimer) && (response.length() > 0)) aliveTimer = millis() + timeoutSec * 1000; return newState;}
开发者ID:mihaigalos,项目名称:FTPino,代码行数:87,
示例17: while//------------------------------------------------------------------------------bool ScoreSegmentIterator::next(void){ if(ch) { while(rowCounter < numRows) { int j = rowCounter; double startOfRowTime = startOfPageTime + j * totalRowTime; double endOfRowTime = startOfRowTime + totalRowTime; _lineCenterY = toInt(sw->_boarderY) + halfStaveHeight + staveHeight * j; while(++subRowCounter < 4) { switch(subRowCounter) { case 1: if(startOfRowTime < lookBehindTime3) { //draw any parts of the next page _leftTime = startOfRowTime + totalPageTime; _rightTime = std::min(endOfRowTime, lookBehindTime3) + totalPageTime; _leftX = (double)sw->_boarderX; return (_isValid = true); } break; case 2: if(endOfRowTime > lookBehindTime3+lookAheadGapTime && startOfRowTime < lookAheadTime2) { //normal case _leftTime = std::max(startOfRowTime, lookBehindTime3 + lookAheadGapTime); _rightTime = std::min(startOfRowTime + totalRowTime, lookAheadTime2); _leftX = (double)sw->_boarderX + (_leftTime-startOfRowTime) * sw->_scaleX; return (_isValid = true); } break; case 3: if(endOfRowTime - totalPageTime > lookBehindTime2 + lookAheadGapTime) { _leftTime = std::max(startOfRowTime - totalPageTime, lookBehindTime2 + lookAheadGapTime); _leftTime = std::min(_leftTime, endOfRowTime - totalPageTime); _rightTime = endOfRowTime - totalPageTime; _leftX = (double)sw->_boarderX + (_leftTime -(startOfRowTime - totalPageTime)) * sw->_scaleX; return (_isValid = true); } } } rowCounter++; subRowCounter = -1; } } else { while(rowCounter < numRows) { double startOfRowTime = startOfPageTime + rowCounter*totalRowTime; double endOfRowTime = startOfRowTime + totalRowTime; _lineCenterY = toInt(sw->_boarderY) + halfStaveHeight + staveHeight*rowCounter; _leftX = sw->_boarderX; _leftTime = startOfRowTime; _rightTime = endOfRowTime; rowCounter++; return (_isValid = true); } } return (_isValid = false);}
开发者ID:quicky2000,项目名称:tartini,代码行数:66,
示例18: toIntint String::toInt() const{ return toInt(0);}
开发者ID:amigadave,项目名称:taglib,代码行数:4,
示例19: resetvoid TileSet::load(const std::string& filename) { if (current_map == filename) return; reset(); FileParser infile; // @CLASS TileSet|Description of tilesets in tilesets/ if (infile.open(filename)) { while (infile.next()) { if (infile.key == "img") { // @ATTR img|string|Filename of a tile sheet image. loadGraphics(infile.val); } else if (infile.key == "tile") { // @ATTR tile|index (integer), x (integer), y (integer), w (integer), h (integer), x offset (integer), y offset (integer)|A single tile definition. // Verify that we have graphics for tiles if (!sprites) { std::cerr << "No graphics for tileset definition '" << filename << "', aborting." << std::endl; exit(0); } unsigned index = popFirstInt(infile.val); if (index >= tiles.size()) tiles.resize(index + 1); tiles[index].tile = sprites->getGraphics()->createSprite(); tiles[index].tile->setClipX(popFirstInt(infile.val)); tiles[index].tile->setClipY(popFirstInt(infile.val)); tiles[index].tile->setClipW(popFirstInt(infile.val)); tiles[index].tile->setClipH(popFirstInt(infile.val)); tiles[index].offset.x = popFirstInt(infile.val); tiles[index].offset.y = popFirstInt(infile.val); max_size_x = std::max(max_size_x, (tiles[index].tile->getClip().w / TILE_W) + 1); max_size_y = std::max(max_size_y, (tiles[index].tile->getClip().h / TILE_H) + 1); } else if (infile.key == "transparency") { // @ATTR transparency|r (integer), g (integer), b (integer)|An RGB color to key out and treat as transparent. alpha_background = false; trans_r = (Uint8)popFirstInt(infile.val); trans_g = (Uint8)popFirstInt(infile.val); trans_b = (Uint8)popFirstInt(infile.val); } else if (infile.key == "animation") { // @ATTR animation|tile index (integer), x (integer), y (integer), duration (duration), ...|An animation for a tile. Durations are in 'ms' or 's'. int frame = 0; unsigned TILE_ID = toInt(infile.nextValue()); if (TILE_ID >= anim.size()) anim.resize(TILE_ID + 1); std::string repeat_val = infile.nextValue(); while (repeat_val != "") { anim[TILE_ID].frames++; anim[TILE_ID].pos.resize(frame + 1); anim[TILE_ID].frame_duration.resize(frame + 1); anim[TILE_ID].pos[frame].x = toInt(repeat_val); anim[TILE_ID].pos[frame].y = toInt(infile.nextValue()); anim[TILE_ID].frame_duration[frame] = parse_duration(infile.nextValue()); frame++; repeat_val = infile.nextValue(); } } else { infile.error("TileSet: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } current_map = filename;}
开发者ID:RetroAsh,项目名称:flare-engine-next,代码行数:78,
示例20: computeLinestatuscomputeLine(Line ln){ if ( notNil(ln->request_compute) ) { int x1 = valInt(ln->start_x); int x2 = valInt(ln->end_x); int y1 = valInt(ln->start_y); int y2 = valInt(ln->end_y); int pen = valInt(ln->pen); int x, y, w, h; Area a = ln->area; if ( x1 < x2 ) { x = x1; w = x2-x1; } else { x = x2; w = x1-x2; } if ( y1 < y2 ) { y = y1; h = y2-y1; } else { y = y2; h = y1-y2; } if ( pen == 1 ) { w++; h++; } else if ( pen > 1 ) { int ex = (h > 0 ? (pen*h)/(w+h) : 0); /* h = 0: horizontal line */ int ey = (w > 0 ? (pen*w)/(w+h) : 0); /* w = 0: vertical line */ int hx = ex/2; int hy = ey/2; x -= hx; w += ex; y -= hy; h += ey; } if ( ln->selected == ON ) /* should be solved elsewhere */ { x -= 3; y -= 3; w += 6; h += 6; } CHANGING_GRAPHICAL(ln, assign(a, x, toInt(x)); assign(a, y, toInt(y)); assign(a, w, toInt(w)); assign(a, h, toInt(h)); if ( adjustFirstArrowLine(ln) ) unionNormalisedArea(a, ln->first_arrow->area); if ( adjustSecondArrowLine(ln) ) unionNormalisedArea(a, ln->second_arrow->area); changedEntireImageGraphical(ln)); assign(ln, request_compute, NIL); }
开发者ID:SWI-Prolog,项目名称:packages-xpce,代码行数:63,
示例21: doublevoid CorrelationWidget::paintEvent( QPaintEvent * ){ Channel *active = gdata->getActiveChannel(); AnalysisData *data = NULL; int chunk=0; double dh2 = double(height()-1) / 2.0; int j, x, y; beginDrawing(false); if(active) { active->lock(); chunk = active->currentChunk(); data = active->dataAtChunk(chunk); //int centerX = width() / 2; if(data) { double freq = data->getFundamentalFreq(); double period = double(active->rate()) / freq; //double numPeriods = double(active->size()) / period; double scaleX = period * double(width()) / double(active->nsdfData.size()); //pixels per period //draw alternating background color indicating period if(gdata->view->backgroundShading() && period > 4.0 && period < double(active->nsdfData.size())) { int n = int(ceil(double(width()) / scaleX)); //number of colored patches p.setPen(Qt::NoPen); QColor color1 = colorBetween(gdata->backgroundColor(), gdata->shading1Color(), data->getCorrelation()); QColor color2 = colorBetween(gdata->backgroundColor(), gdata->shading2Color(), data->getCorrelation()); for(j = 0; j<n; j++) { x = toInt(scaleX*double(j)); p.setBrush((j%2) ? color1 : color2); p.drawRect(x, 0, toInt(scaleX*double(j+1)) - toInt(scaleX*double(j)), height()); } p.setPen(colorBetween(gdata->backgroundColor(), Qt::black, 0.3 * data->getCorrelation())); for(j = 0; j<n; j++) { x = toInt(scaleX*double(j)); p.drawLine(x, 0, x, height()); } } else { clearBackground(); } QString numPeriodsText; numPeriodsText.sprintf("Period = %lf", period); p.setPen(Qt::black); p.drawText(5, height() - 8, numPeriodsText); } else { clearBackground(); } } else { clearBackground(); } //draw the horizontal center line p.setPen(QPen(colorBetween(colorGroup().background(), Qt::black, 0.3), 0)); p.drawLine(0, toInt(dh2), width(), toInt(dh2)); if(active) { if(gdata->doingFreqAnalysis()) { int w = width() / 2; //only do every second pixel (for speed) //draw the waveform if(int(pointArray.size()) != w) pointArray.resize(w); if(lookup.size() != w) lookup.resize(w); NoteData *currentNote = active->getCurrentNote(); Array1d<float> *input = &(active->nsdfData); if(currentNote) { if(aggregateMode == 1) input = ¤tNote->nsdfAggregateData; else if(aggregateMode == 2) input = ¤tNote->nsdfAggregateDataScaled; } //bresenham1d(*input, lookup); maxAbsDecimate1d(*input, lookup); for(int j=0; j<w; j++) { pointArray.setPoint(j, j*2, toInt(dh2 - lookup[j]*dh2)); } p.setPen(QPen(active->color, 0)); p.drawPolyline(pointArray); } if(data && (aggregateMode == 0)) { double ratio = double(width()) / double(active->nsdfData.size()); //pixels per index //float highest = active->nsdfData.at(data->highestCorrelationIndex); //float chosen = active->nsdfData.at(data->chosenCorrelationIndex); //draw a dot at all the period estimates p.setPen(Qt::blue); p.setBrush(Qt::blue); for(j=0; j<int(data->getPeriodEstimatesSize()); j++) { x = toInt(double(data->getPeriodEstimatesAt(j)) * ratio); y = toInt(dh2 - data->getPeriodEstimatesAmpAt(j) * dh2); p.drawEllipse(x-2, y-2, 5, 5); } if(data->getHighestCorrelationIndex() >= 0) { float highest = data->getPeriodEstimatesAmpAt(data->getHighestCorrelationIndex()); //draw threshold line p.setPen(QPen(colorBetween(colorGroup().background(), Qt::black, 0.3), 0)); y = toInt(dh2 - (highest * active->threshold()) * dh2); p.drawLine(0, y, width(), y);//.........这里部分代码省略.........
开发者ID:nsauzede,项目名称:tartini,代码行数:101,
示例22: deleteValue//在interpreter中检测table是否存在//与rm交互,根据条件删除表中数据//与im交互删除index(如果存在)int APIManager:: deleteValue(string tablename, vector<Conditions> &condition){ int total = 0; int tableIndex = catalogmanager.findTable(tablename); for(size_t i =0; i < condition.size(); ++i) { int attriNum = catalogmanager.getAttriNum(catalogmanager.Vtable[tableIndex], condition[i].attribute); switch (catalogmanager.Vtable[tableIndex].attributes[attriNum].type) { case INT: total += recordmanager.deleteRow(catalogmanager.Vtable[tableIndex], condition[i].attribute, toInt(condition[i].attributeValue), condition[i].condition_type); break; case FLOAT: total += recordmanager.deleteRow(catalogmanager.Vtable[tableIndex], condition[i].attribute, toFloat(condition[i].attributeValue), condition[i].condition_type); break; case CHAR: total += recordmanager.deleteRow(catalogmanager.Vtable[tableIndex], condition[i].attribute, condition[i].attributeValue, condition[i].condition_type); break; } } for(size_t i = 0; i < condition.size(); ++i) { int attriNum = catalogmanager.getAttriNum(catalogmanager.Vtable[tableIndex], condition[i].attribute); if(catalogmanager.Vtable[tableIndex].attributes[attriNum].indexName != "NULL") { switch (catalogmanager.Vtable[tableIndex].attributes[attriNum].type) { case INT: indexmanager.afterDelete(catalogmanager.Vtable[tableIndex].attributes[attriNum], format(toInt(condition[i].attributeValue)), catalogmanager.Vtable[tableIndex]); break; case FLOAT: indexmanager.afterDelete(catalogmanager.Vtable[tableIndex].attributes[attriNum], format(toFloat(condition[i].attributeValue)), catalogmanager.Vtable[tableIndex]); break; case CHAR: indexmanager.afterDelete(catalogmanager.Vtable[tableIndex].attributes[attriNum], condition[i].attributeValue, catalogmanager.Vtable[tableIndex]); break; } } } return total;}
开发者ID:crabyh,项目名称:MiniSQL,代码行数:42,
示例23: toFloat//.........这里部分代码省略......... // @ATTR cooldown_hit|duration|Duration of cooldown after being hit in 'ms' or 's'. cooldown_hit = parse_duration(infile->val); return true; } else if (infile->key == "stat") { // @ATTR stat|string, int : Stat name, Value|The starting value for this stat. std::string stat = popFirstString(infile->val); int value = popFirstInt(infile->val); for (size_t i=0; i<STAT_COUNT; ++i) { if (STAT_KEY[i] == stat) { starting[i] = value; return true; } } for (size_t i = 0; i < DAMAGE_TYPES.size(); ++i) { if (DAMAGE_TYPES[i].min == stat) { starting[STAT_COUNT + (i*2)] = value; return true; } else if (DAMAGE_TYPES[i].max == stat) { starting[STAT_COUNT + (i*2) + 1] = value; return true; } } } else if (infile->key == "stat_per_level") { // @ATTR stat_per_level|predefined_string, int : Stat name, Value|The value for this stat added per level. std::string stat = popFirstString(infile->val); int value = popFirstInt(infile->val); for (unsigned i=0; i<STAT_COUNT; i++) { if (STAT_KEY[i] == stat) { per_level[i] = value; return true; } } for (size_t i = 0; i < DAMAGE_TYPES.size(); ++i) { if (DAMAGE_TYPES[i].min == stat) { per_level[STAT_COUNT + (i*2)] = value; return true; } else if (DAMAGE_TYPES[i].max == stat) { per_level[STAT_COUNT + (i*2) + 1] = value; return true; } } } else if (infile->key == "stat_per_primary") { // @ATTR stat_per_primary|predefined_string, predefined_string, int : Primary Stat, Stat name, Value|The value for this stat added for every point allocated to this primary stat. std::string prim_stat = popFirstString(infile->val); size_t prim_stat_index = getPrimaryStatIndex(prim_stat); std::string stat = popFirstString(infile->val); int value = popFirstInt(infile->val); for (unsigned i=0; i<STAT_COUNT; i++) { if (STAT_KEY[i] == stat) { per_primary[prim_stat_index][i] = value; return true; } } for (size_t i = 0; i < DAMAGE_TYPES.size(); ++i) { if (DAMAGE_TYPES[i].min == stat) { per_primary[prim_stat_index][STAT_COUNT + (i*2)] = value; return true; } else if (DAMAGE_TYPES[i].max == stat) { per_primary[prim_stat_index][STAT_COUNT + (i*2) + 1] = value; return true; } } } else if (infile->key == "vulnerable") { // @ATTR vulnerable|predefined_string, int : Element, Value|Percentage weakness to this element. std::string element = popFirstString(infile->val); int value = popFirstInt(infile->val); for (unsigned int i=0; i<ELEMENTS.size(); i++) { if (element == ELEMENTS[i].id) { vulnerable[i] = vulnerable_base[i] = value; return true; } } } else if (infile->key == "power_filter") { // @ATTR power_filter|list(power_id)|Only these powers are allowed to hit this entity. std::string power_id = popFirstString(infile->val); while (!power_id.empty()) { power_filter.push_back(toInt(power_id)); power_id = popFirstString(infile->val); } return true; } return false;}
开发者ID:igorko,项目名称:flare-engine,代码行数:101,
示例24: MenuMenuVendor::MenuVendor(StatBlock *_stats) : Menu() , stats(_stats) , closeButton(new WidgetButton("images/menus/buttons/button_x.png")) , tabControl(new WidgetTabControl()) , slots_cols(1) , slots_rows(1) , activetab(VENDOR_BUY) , color_normal(font->getColor("menu_normal")) , npc(NULL) , buyback_stock() { setBackground("images/menus/vendor.png"); tabControl->setTabTitle(VENDOR_BUY, msg->get("Inventory")); tabControl->setTabTitle(VENDOR_SELL, msg->get("Buyback")); // Load config settings FileParser infile; // @CLASS MenuVendor|Description of menus/vendor.txt if(infile.open("menus/vendor.txt")) { while(infile.next()) { if (parseMenuKey(infile.key, infile.val)) continue; // @ATTR close|point|Position of the close button. if(infile.key == "close") { Point pos = toPoint(infile.val); closeButton->setBasePos(pos.x, pos.y); } // @ATTR slots_area|point|Position of the top-left slot. else if(infile.key == "slots_area") { slots_area.x = popFirstInt(infile.val); slots_area.y = popFirstInt(infile.val); } // @ATTR vendor_cols|int|The number of columns in the grid of slots. else if (infile.key == "vendor_cols") { slots_cols = std::max(1, toInt(infile.val)); } // @ATTR vendor_rows|int|The number of rows in the grid of slots. else if (infile.key == "vendor_rows") { slots_rows = std::max(1, toInt(infile.val)); } // @ATTR label_title|label|The position of the text that displays the NPC's name. else if (infile.key == "label_title") { title = eatLabelInfo(infile.val); } else { infile.error("MenuVendor: '%s' is not a valid key.", infile.key.c_str()); } } infile.close(); } VENDOR_SLOTS = slots_cols * slots_rows; slots_area.w = slots_cols*ICON_SIZE; slots_area.h = slots_rows*ICON_SIZE; stock[VENDOR_BUY].initGrid(VENDOR_SLOTS, slots_area, slots_cols); stock[VENDOR_SELL].initGrid(VENDOR_SLOTS, slots_area, slots_cols); tablist.add(tabControl); tablist_buy.setPrevTabList(&tablist); tablist_sell.setPrevTabList(&tablist); tablist_buy.lock(); tablist_sell.lock(); for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist_buy.add(stock[VENDOR_BUY].slots[i]); } for (unsigned i = 0; i < VENDOR_SLOTS; i++) { tablist_sell.add(stock[VENDOR_SELL].slots[i]); } align();}
开发者ID:hansjoachim,项目名称:flare-engine,代码行数:76,
示例25: while/** * load a statblock, typically for an enemy definition */void StatBlock::load(const std::string& filename) { // @CLASS StatBlock: Enemies|Description of enemies in enemies/ FileParser infile; if (!infile.open(filename)) return; bool clear_loot = true; bool flee_range_defined = false; while (infile.next()) { if (infile.new_section) { // APPENDed file clear_loot = true; } int num = toInt(infile.val); float fnum = toFloat(infile.val); bool valid = loadCoreStat(&infile) || loadSfxStat(&infile); // @ATTR name|string|Name if (infile.key == "name") name = msg->get(infile.val); // @ATTR humanoid|bool|This creature gives human traits when transformed into, such as the ability to talk with NPCs. else if (infile.key == "humanoid") humanoid = toBool(infile.val); // @ATTR level|int|Level else if (infile.key == "level") level = num; // enemy death rewards and events // @ATTR xp|int|XP awarded upon death. else if (infile.key == "xp") xp = num; else if (infile.key == "loot") { // @ATTR loot|repeatable(loot)|Possible loot that can be dropped on death. // loot entries format: // loot=[id],[percent_chance] // optionally allow range: // loot=[id],[percent_chance],[count_min],[count_max] if (clear_loot) { loot_table.clear(); clear_loot = false; } loot_table.push_back(Event_Component()); loot->parseLoot(infile.val, &loot_table.back(), &loot_table); } else if (infile.key == "loot_count") { // @ATTR loot_count|int, int : Min, Max|Sets the minimum (and optionally, the maximum) amount of loot this creature can drop. Overrides the global drop_max setting. loot_count.x = popFirstInt(infile.val); loot_count.y = popFirstInt(infile.val); if (loot_count.x != 0 || loot_count.y != 0) { loot_count.x = std::max(loot_count.x, 1); loot_count.y = std::max(loot_count.y, loot_count.x); } } // @ATTR defeat_status|string|Campaign status to set upon death. else if (infile.key == "defeat_status") defeat_status = infile.val; // @ATTR convert_status|string|Campaign status to set upon being converted to a player ally. else if (infile.key == "convert_status") convert_status = infile.val; // @ATTR first_defeat_loot|item_id|Drops this item upon first death. else if (infile.key == "first_defeat_loot") first_defeat_loot = num; // @ATTR quest_loot|string, string, item_id : Required status, Required not status, Item|Drops this item when campaign status is met. else if (infile.key == "quest_loot") { quest_loot_requires_status = popFirstString(infile.val); quest_loot_requires_not_status = popFirstString(infile.val); quest_loot_id = popFirstInt(infile.val); } // behavior stats // @ATTR flying|bool|Creature can move over gaps/water. else if (infile.key == "flying") flying = toBool(infile.val); // @ATTR intangible|bool|Creature can move through walls. else if (infile.key == "intangible") intangible = toBool(infile.val); // @ATTR facing|bool|Creature can turn to face their target. else if (infile.key == "facing") facing = toBool(infile.val); // @ATTR waypoint_pause|duration|Duration to wait at each waypoint in 'ms' or 's'. else if (infile.key == "waypoint_pause") waypoint_pause = parse_duration(infile.val); // @ATTR turn_delay|duration|Duration it takes for this creature to turn and face their target in 'ms' or 's'. else if (infile.key == "turn_delay") turn_delay = parse_duration(infile.val); // @ATTR chance_pursue|int|Percentage change that the creature will chase their target. else if (infile.key == "chance_pursue") chance_pursue = num; // @ATTR chance_flee|int|Percentage chance that the creature will run away from their target. else if (infile.key == "chance_flee") chance_flee = num; else if (infile.key == "power") { // @ATTR power|["melee", "ranged", "beacon", "on_hit", "on_death", "on_half_dead", "on_join_combat", "on_debuff"], power_id, int : State, Power, Chance|A power that has a chance of being triggered in a certain state. AIPower ai_power; std::string ai_type = popFirstString(infile.val); ai_power.id = powers->verifyID(popFirstInt(infile.val), &infile, false); if (ai_power.id == 0) continue; // verifyID() will print our error message ai_power.chance = popFirstInt(infile.val);//.........这里部分代码省略.........
开发者ID:igorko,项目名称:flare-engine,代码行数:101,
注:本文中的toInt函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ toInt32函数代码示例 C++ toHex函数代码示例 |