void sp_find_dialog_find(GObject *, GObject *dlg)
{
    SPDesktop *desktop = SP_ACTIVE_DESKTOP;

    bool hidden = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includehidden")));
    bool locked = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "includelocked")));

    GSList *l = NULL;
    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inselection")))) {
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) {
            l = all_selection_items (desktop->selection, l, desktop->currentLayer(), hidden, locked);
        } else {
            l = all_selection_items (desktop->selection, l, NULL, hidden, locked);
        }
    } else {
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (gtk_object_get_data (GTK_OBJECT (dlg), "inlayer")))) {
            l = all_items (desktop->currentLayer(), l, hidden, locked);
        } else {
            l = all_items (SP_DOCUMENT_ROOT (sp_desktop_document (desktop)), l, hidden, locked);
        }
    }
    guint all = g_slist_length (l);

    bool exact = true;
    GSList *n = NULL;
    n = filter_list (l, dlg, exact);
    if (n == NULL) {
        exact = false;
        n = filter_list (l, dlg, exact);
    }

    if (n != NULL) {
        int count = g_slist_length (n);
        desktop->messageStack()->flashF(Inkscape::NORMAL_MESSAGE,
                                        // TRANSLATORS: "%s" is replaced with "exact" or "partial" when this string is displayed
                                        ngettext("<b>%d</b> object found (out of <b>%d</b>), %s match.",
                                                 "<b>%d</b> objects found (out of <b>%d</b>), %s match.",
                                                 count),
                                        count, all, exact? _("exact") : _("partial"));

        Inkscape::Selection *selection = sp_desktop_selection (desktop);
        selection->clear();
        selection->setList(n);
        scroll_to_show_item (desktop, SP_ITEM(n->data));
    } else {
        desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("No objects found"));
    }
}
GSList *
all_selection_items (Inkscape::Selection *s, GSList *l, SPObject *ancestor, bool hidden, bool locked)
{
    SPDesktop *desktop = SP_ACTIVE_DESKTOP;

   for (GSList *i = (GSList *) s->itemList(); i != NULL; i = i->next) {
        if (SP_IS_ITEM (i->data) && !SP_OBJECT_IS_CLONED (i->data) && !desktop->isLayer(SP_ITEM(i->data))) {
            if (!ancestor || ancestor->isAncestorOf(SP_OBJECT (i->data))) {
                if ((hidden || !desktop->itemIsHidden(SP_ITEM(i->data))) && (locked || !SP_ITEM(i->data)->isLocked())) {
                    l = g_slist_prepend (l, i->data);
                }
            }
        }
        if (!ancestor || ancestor->isAncestorOf(SP_OBJECT (i->data))) {
            l = all_items (SP_OBJECT (i->data), l, hidden, locked);
        }
    }
    return l;
}
GSList *
all_items (SPObject *r, GSList *l, bool hidden, bool locked)
{
    SPDesktop *desktop = SP_ACTIVE_DESKTOP;

    if (SP_IS_DEFS(r))
        return l; // we're not interested in items in defs

    if (!strcmp (SP_OBJECT_REPR (r)->name(), "svg:metadata"))
        return l; // we're not interested in metadata

    for (SPObject *child = sp_object_first_child(r); child; child = SP_OBJECT_NEXT (child)) {
        if (SP_IS_ITEM (child) && !SP_OBJECT_IS_CLONED (child) && !desktop->isLayer(SP_ITEM(child))) {
                if ((hidden || !desktop->itemIsHidden(SP_ITEM(child))) && (locked || !SP_ITEM(child)->isLocked())) {
                    l = g_slist_prepend (l, child);
                }
        }
        l = all_items (child, l, hidden, locked);
    }
    return l;
}
// Load values from this data file into m_templates
void Item_factory::load_item_templates_from(const std::string file_name) throw (std::string){
    catajson all_items(file_name);

    if(! json_good())
    	throw (std::string)"Could not open " + file_name;

    if (! all_items.is_array())
        throw file_name + (std::string)"is not an array of item_templates";

    //Crawl through and extract the items
    for (all_items.set_begin(); all_items.has_curr(); all_items.next()) {
        catajson entry = all_items.curr();
        // The one element we absolutely require for an item definition is an id
        if(!entry.has("id") || !entry.get("id").is_string())
        {
            debugmsg("Item definition skipped, no id found or id was malformed.");
        }
        else
        {
            Item_tag new_id = entry.get("id").as_string();

            // If everything works out, add the item to the group list...
            // unless a similar item is already there
            if(m_templates.find(new_id) != m_templates.end())
            {
                debugmsg("Item definition skipped, id %s already exists.", new_id.c_str());
            }
            else
            {
                itype* new_item_template;
                if (!entry.has("type"))
                {
                    new_item_template = new itype();
                }
                else
                {
                    std::string type_label = entry.get("type").as_string();
                    if (type_label == "GUNMOD")
                    {
                        it_gunmod* gunmod_template = new it_gunmod();
                        gunmod_template->damage = entry.get("damage_modifier").as_int();;
                        gunmod_template->loudness = entry.get("loudness_modifier").as_int();
                        gunmod_template->newtype = entry.get("ammo_modifier").as_string();
                        gunmod_template->used_on_pistol = is_mod_target(entry.get("mod_targets"), "pistol");
                        gunmod_template->used_on_shotgun = is_mod_target(entry.get("mod_targets"), "shotgun");
                        gunmod_template->used_on_smg = is_mod_target(entry.get("mod_targets"), "smg");
                        gunmod_template->used_on_rifle = is_mod_target(entry.get("mod_targets"), "rifle");
                        gunmod_template->dispersion = entry.get("dispersion_modifier").as_int();
                        gunmod_template->recoil = entry.get("recoil_modifier").as_int();
                        gunmod_template->burst = entry.get("burst_modifier").as_int();
                        gunmod_template->clip = entry.get("clip_size_modifier").as_int();
                        if( entry.has("acceptable_ammo") ) {
                            tags_from_json( entry.get("acceptable_ammo"),
                                            gunmod_template->acceptible_ammo_types );
                        }
                        new_item_template = gunmod_template;
                    }
                    else if (type_label == "COMESTIBLE")
                    {
                        it_comest* comest_template = new it_comest();
                        comest_template->comesttype = entry.get("comestible_type").as_string();
                        comest_template->tool = entry.get("tool").as_string();
                        comest_template->container = entry.get("container").as_string();
                        comest_template->quench = entry.get("quench").as_int();
                        comest_template->nutr = entry.get("nutrition").as_int();
                        comest_template->spoils = entry.get("spoils_in").as_int();
                        comest_template->addict = entry.get("addiction_potential").as_int();
                        comest_template->charges = entry.get("charges").as_int();
                        comest_template->stim = entry.get("stim").as_int();
                        comest_template->healthy = entry.get("heal").as_int();
                        comest_template->fun = entry.get("fun").as_int();
                        comest_template->add = addiction_type(entry.get("addiction_type").as_string());
                        new_item_template = comest_template;
                    }
                    else if (type_label == "GUN")
                    {
                        it_gun* gun_template = new it_gun();
                        gun_template->ammo = entry.get("ammo").as_string();
                        gun_template->skill_used = Skill::skill(entry.get("skill").as_string());
                        gun_template->dmg_bonus = entry.get("ranged_damage").as_int();
                        gun_template->range = entry.get("range").as_int();
                        gun_template->dispersion = entry.get("dispersion").as_int();
                        gun_template->recoil = entry.get("recoil").as_int();
                        gun_template->durability = entry.get("durability").as_int();
                        gun_template->burst = entry.get("burst").as_int();
                        gun_template->clip = entry.get("clip_size").as_int();
                        gun_template->reload_time = entry.get("reload").as_int();
                        gun_template->pierce = entry.has("pierce") ? entry.get("pierce").as_int() : 0;
                        if( entry.has("ammo_effects") ) {
                            tags_from_json(entry.get("ammo_effects"), gun_template->ammo_effects);
                        }

                        new_item_template = gun_template;
                    }
                    else if (type_label == "TOOL")
                    {
                        it_tool* tool_template = new it_tool();
                        tool_template->ammo = entry.get("ammo").as_string();
                        tool_template->max_charges = entry.get("max_charges").as_int();
                        tool_template->def_charges = entry.get("initial_charges").as_int();
                        tool_template->charges_per_use = entry.get("charges_per_use").as_int();
                        tool_template->turns_per_charge = entry.get("turns_per_charge").as_int();
                        tool_template->revert_to = entry.get("revert_to").as_string();

                        new_item_template = tool_template;
                    }
                    else if (type_label == "AMMO")
                    {
                        it_ammo* ammo_template = new it_ammo();
                        ammo_template->type = entry.get("ammo_type").as_string();
                        if(entry.has("casing")) {
                            ammo_template->casing = entry.get("casing").as_string();
                        }
                        ammo_template->damage = entry.get("damage").as_int();
                        ammo_template->pierce = entry.get("pierce").as_int();
                        ammo_template->range = entry.get("range").as_int();
                        ammo_template->dispersion =
                            entry.get("dispersion").as_int();
                        ammo_template->recoil = entry.get("recoil").as_int();
                        ammo_template->count = entry.get("count").as_int();
                        if( entry.has("effects") ) {
                            tags_from_json(entry.get("effects"), ammo_template->ammo_effects);
                        }

                        new_item_template = ammo_template;
                    }
                    else if (type_label == "ARMOR")
                    {
                        it_armor* armor_template = new it_armor();

                        armor_template->encumber = entry.get("encumberance").as_int();
                        armor_template->coverage = entry.get("coverage").as_int();
                        armor_template->thickness = entry.get("material_thickness").as_int();
                        armor_template->env_resist = entry.get("enviromental_protection").as_int();
                        armor_template->warmth = entry.get("warmth").as_int();
                        armor_template->storage = entry.get("storage").as_int();
                        armor_template->power_armor = entry.has("power_armor") ? entry.get("power_armor").as_bool() : false;
                        armor_template->covers = entry.has("covers") ?
                          flags_from_json(entry.get("covers"),"bodyparts") : 0;

                        new_item_template = armor_template;
                    }
                    else if (type_label == "BOOK")
                    {
                        it_book* book_template = new it_book();

                        book_template->level = entry.get("max_level").as_int();
                        book_template->req = entry.get("required_level").as_int();
                        book_template->fun = entry.get("fun").as_int();
                        book_template->intel = entry.get("intelligence").as_int();
                        book_template->time = entry.get("time").as_int();
                        book_template->type = Skill::skill(entry.get("skill").as_string());

                        new_item_template = book_template;
                    }
                    else if (type_label == "CONTAINER")
                    {
                        it_container* container_template = new it_container();

                        container_template->contains = entry.get("contains").as_int();

                        new_item_template = container_template;
                    }
                    else
                    {
                        debugmsg("Item definition for %s skipped, unrecognized type: %s", new_id.c_str(),
                                 type_label.c_str());
                        break;
                    }
                }
                new_item_template->id = new_id;
                m_templates[new_id] = new_item_template;

                // And then proceed to assign the correct field
                new_item_template->price = entry.get("price").as_int();
                new_item_template->name = _(entry.get("name").as_string().c_str());
                new_item_template->sym = entry.get("symbol").as_char();
                new_item_template->color = color_from_string(entry.get("color").as_string());
                new_item_template->description = _(entry.get("description").as_string().c_str());
                if(entry.has("material")){
                  set_material_from_json(new_id, entry.get("material"));
                } else {
                  new_item_template->m1 = "null";
                  new_item_template->m2 = "null";
                }
                Item_tag new_phase = "solid";
                if(entry.has("phase")){
                    new_phase = entry.get("phase").as_string();
                }
                new_item_template->phase = phase_from_tag(new_phase);
                new_item_template->volume = entry.get("volume").as_int();
                new_item_template->weight = entry.get("weight").as_int();
                new_item_template->melee_dam = entry.get("bashing").as_int();
                new_item_template->melee_cut = entry.get("cutting").as_int();
                new_item_template->m_to_hit = entry.get("to_hit").as_int();

                if( entry.has("flags") )
                {
                    new_item_template->item_tags = entry.get("flags").as_tags();
                    /*
                    List of current flags
                    FIT - Reduces encumberance by one
                    VARSIZE - Can be made to fit via tailoring
                    OVERSIZE - Can always be worn no matter encumberance/mutations/bionics/etc
                    HOOD - Will increase warmth for head if head is cold and player is not wearing a helmet (headwear of material that is not wool or cotton)
                    POCKETS - Will increase warmth for hands if hands are cold and the player is wielding nothing
                    WATCH - Shows the current time, instead of sun/moon position
                    ALARMCLOCK - Has an alarmclock feature
                    MALE_TYPICAL - Typically only worn by men.
                    FEMALE_TYPICAL - Typically only worn by women.
                    USE_EAT_VERB - Use the eat verb, even if it's a liquid(soup, jam etc.)

                    Container-only flags:
                    SEALS
                    RIGID
                    WATERTIGHT
                    */
                }

                new_item_template->techniques = (!entry.has("techniques") ? 0 :
                                                 flags_from_json(entry.get("techniques"), "techniques"));
                new_item_template->use = (!entry.has("use_action") ? &iuse::none :
                                          use_from_string(entry.get("use_action").as_string()));
            }
        }
    }
    if(!json_good())
        throw "There was an error reading " + file_name;
}
示例#5
0
void cTmpEff::Expire()
{
    int k;

    P_CHAR pc_s = FindCharBySerial(getDest());
    if (   num != 9		// grinding
            && num != 10	// create potion
            && num != 13	// door close
            && num != 14	// training dummy
            && num != 17)	// explosion
    {
        //Added by TANiS to fix errors, memory corruption and door auto-close 10-6-98
        // Check to see if it's a dead char and delete the wrong effect, or if it's just
        // a door auto-close effect and process it the right way.
        if ( pc_s == NULL )
        {
            return;		// just remove this effect
        } //End of TANiS' change
    }

    switch(num)
    {
    case 1:
        if (pc_s->priv2&0x02)
        {
            pc_s->priv2 &= 0xFD;
            int sk=calcSocketFromChar((pc_s));
            if (sk!=-1) sysmessage(sk, "You are no longer frozen.");
            Magic->afterParticles(38, pc_s);
        }
        break;
    case 2:
        pc_s->fixedlight='\xFF';
        dolight(calcSocketFromChar((pc_s)), worldbrightlevel);
        break;
    case 3:
        pc_s->chgDex(more1);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 4:
        pc_s->in+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 5:
        pc_s->st+=more1;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 6:
        pc_s->chgDex(-1 * more1);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 7:
        pc_s->in-=more1;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 8:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 9:
        if (more1 == 0)
        {
            if (more2!=0)
            {
                sprintf((char*)temp, "*%s continues grinding.*", pc_s->name.c_str());
                npcemoteall(pc_s, (char*)temp,1);
            }
            soundeffect2(pc_s, 0x0242);
        }
        break;
    case 10:
    {
        pc_s = FindCharBySerial(getSour());
        P_ITEM pMortar = FindItemBySerial(getDest());
        if(pMortar != NULL) //AntiChrist - to prevent crashes
            Skills->CreatePotion(pc_s, more1, more2, pMortar);
    }
    break;
    case 11:
        pc_s->st-=more1;
        pc_s->hp=min(pc_s->hp, pc_s->st);
        pc_s->chgDex(-1 * more2);
        pc_s->stm=min(pc_s->stm, (int)pc_s->effDex());
        pc_s->in-=more3;
        pc_s->mn=min(pc_s->mn, pc_s->in);
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 12:
        pc_s->st+=more1;
        pc_s->chgDex(more2);
        pc_s->in+=more3;
        statwindow(calcSocketFromChar(pc_s), pc_s);
        break;
    case 13:
    {
        P_ITEM pDoor = FindItemBySerial(getDest());// door
        if (pDoor)
        {
            if (pDoor->dooropen==0)
                break;
            pDoor->dooropen=0;
            dooruse(calcSocketFromChar((pc_s)), pDoor);
        }
        break;
    }
    case 14: //- training dummies Tauriel check to see if item moved or not before searching for it
    {
        P_ITEM pTrainDummy = FindItemBySerial(getDest());
        if (pTrainDummy)
        {
            if (pTrainDummy->id()==0x1071)
            {
                pTrainDummy->setId(0x1070);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
            else if (pTrainDummy->id()==0x1075)
            {
                pTrainDummy->setId(0x1074);
                pTrainDummy->gatetime=0;
                RefreshItem(pTrainDummy);//AntiChrist
            }
        }
    }
    break;
    case 15: //reactive armor
        pc_s->ra=0;
        break;
    case 16: //Explosion potion messages	Tauriel
        sprintf((char*)temp, "%i", more3);
        sysmessage(calcSocketFromChar((pc_s)), (char*)temp); // crashfix, LB
        break;
    case 17: //Explosion potion explosion	Tauriel
        pc_s = FindCharBySerial(getSour());
        explodeitem(calcSocketFromChar((pc_s)), FindItemBySerial(getDest())); //explode this item
        break;
    case 18: //Polymorph spell by AntiChrist 9/99
        if(pc_s->polymorph)//let's ensure it's under polymorph effect!
        {
            pc_s->setId(pc_s->xid);
            pc_s->polymorph=false;
            teleport(pc_s);
        }
        break;
    case 19: //Incognito spell by AntiChrist 12/99
        reverseIncognito(pc_s);
        break;

    case 20: // LSD potions, LB 5'th nov 1999
    {
        k=calcSocketFromChar((pc_s));
        if (k==-1) return;
        LSD[k]=0;
        sysmessage(k,"LSD has worn off");
        pc_s->stm=3; // stamina near 0
        pc_s->mn=3;
        pc_s->hp=pc_s->hp/7;
        impowncreate(k, pc_s, 0);
        all_items(k); // absolutely necassairy here !!!
        AllCharsIterator it;
        for (it.Begin(); !it.atEnd(); it++) // that hurts, but there's no other good way
        {
            P_CHAR pc = it.GetData();
            if (chardist( pc_s, pc ) < 15 && ( online(pc) || pc->isNpc() ) )
                updatechar(pc);
        }
    }
    break;

    case 21:
        int toDrop;
        toDrop = more1; //Effect->more1;
        if( ( pc_s->baseskill[PARRYING] - toDrop ) < 0 )
            pc_s->baseskill[PARRYING] = 0;
        else
            pc_s->baseskill[PARRYING] -= toDrop;
        break;

    case 33: // delayed hiding for gms after flamestrike effect
        k=calcSocketFromChar((pc_s));
        sysmessage(k,"You have hidden yourself well.");
        pc_s->hidden=1;
        updatechar(pc_s);
        break;

    case 34: // delayed unhide for gms
        // Changed to be uniform with delayed hideing  (Aldur)
        k = calcSocketFromChar((pc_s));
        sysmessage(k, "You are now visible.");
        pc_s->hidden = 0;
        updatechar(pc_s);
        break;

    case 35: //heals some pf - solarin
        int iHp;
        iHp=(int)more1;
        pc_s->hp+=iHp;
        updatestats(pc_s, 0);
        if (!more2)
            tempeffect(pc_s, pc_s, 35, more1+1, 1, more3, 0);
        break;

    default:
        LogErrorVar("Fallout of switch (num = %i).", num);
        break;
    }
    Items->CheckEquipment(pc_s); //AntiChrist - checks equipments for stats requirements
}