Ejemplo n.º 1
0
void Lattice::AttackBy(id_ptr_on<Item> item)
{
    if (id_ptr_on<FloorTile> tile = item)
    {
        tile->delThis();

        GetTurf()->delThis();
        SetTurf(GetItemFabric().newItem<ITurf>(Floor::T_ITEM_S()));

        PlaySoundIfVisible("Deconstruct.ogg", owner.ret_id());

        delThis();
    }
}
Ejemplo n.º 2
0
void MapEditor::PasteFromAreaBuffer()
{
    int end_x = std::min(
                    editor_map_.size(),
                    pointer_.first_posx + area_buffer_.size());
    int end_y = std::min(
                    editor_map_[0].size(),
                    pointer_.first_posy + area_buffer_[0].size());

    for (int x = 0; x < end_x - pointer_.first_posx; ++x)
    {
        for (int y = 0; y < end_y - pointer_.first_posy; ++y)
        {
            auto& new_item = SetTurf(
                                area_buffer_[x][y].turf.item_type,
                                pointer_.first_posx + x,
                                pointer_.first_posy + y,
                                0);
            new_item.variables = area_buffer_[x][y].turf.variables;
            UpdateDirs(&new_item);
            for (auto it = area_buffer_[x][y].items.begin();
                      it != area_buffer_[x][y].items.end();
                    ++it)
            {
                auto& new_item = AddItem(
                                    it->item_type,
                                    pointer_.first_posx + x,
                                    pointer_.first_posy + y,
                                    0);
                new_item.variables = it->variables;
                UpdateDirs(&new_item);
            }
        }
    }

    SetFirstSelectionPoint(pointer_.first_posx, pointer_.first_posy);
    SetSecondSelectionPoint(end_x - 1, end_y - 1);

    emit newSelectionSetted(
                first_selection_x_, first_selection_y_,
                second_selection_x_, second_selection_y_);
}
Ejemplo n.º 3
0
void MapEditor::LoadMapgen(const std::string &name)
{
    std::fstream sfile;
    sfile.open(name, std::ios_base::in);
    if(sfile.fail())
    {
        SYSTEM_STREAM << "Error open " << name << std::endl;
        return;
    }

    ClearMap();

    std::stringstream ss;

    sfile.seekg (0, std::ios::end);
    std::streamoff length = sfile.tellg();
    sfile.seekg (0, std::ios::beg);
    char* buff = new char[static_cast<size_t>(length)];

    sfile.read(buff, length);
    sfile.close();
    ss.write(buff, length);
    delete[] buff;

    int x, y, z;
    ss >> x;
    ss >> y;
    ss >> z;

    Resize(x, y, z);

    while (ss)
    {
        std::string t_item;
        size_t x, y, z;
        ss >> t_item;
        if (!ss)
        {
            continue;
        }
        ss >> x;
        if (!ss)
        {
            continue;
        }
        ss >> y;
        if (!ss)
        {
            continue;
        }
        ss >> z;
        if (!ss)
        {
            continue;
        }

        MapEditor::EditorEntry* ee;
        if (turf_types_.find(t_item) != turf_types_.end())
        {
            ee = &SetTurf(t_item, x, y, z);
        }
        else
        {
            ee = &AddItem(t_item, x, y, z);
        }

        WrapReadMessage(ss, ee->variables);

        // TODO
        UpdateDirs(ee);
    }
}