当前位置: 首页>>代码示例>>C++>>正文


C++ color_ostream::printerr方法代码示例

本文整理汇总了C++中color_ostream::printerr方法的典型用法代码示例。如果您正苦于以下问题:C++ color_ostream::printerr方法的具体用法?C++ color_ostream::printerr怎么用?C++ color_ostream::printerr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在color_ostream的用法示例。


在下文中一共展示了color_ostream::printerr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AssertCoreSuspend

void DFHack::Lua::InvokeEvent(color_ostream &out, lua_State *state, void *key, int num_args)
{
    AssertCoreSuspend(state);

    int base = lua_gettop(state) - num_args;

    if (!lua_checkstack(state, num_args+4))
    {
        out.printerr("Stack overflow in Lua::InvokeEvent");
        lua_settop(state, base);
        return;
    }

    lua_rawgetp(state, LUA_REGISTRYINDEX, key);

    if (!lua_istable(state, -1))
    {
        if (!lua_isnil(state, -1))
            out.printerr("Invalid event object in Lua::InvokeEvent");
        lua_settop(state, base);
        return;
    }

    lua_insert(state, base+1);

    color_ostream *cur_out = Lua::GetOutput(state);
    set_dfhack_output(state, &out);
    dfhack_event_invoke(state, base, true);
    set_dfhack_output(state, cur_out);
}
开发者ID:Elvang,项目名称:dfhack,代码行数:30,代码来源:LuaTools.cpp

示例2: outsideOnly

command_result outsideOnly(color_ostream& out, vector<string>& parameters) {
    int32_t status = 2;
    for ( size_t a = 0; a < parameters.size(); a++ ) {
        if ( parameters[a] == "clear" ) {
            registeredBuildings.clear();
        } else if ( parameters[a] == "outside" ) {
            status = OUTSIDE_ONLY;
        } else if ( parameters[a] == "inside" ) {
            status = INSIDE_ONLY;
        } else if ( parameters[a] == "either" ) {
            status = EITHER;
        } else if ( parameters[a] == "checkEvery" ) {
            if (a+1 >= parameters.size()) {
                out.printerr("You must specify how often to check.\n");
                return CR_WRONG_USAGE;
            }
            checkEvery = atoi(parameters[a].c_str());
        }
        else {
            if ( status == 2 ) {
                out.printerr("Error: you need to tell outsideOnly whether the building is inside only, outside-only or either.\n");
                return CR_WRONG_USAGE;
            }
            registeredBuildings[parameters[a]] = status;
        }
    }
    out.print("outsideOnly is %s\n", enabled ? "enabled" : "disabled");
    if ( enabled ) {
        
    }
    return CR_OK;
}
开发者ID:quietust,项目名称:dfhack-23a,代码行数:32,代码来源:outsideOnly.cpp

示例3: spotclean

command_result spotclean (color_ostream &out, vector <string> & parameters)
{
    // HOTKEY COMMAND: CORE ALREADY SUSPENDED
    if (cursor->x == -30000)
    {
        out.printerr("The cursor is not active.\n");
        return CR_WRONG_USAGE;
    }
    if (!Maps::IsValid())
    {
        out.printerr("Map is not available.\n");
        return CR_FAILURE;
    }
    df::map_block *block = Maps::getTileBlock(cursor->x, cursor->y, cursor->z);
    if (block == NULL)
    {
        out.printerr("Invalid map block selected!\n");
        return CR_FAILURE;
    }

    for (size_t i = 0; i < block->block_events.size(); i++)
    {
        df::block_square_event *evt = block->block_events[i];
        if (evt->getType() != block_square_event_type::material_spatter)
            continue;
        // type verified - recast to subclass
        df::block_square_event_material_spatterst *spatter = (df::block_square_event_material_spatterst *)evt;
        spatter->amount[cursor->x % 16][cursor->y % 16] = 0;
    }
    return CR_OK;
}
开发者ID:BenLubar,项目名称:dfhack,代码行数:31,代码来源:cleaners.cpp

示例4: unload

bool Plugin::unload(color_ostream &con)
{
    // get the mutex
    access->lock();
    // if we are actually loaded
    if(state == PS_LOADED)
    {
        EventManager::unregisterAll(this);
        // notify the plugin about an attempt to shutdown
        if (plugin_onstatechange &&
            plugin_onstatechange(con, SC_BEGIN_UNLOAD) != CR_OK)
        {
            con.printerr("Plugin %s has refused to be unloaded.\n", name.c_str());
            access->unlock();
            return false;
        }
        // wait for all calls to finish
        access->wait();
        state = PS_UNLOADING;
        access->unlock();
        // enter suspend
        CoreSuspender suspend;
        access->lock();
        // notify plugin about shutdown, if it has a shutdown function
        command_result cr = CR_OK;
        if(plugin_shutdown)
            cr = plugin_shutdown(con);
        // cleanup...
        plugin_is_enabled = 0;
        plugin_onupdate = 0;
        reset_lua();
        parent->unregisterCommands(this);
        commands.clear();
        if(cr == CR_OK)
        {
            ClosePlugin(plugin_lib);
            state = PS_UNLOADED;
            access->unlock();
            return true;
        }
        else
        {
            con.printerr("Plugin %s has failed to shutdown!\n",name.c_str());
            state = PS_BROKEN;
            access->unlock();
            return false;
        }
    }
    else if(state == PS_UNLOADED)
    {
        access->unlock();
        return true;
    }
    access->unlock();
    return false;
}
开发者ID:maxthyme,项目名称:dfhack,代码行数:56,代码来源:PluginManager.cpp

示例5: rename

static command_result rename(color_ostream &out, vector <string> &parameters)
{
    CoreSuspender suspend;

    string cmd;
    if (!parameters.empty())
        cmd = parameters[0];

    if (cmd == "hotkey")
    {
        if (parameters.size() != 3)
            return CR_WRONG_USAGE;

        int id = atoi(parameters[1].c_str());
        if (id < 1 || id > 16) {
            out.printerr("Invalid hotkey index\n");
            return CR_WRONG_USAGE;
        }

        ui->main.hotkeys[id-1].name = parameters[2];
    }
    else if (cmd == "unit")
    {
        if (parameters.size() != 2)
            return CR_WRONG_USAGE;

        df::unit *unit = Gui::getSelectedUnit(out, true);
        if (!unit)
            return CR_WRONG_USAGE;

        Units::setNickname(unit, parameters[1]);
    }
    else if (cmd == "unit-profession")
    {
        if (parameters.size() != 2)
            return CR_WRONG_USAGE;

        df::unit *unit = Gui::getSelectedUnit(out, true);
        if (!unit)
            return CR_WRONG_USAGE;

        unit->custom_profession = parameters[1];
    }
    else
    {
        if (!parameters.empty() && cmd != "?")
            out.printerr("Invalid command: %s\n", cmd.c_str());
        return CR_WRONG_USAGE;
    }

    return CR_OK;
}
开发者ID:mstram,项目名称:dfhack-40d,代码行数:52,代码来源:rename.cpp

示例6: recover_job

static bool recover_job(color_ostream &out, ProtectedJob *pj)
{
    if (pj->isLive())
        return true;

    // Check that the building exists
    pj->holder = df::building::find(pj->building_id);
    if (!pj->holder)
    {
        out.printerr("Forgetting job %d (%s): holder building lost.\n",
                        pj->id, ENUM_KEY_STR(job_type, pj->job_copy->job_type).c_str());
        forget_job(out, pj);
        return true;
    }

    // Check its state and postpone or cancel if invalid
    if (pj->holder->jobs.size() >= 10)
    {
        out.printerr("Forgetting job %d (%s): holder building has too many jobs.\n",
                        pj->id, ENUM_KEY_STR(job_type, pj->job_copy->job_type).c_str());
        forget_job(out, pj);
        return true;
    }

    if (!pj->holder->jobs.empty())
    {
        df::job_type ftype = pj->holder->jobs[0]->job_type;
        if (ftype == job_type::DestroyBuilding)
            return false;

        if (ENUM_ATTR(job_type,type,ftype) == job_type_class::StrangeMood)
            return false;
    }

    // Create and link in the actual job structure
    df::job *recovered = Job::cloneJobStruct(pj->job_copy);

    if (!Job::linkIntoWorld(recovered, false)) // reuse same id
    {
        Job::deleteJobStruct(recovered);

        out.printerr("Inconsistency: job %d (%s) already in list.\n",
                        pj->id, ENUM_KEY_STR(job_type, pj->job_copy->job_type).c_str());
        return true;
    }

    pj->holder->jobs.push_back(recovered);

    // Done
    pj->recover(recovered);
    return true;
}
开发者ID:Reag,项目名称:dfhack,代码行数:52,代码来源:workflow.cpp

示例7: cmd_fix_unit_occupancy

command_result cmd_fix_unit_occupancy (color_ostream &out, std::vector <std::string> & parameters)
{
    CoreSuspender suspend;
    uo_opts opts;
    bool ok = true;

    if (parameters.size() >= 1 && (parameters[0] == "-i" || parameters[0].find("interval") != std::string::npos))
    {
        if (parameters.size() >= 2)
        {
            int new_interval = atoi(parameters[1].c_str());
            if (new_interval < 100)
            {
                out.printerr("Invalid interval - minimum is 100 ticks\n");
                return CR_WRONG_USAGE;
            }
            run_interval = new_interval;
            if (!is_enabled)
                out << "note: Plugin not enabled (use `enable fix-unit-occupancy` to enable)" << endl;
            return CR_OK;
        }
        else
            return CR_WRONG_USAGE;
    }

    for (auto opt = parameters.begin(); opt != parameters.end(); ++opt)
    {
        if (*opt == "-n" || opt->find("dry") != std::string::npos)
            opts.dry_run = true;
        else if (*opt == "-h" || opt->find("cursor") != std::string::npos || opt->find("here") != std::string::npos)
            opts.use_cursor = true;
        else if (opt->find("enable") != std::string::npos)
            plugin_enable(out, true);
        else if (opt->find("disable") != std::string::npos)
            plugin_enable(out, false);
        else
        {
            out.printerr("Unknown parameter: %s\n", opt->c_str());
            ok = false;
        }
    }
    if (!ok)
        return CR_WRONG_USAGE;

    unsigned count = fix_unit_occupancy(out, opts);
    if (!count)
        out << "No occupancy issues found." << endl;

    return CR_OK;
}
开发者ID:HarryFromMarydelDE,项目名称:dfhack,代码行数:50,代码来源:fix-unit-occupancy.cpp

示例8: generator

command_result cmd_3dveins(color_ostream &con, std::vector<std::string> & parameters)
{
    bool verbose = false;

    for (size_t i = 0; i < parameters.size(); i++)
    {
        if (parameters[i] == "verbose")
            verbose = true;
        else
            return CR_WRONG_USAGE;
    }

    CoreSuspender suspend;

    if (!Maps::IsValid())
    {
        con.printerr("Map is not available!\n");
        return CR_FAILURE;
    }

    if (*gametype != game_type::DWARF_MAIN && *gametype != game_type::DWARF_RECLAIM)
    {
        con.printerr("Must be used in fortress mode!\n");
        return CR_FAILURE;
    }

    VeinGenerator generator(con);

    con.print("Collecting statistics...\n");

    if (!generator.init_biomes())
        return CR_FAILURE;
    if (!generator.scan_tiles())
        return CR_FAILURE;

    con.print("Generating veins...\n");

    if (!generator.form_veins())
        return CR_FAILURE;
    if (!generator.place_veins(verbose))
        return CR_FAILURE;

    con.print("Writing tiles...\n");

    generator.write_tiles();

    return CR_OK;
}
开发者ID:BenLubar,项目名称:dfhack,代码行数:48,代码来源:3dveins.cpp

示例9: df_cleanconst

command_result df_cleanconst(color_ostream &out, vector <string> & parameters)
{
    CoreSuspender suspend;

    if (!Maps::IsValid())
    {
        out.printerr("Map is not available!\n");
        return CR_FAILURE;
    }
    size_t numItems = world->items.all.size();

    int cleaned_total = 0;

    // proceed with the cleanup operation
    for (size_t i = 0; i < numItems; i++)
    {
        df::item *item = world->items.all[i];
        // only process items marked as "in construction"
        if (!item->flags.bits.construction)
            continue;
        df::coord pos(item->pos.x, item->pos.y, item->pos.z);

        df::construction *cons = df::construction::find(pos);
        if (!cons)
        {
            out.printerr("Item at %i,%i,%i marked as construction but no construction is present!\n", pos.x, pos.y, pos.z);
            continue;
        }
        // if the construction is already labeled as "no build item", then leave it alone
        if (cons->flags.bits.no_build_item)
            continue;

        // only destroy the item if the construction claims to be made of the exact same thing
        if (item->getType() != cons->item_type ||
            item->getSubtype() != cons->item_subtype ||
            item->getMaterial() != cons->mat_type ||
            item->getMaterialIndex() != cons->mat_index)
            continue;

        item->flags.bits.garbage_collect = 1;
        cons->flags.bits.no_build_item = 1;

        cleaned_total++;
    }

    out.print("Done. %d construction items cleaned up.\n", cleaned_total);
    return CR_OK;
}
开发者ID:Alloyed,项目名称:dfhack,代码行数:48,代码来源:cleanconst.cpp

示例10: df_grow

command_result df_grow (color_ostream &out, vector <string> & parameters)
{
    for(size_t i = 0; i < parameters.size();i++)
    {
        if(parameters[i] == "help" || parameters[i] == "?")
        {
            out << "Usage:\n"
                "This command turns all living saplings on the map into full-grown trees.\n"
                "With active cursor, work on the targetted one only.\n";
            return CR_OK;
        }
    }

    CoreSuspender suspend;

    if (!Maps::IsValid())
    {
        out.printerr("Map is not available!\n");
        return CR_FAILURE;
    }
    MapExtras::MapCache map;
    int32_t x,y,z;
    if(Gui::getCursorCoords(x,y,z))
    {
        auto block = Maps::getTileBlock(x,y,z);
        stl::vector<df::plant *> *alltrees = &world->plants.all;
        if(alltrees)
        {
            for(size_t i = 0 ; i < alltrees->size(); i++)
            {
                df::plant * tree = alltrees->at(i);
                if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z)
                {
                    if(tileShape(map.tiletypeAt(DFCoord(x,y,z))) == tiletype_shape::SAPLING &&
                        tileSpecial(map.tiletypeAt(DFCoord(x,y,z))) != tiletype_special::DEAD)
                    {
                        tree->grow_counter = sapling_to_tree_threshold;
                    }
                    break;
                }
            }
        }
    }
    else
    {
        int grown = 0;
        for(size_t i = 0 ; i < world->plants.all.size(); i++)
        {
            df::plant *p = world->plants.all[i];
            df::tiletype ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z));
            bool is_shrub = p->flags >= plant_flags::shrub_forest;
            if(!is_shrub && tileShape(ttype) == tiletype_shape::SAPLING && tileSpecial(ttype) != tiletype_special::DEAD)
            {
                p->grow_counter = sapling_to_tree_threshold;
            }
        }
    }

    return CR_OK;
}
开发者ID:quietust,项目名称:dfhack-23a,代码行数:60,代码来源:plants.cpp

示例11: lair

command_result lair(color_ostream &out, std::vector<std::string> & params)
{
    state do_what = LAIR_SET;
    for(auto iter = params.begin(); iter != params.end(); iter++)
    {
        if(*iter == "reset")
            do_what = LAIR_RESET;
    }
    CoreSuspender lock;
    if (!Maps::IsValid())
    {
        out.printerr("Map is not available!\n");
        return CR_FAILURE;
    }
    uint32_t x_max,y_max,z_max;
    Maps::getSize(x_max,y_max,z_max);
    for (size_t i = 0; i < world->map.map_blocks.size(); i++)
    {
        df::map_block *block = world->map.map_blocks[i];
        DFHack::occupancies40d & occupancies = block->occupancy;
        // for each tile in block
        for (uint32_t x = 0; x < 16; x++) for (uint32_t y = 0; y < 16; y++)
        {
            // set to revealed
            occupancies[x][y].bits.monster_lair = (do_what == LAIR_SET);
        }
    }
    if(do_what == LAIR_SET)
        out.print("Map marked as lair.\n");
    else
        out.print("Map no longer marked as lair.\n");
    return CR_OK;
}
开发者ID:Dimble,项目名称:dfhack,代码行数:33,代码来源:lair.cpp

示例12: df_immolate

command_result df_immolate (color_ostream &out, vector <string> & parameters, do_what what)
{
    bool shrubs = false, trees = false, help = false;
    if (getoptions(parameters, shrubs, trees, help) && !help)
    {
        return immolations(out, what, shrubs, trees);
    }

    string mode;
    if (what == do_immolate)
        mode = "Set plants on fire";
    else
        mode = "Kill plants";

    if (!help)
        out.printerr("Invalid parameter!\n");

    out << "Usage:\n" <<
        mode << " (under cursor, 'shrubs', 'trees' or 'all').\n"
        "Without any options, this command acts on the plant under the cursor.\n"
        "Options:\n"
        "shrubs   - affect all shrubs\n"
        "trees    - affect all trees\n"
        "all      - affect all plants\n";

    return CR_OK;
}
开发者ID:quietust,项目名称:dfhack-23a,代码行数:27,代码来源:plants.cpp

示例13: wagonshot

command_result wagonshot (color_ostream &out, vector <string> & parameters)
{
	CoreSuspender suspend;
	int32_t cursorX, cursorY, cursorZ;
	Gui::getCursorCoords(cursorX,cursorY,cursorZ);
	if(cursorX == -30000)
	{
		out.printerr("No cursor; place cursor over creature to murder.\n");
	}
	else
	{
		for(size_t i = 0; i < world->units.all.size(); i++)
		{
			df::unit * unit = world->units.all[i];
			if(unit->pos.x == cursorX && unit->pos.y == cursorY && unit->pos.z == cursorZ)
			{
				if (parameters.size() == 1 && (parameters[0] == "--kill" || parameters[0] == "-k"))
				{
					unit->flags3.bits.scuttle = 1;
					//out.print("Boom! Wagonshot!\n");
					continue;
				}
				else
				{
					out.print("'wagonshot --kill' short and sweet\n(or 'wagonshot -k' even shorter). No condiments needed. That's what the wagon provides.\nNow show me where we drop the wagon.\n");
					break;
				}
			}
		}
	}
	return CR_OK;
}
开发者ID:EldrickWT,项目名称:dfhack,代码行数:32,代码来源:wagonshot.cpp

示例14: init_state

static void init_state(color_ostream &out)
{
    auto pworld = Core::getInstance().getWorld();

    config = pworld->GetPersistentData("workflow/config");
    if (config.isValid() && config.ival(0) == -1)
        config.ival(0) = 0;

    enabled = isOptionEnabled(CF_ENABLED);

    // Parse constraints
    std::vector<PersistentDataItem> items;
    pworld->GetPersistentData(&items, "workflow/constraints");

    for (int i = items.size()-1; i >= 0; i--) {
        if (get_constraint(out, items[i].val(), &items[i]))
            continue;

        out.printerr("Lost constraint %s\n", items[i].val().c_str());
        pworld->DeletePersistentData(items[i]);
    }

    last_tick_frame_count = world->frame_counter;
    last_frame_count = world->frame_counter;

    if (!enabled)
        return;

    start_protect(out);
}
开发者ID:Reag,项目名称:dfhack,代码行数:30,代码来源:workflow.cpp

示例15: read_order

bool read_order(color_ostream &out, lua_State *L, std::vector<unsigned> *order, size_t size)
{
    std::vector<char> found;

    Lua::StackUnwinder frame(L, 1);

    if (!lua_istable(L, -1))
    {
        out.printerr("Not a table returned as ordering.\n");
        return false;
    }

    if (lua_rawlen(L, -1) != size)
    {
        out.printerr("Invalid ordering size: expected %d, actual %d\n", size, lua_rawlen(L, -1));
        return false;
    }

    order->clear();
    order->resize(size);
    found.resize(size);

    for (size_t i = 1; i <= size; i++)
    {
        lua_rawgeti(L, frame[1], i);
        int v = lua_tointeger(L, -1);
        lua_pop(L, 1);

        if (v < 1 || size_t(v) > size)
        {
            out.printerr("Order value out of range: %d\n", v);
            return false;
        }

        if (found[v-1])
        {
            out.printerr("Duplicate order value: %d\n", v);
            return false;
        }

        found[v-1] = 1;
        (*order)[i-1] = v-1;
    }

    return true;
}
开发者ID:mstram,项目名称:dfhack-40d,代码行数:46,代码来源:sort.cpp


注:本文中的color_ostream::printerr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。