Example #1
0
            bvres_t update() override
            {
                if(!m_done_res.has_value()){
                    m_timer.reset();
                }

                if(!m_done_res.has_value() || m_done_res.value() == BV_PENDING){
                    m_done_res.emplace(m_operation->update());
                    switch(auto op_status = m_done_res.value()){
                        case BV_ABORT:
                        case BV_PENDING:
                            {
                                return op_status;
                            }
                        case BV_FAILURE:
                        case BV_SUCCESS:
                            {
                                break;
                            }
                        default:
                            {
                                throw std::runtime_error(str_fflprintf(": Invalid node status: %d", op_status));
                            }
                    }
                }

                if(m_timer.diff_msec() > m_slowdown){
                    return m_done_res.value();
                }else{
                    return BV_PENDING;
                }
            }
Example #2
0
RWConfig GameBase::buildConfig(const std::optional<RWArgConfigLayer> &args) {
    RWConfig config;
    if (args.has_value()) {
        config.setLayer(RWConfig::LAYER_ARGUMENT, *args);
    }
    auto defaultLayer = buildDefaultConfigLayer();
    config.setLayer(RWConfig::LAYER_DEFAULT, defaultLayer);

    rwfs::path configPath;
    if (args.has_value() && args->configPath.has_value()) {
        configPath = *args->configPath;
    } else {
        configPath = RWConfigParser::getDefaultConfigPath() / "openrw.ini";
    }

    if ((!args) || (args && !args->noconfig)) {
        RWConfigParser configParser{};
        auto [configLayer, parseResult] = configParser.loadFile(configPath);

        if (!parseResult.isValid()) {
            log.error("Config", "Could not read configuation file at " + configPath.string());
            throw std::runtime_error(parseResult.what());
        }
        config.unknown = parseResult.getUnknownData();
        config.setLayer(RWConfig::LAYER_CONFIGFILE, configLayer);
    }
Example #3
0
        game_value remote_exec(const game_value &params_, sqf_string_const_ref function_, std::variant<int, object, sqf_string_const_ref_wrapper, side, group, std::reference_wrapper<const std::vector<game_value>>> targets_, std::optional<std::variant<sqf_string_const_ref_wrapper, bool, object, group>> jip_) {
            game_value targets;
            game_value jip;
            switch (targets_.index()) {
            case 0: targets = static_cast<float>(std::get<int>(targets_)); break;
            case 1: targets = std::get<object>(targets_); break;
            case 2: targets = std::get<2>(targets_).get(); break;
            case 3: targets = std::get<side>(targets_); break;
            case 4: targets = std::get<group>(targets_); break;
            case 5: targets = std::move(auto_array<game_value>({ std::get<5>(targets_).get().begin(), std::get<5>(targets_).get().end() })); break;
            }

            if (jip_.has_value()) {
                switch ((*jip_).index()) {
                case 0: jip = std::get<0>(*jip_).get(); break;
                case 1: jip = std::get<bool>(*jip_); break;
                case 2: jip = std::get<object>(*jip_); break;
                case 3: jip = std::get<group>(*jip_); break;
                }
            }
            game_value params_right = game_value({
                function_,
                targets,
                jip
            });

            return host::functions.invoke_raw_binary(__sqf::binary__remoteexec__any__array__ret__any, params_, params_right);
        }
Example #4
0
	static void make_vt_sequence(span<const FAR_CHAR_INFO> Input, string& Str, std::optional<FarColor>& LastColor)
	{
		for (const auto& i: Input)
		{
			if (!LastColor.has_value() || i.Attributes != *LastColor)
			{
				make_vt_attributes(i.Attributes, Str, LastColor);
				LastColor = i.Attributes;
			}

			Str += ReplaceControlCharacter(i.Char);
		}
	}
Example #5
0
	static void make_vt_attributes(const FarColor& Attributes, string& Str, std::optional<FarColor> const& LastColor)
	{
		append(Str, L"\033["sv);

		if (Attributes.IsFg4Bit())
		{
			append(Str, Attributes.ForegroundColor & FOREGROUND_INTENSITY? L'9' : L'3', vt_color_index(Attributes.ForegroundColor));
		}
		else
		{
			const auto& c = Attributes.ForegroundRGBA;
			Str += format(L"38;2;{0};{1};{2}"sv, c.r, c.g, c.b);
		}

		Str += L';';

		if (Attributes.IsBg4Bit())
		{
			append(Str, Attributes.BackgroundColor & FOREGROUND_INTENSITY? L"10"sv : L"4"sv, vt_color_index(Attributes.BackgroundColor));
		}
		else
		{
			const auto& c = Attributes.BackgroundRGBA;
			Str += format(L"48;2;{0};{1};{2}"sv, c.r, c.g, c.b);
		}

		if (Attributes.Flags & FCF_FG_UNDERLINE)
		{
			if (!LastColor.has_value() || !(LastColor->Flags & FCF_FG_UNDERLINE))
				Str += L";4"sv;
		}
		else
		{
			if (LastColor.has_value() && LastColor->Flags & FCF_FG_UNDERLINE)
				Str += L";24"sv;
		}

		Str += L'm';
	}
Example #6
0
// Routine Description:
// - Remaps all of the stored items to new coordinate positions
//   based on a bulk rearrangement of row IDs and potential row width resize.
// Arguments:
// - rowMap - A map of the old row IDs to the new row IDs.
// - width - The width of the new row. Remove any items that are beyond the row width.
//         - Use nullopt if we're not resizing the width of the row, just renumbering the rows.
void UnicodeStorage::Remap(const std::map<SHORT, SHORT>& rowMap, const std::optional<SHORT> width)
{
    // Make a temporary map to hold all the new row positioning
    std::unordered_map<key_type, mapped_type> newMap;

    // Walk through every stored item.
    for (const auto& pair : _map)
    {
        // Extract the old coordinate position
        const auto oldCoord = pair.first;

        // Only try to short-circuit based on width if we were told it changed
        // by being given a new width value.
        if (width.has_value())
        {
            // Get the column ID
            const auto oldColId = oldCoord.X;

            // If the column index is at/beyond the row width, don't bother copying it to the new map.
            if (oldColId >= width.value())
            {
                continue;
            }
        }

        // Get the row ID from the position as that's what we need to remap
        const auto oldRowId = oldCoord.Y;

        // Use the mapping given to convert the old row ID to the new row ID
        const auto mapIter = rowMap.find(oldRowId);

        // If there's no mapping to a new row, don't bother copying it to the new map. The row is gone.
        if (mapIter == rowMap.end())
        {
            continue;
        }

        const auto newRowId = mapIter->second;

        // Generate a new coordinate with the same X as the old one, but a new Y value.
        const auto newCoord = COORD{ oldCoord.X, newRowId };

        // Put the adjusted coordinate into the map with the original value.
        newMap.emplace(newCoord, pair.second);
    }

    // Swap into the stored map, free the temporary when we exit.
    _map.swap(newMap);
}
Example #7
0
        task create_simple_task(const object &unit_, sqf_string_const_ref name_, std::optional<task> parent_task_) {
            game_value params_right(parent_task_.has_value() ? game_value{ name_, *parent_task_ } : game_value{ name_ });

            return host::functions.invoke_raw_binary(__sqf::binary__createsimpletask__object__array__ret__task, unit_, params_right);
        }