static void line2(const Grid & grid, FILE * stream, ssize_t iy, ssize_t ix0, ssize_t ix1, const char * prefix, const char * high) { if(0 != high) fprintf(stream, high); if(0 != prefix) fprintf(stream, prefix); shared_ptr<GridCSpace const> const cspace(grid.GetCSpace()); for(ssize_t ix(ix0); ix <= ix1; ++ix){ shared_ptr <GridNode const> node(grid.GetNode(ix, iy)); if ( ! node) { fprintf(stream, "| "); fprintf(stream, "| "); } else { const flag_t flag(cspace->GetFlag(node->vertex)); if(NONE == flag) fprintf(stream, "| "); else fprintf(stream, "|%5s ", flag_name(flag)); const double rhs(cspace->GetRhs(node->vertex)); if(infinity == rhs) fprintf(stream, "infty"); else if(huge <= rhs) fprintf(stream, "huge "); else fprintf(stream, "%5.2f", rhs); } } if(0 != high) fprintf(stream, "|%s\n", high); else fprintf(stream, "|\n"); }
void Queue:: Requeue(vertex_t vertex, flag_map_t & flag_map, const value_map_t & value_map, const rhs_map_t & rhs_map) { const double value(get(value_map, vertex)); const double rhs(get(rhs_map, vertex)); const flag_t flag(get(flag_map, vertex)); if(absval(value - rhs) < epsilon){ PVDEBUG("CONSISTENT f: %s i: %lu v: %g rhs: %g\n", flag_name(flag), vertex, value, rhs); if(flag & OPEN){ DoDequeue(vertex, m_queue.begin()); m_map.erase(vertex); put(flag_map, vertex, static_cast<flag_t>(flag ^ OPEN)); } return; } const double key(minval(value, rhs)); if( ! (flag & OPEN)){ m_queue.insert(make_pair(key, vertex)); m_map.insert(make_pair(vertex, key)); put(flag_map, vertex, static_cast<flag_t>(flag | OPEN)); PVDEBUG("ENQUEUE f: %s i: %lu v: %g rhs: %g\n", flag_name(flag), vertex, value, rhs); return; } queue_map_t::iterator im(m_map.find(vertex)); BOOST_ASSERT( im != m_map.end() ); if(absval(im->second - key) < epsilon){ PVDEBUG("KEEP f: %s i: %lu v: %g rhs: %g (absval(%g) < %g)\n", flag_name(flag), vertex, value, rhs, im->second - key, epsilon); return; } PVDEBUG("REQUEUE f: %s i: %lu v: %g rhs: %g\n", flag_name(flag), vertex, value, rhs); DoDequeue(vertex, m_queue.find(im->second)); m_queue.insert(make_pair(key, vertex)); im->second = key; }
/** * Add power for non-derived flags (derived flags have flag_power 0) */ static int flags_power(const object_type *obj, int p, int verbose, ang_file *log_file, bool known) { size_t i, j; int q; bitflag flags[OF_SIZE]; /* Extract the flags */ if (known) object_flags(obj, flags); else object_flags_known(obj, flags); /* Log the flags in human-readable form */ if (verbose) log_flags(flags, log_file); /* Zero the flag counts */ for (i = 0; i < N_ELEMENTS(flag_sets); i++) flag_sets[i].count = 0; for (i = of_next(flags, FLAG_START); i != FLAG_END; i = of_next(flags, i + 1)) { if (flag_power(i)) { q = (flag_power(i) * flag_slot_mult(i, wield_slot(obj))); p += q; log_obj(format("Add %d power for %s, total is %d\n", q, flag_name(i), p)); } /* Track combinations of flag types */ for (j = 0; j < N_ELEMENTS(flag_sets); j++) if (flag_sets[j].type == obj_flag_type(i)) flag_sets[j].count++; } /* Add extra power for multiple flags of the same type */ for (i = 0; i < N_ELEMENTS(flag_sets); i++) { if (flag_sets[i].count > 1) { q = (flag_sets[i].factor * flag_sets[i].count * flag_sets[i].count); p += q; log_obj(format("Add %d power for multiple %s, total is %d\n", q, flag_sets[i].desc, p)); } /* Add bonus if item has a full set of these flags */ if (flag_sets[i].count == flag_sets[i].size) { q = flag_sets[i].bonus; p += q; log_obj(format("Add %d power for full set of %s, total is %d\n", q, flag_sets[i].desc, p)); } } return p; }
vertex_t Queue:: Pop(flag_map_t & flag_map) { BOOST_ASSERT( ! m_queue.empty() ); queue_it iq(m_queue.begin()); const vertex_t vertex(iq->second); m_queue.erase(iq); m_map.erase(vertex); put(flag_map, vertex, static_cast<flag_t>(get(flag_map, vertex) ^ OPEN)); PVDEBUG("f: %s i: %lu\n", flag_name(get(flag_map, vertex)), vertex); return vertex; }
char *flags_to_string(struct flag_name *flags_array, u64 flags) { u64 bit_mask = 1; int i = 0; char *out = strdup(""); for (i = 0; i < 64; ++i) { if (flags & bit_mask) { char *tmp = NULL; asprintf(&tmp, "%s%s%s", out, out[0] ? "|" : "", flag_name(flags_array, bit_mask)); free(out); out = tmp; } bit_mask <<= 1; } return out; }
static void flag_printf(FILE *fp, const char *s, uint_t flags, size_t bits, const char *(*flag_name)(uint_t), const char *(*flag_desc)(uint_t)) { size_t i; oprintf(fp, " %s: 0x%x\n", s, flags); for (i = 0; i < bits; i++) { uint_t f = 1 << i; const char *n; if (!(flags & f)) continue; if ((n = flag_name(f)) != NULL) desc_printf(flag_desc(f), fp, "\t%s", n); else desc_printf(flag_desc(f), fp, "\t0x%x", f); } }
void dump_queue(const Algorithm & algo, const Grid * grid, size_t limit, FILE * stream) { const queue_t & queue(algo.GetQueue().Get()); if(queue.empty()){ fprintf(stream, "queue: empty\n"); return; } shared_ptr<BaseCSpace const> base_cspace(algo.GetCSpace()); shared_ptr<GridCSpace const> grid_cspace; if (grid) grid_cspace = grid->GetCSpace(); size_t count(0); const_queue_it iq(queue.begin()); const double firstkey(iq->first); fprintf(stream, "queue:\n"); for(/**/; iq != queue.end(); ++iq, ++count){ const vertex_t vertex(iq->second); fprintf(stream, " %s f: %s %s i: %zu", iq->first == firstkey ? "*" : " ", flag_name(base_cspace->GetFlag(vertex)), base_cspace->GetRhs(vertex) < base_cspace->GetValue(vertex) ? "lower" : "raise", vertex); if(grid_cspace){ GridNode const & gn(*grid_cspace->Lookup(vertex)); fprintf(stream, " (%zu, %zu)", gn.ix, gn.iy); } const double vv(base_cspace->GetValue(vertex)); if(vv == infinity) fprintf(stream, " k: %g v: inf", iq->first); else fprintf(stream, " k: %g v: %g", iq->first, vv); const double rr(base_cspace->GetRhs(vertex)); if(rr == infinity) fprintf(stream, " rhs: inf\n"); else fprintf(stream, " rhs: %g\n", rr); if((limit > 0) && (count > limit) && (iq->first != firstkey)) break; } }
/* * Print an item's flavour text. * * \param tb is the textblock to which we are adding. * \param o_ptr is the object we are describing. * \param ego is whether we're describing an ego template (as opposed to a * real object) */ static void describe_flavor_text(textblock *tb, const object_type *o_ptr, oinfo_detail_t mode) { int i, count = 0; bool ego = mode & OINFO_EGO; bool subj = mode & OINFO_SUBJ; /* Display the known artifact description */ if (!OPT(birth_randarts) && o_ptr->artifact && object_is_known(o_ptr) && o_ptr->artifact->text) textblock_append(tb, "%s\n\n", o_ptr->artifact->text); else if (o_ptr->theme && o_ptr->theme->text && object_theme_is_known(o_ptr)) textblock_append(tb, "%s\n\n", o_ptr->theme->text); /* Display the known object description */ else if (object_flavor_is_aware(o_ptr) || object_is_known(o_ptr) || ego) { bool did_desc = FALSE; if (!ego && o_ptr->kind->text) { textblock_append(tb, "%s", o_ptr->kind->text); did_desc = TRUE; } /* Display additional affix descriptions */ for (i = 0; i < MAX_AFFIXES && o_ptr->affix[i]; i++) if (o_ptr->affix[i]->text && (ego || object_affix_is_known(o_ptr, o_ptr->affix[i]->eidx))) { if (did_desc) textblock_append(tb, " "); textblock_append(tb, "%s", o_ptr->affix[i]->text); did_desc = TRUE; } if (did_desc) textblock_append(tb, "\n\n"); } /* List the affixes on the item */ for (i = 0; i < MAX_AFFIXES && o_ptr->affix[i]; i++) if (object_affix_is_known(o_ptr, o_ptr->affix[i]->eidx)) { if (count == 0) textblock_append(tb, "This item's known properties are: "); else textblock_append(tb, ", "); textblock_append(tb, "%s", o_ptr->affix[i]->name); count++; } if (count) textblock_append(tb, ".\n\n"); if (!ego && subj && o_ptr->origin != ORIGIN_STORE) { /* List the item's known runes */ count = 0; for (i = 0; i < OF_MAX; i++) if (of_has(o_ptr->flags, i) && of_has(p_ptr->known_runes, i) && obj_flag_type(i) != OFT_INT && obj_flag_type(i) != OFT_NONE) { if (count == 0) textblock_append(tb, "This item's known runes are: "); else textblock_append(tb, ", "); textblock_append(tb, "%s", flag_name(i)); count++; } if (count) textblock_append(tb, ".\n\n"); /* List the item's unknown runes */ count = 0; for (i = 0; i < OF_MAX; i++) if (of_has(o_ptr->flags, i) && !of_has(p_ptr->known_runes, i) && obj_flag_type(i) != OFT_INT && obj_flag_type(i) != OFT_NONE) { if (count == 0) textblock_append(tb, "This item's unknown runes are: "); else textblock_append(tb, ", "); textblock_append(tb, "%s", flag_rune(i)); count++; } if (count) textblock_append(tb, ".\n\n"); } }
PartitionState do_test1(PedDevice *dev, label_type labelType) { PartitionState state; //PedGeometry geom; PedDisk *disk; PedPartition *part; PedPartition *grub_partition = 0, *boot_partition = 0, *root_partition = 0; PedDiskType *type = 0; PedFileSystemType *ext4 = ped_file_system_type_get("ext4"); bool dirty = false; PedSector start = 0, end = 0; /*if (!ped_geometry_init(&geom,dev,0,dev->length)) { qDebug() << "unable to init geom"; return; }*/ disk = ped_disk_new(dev); /*type = ped_disk_probe(dev); if (type) { qDebug() << "current partition type:" << type->name; disk = type->ops->alloc(dev); if (!type->ops->read(disk)) { qDebug() << "failed to read gpt tables"; return; } }*/ if (!disk) { qDebug() << "no tables detected"; if (labelType == label_type::gpt) { type = ped_disk_type_get("gpt"); } else if (labelType == label_type::mbr) { type = ped_disk_type_get("msdos"); } disk = ped_disk_new_fresh(dev,type); ped_disk_commit(disk); } if (disk) { for (part = ped_disk_next_partition(disk,NULL); part; part = ped_disk_next_partition(disk,part)) { if (!ped_partition_is_active(part)) continue; QString name(ped_partition_get_name(part)); qDebug() << "partition" << part->num << name; if (name == "boot") boot_partition = part; if (name == "root") root_partition = part; if (ped_partition_get_flag(part,PED_PARTITION_BIOS_GRUB)) grub_partition = part; for (int f = PED_PARTITION_FIRST_FLAG; f < PED_PARTITION_LAST_FLAG; f++) { if (ped_partition_get_flag(part,(PedPartitionFlag)f)) { QString flag_name(ped_partition_flag_get_name((PedPartitionFlag)f)); qDebug() << "flag" << flag_name << "is set"; } } } PedConstraint *constraint = ped_constraint_any(dev); if (!grub_partition) { start = (1024*1024) / dev->sector_size; end = ((1024*1024) / dev->sector_size) + start; qDebug() << "creating" << start << end; grub_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,ext4,start,end); if (labelType == label_type::gpt) { ped_partition_set_name(grub_partition,"bios boot"); ped_partition_set_flag(grub_partition,PED_PARTITION_BIOS_GRUB,1); } if (!ped_disk_add_partition(disk,grub_partition,constraint)) { qDebug() << "error adding partition"; } dirty = true; } if (!boot_partition) { start = (1024*1024*2) / dev->sector_size; end = ((1024*1024*128) / dev->sector_size) + start; qDebug() << "creating" << start << end; boot_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,NULL,start,end); if (labelType == label_type::gpt) { ped_partition_set_name(boot_partition,"boot"); } //ped_partition_set_flag(boot_partition,PED_PARTITION_BOOT,1); if (!ped_disk_add_partition(disk,boot_partition,constraint)) { qDebug() << "error adding partition"; } dirty = true; } if (!root_partition) { start = (1024*1024*129) / dev->sector_size; end = dev->length; qDebug() << "creating" << start << end; root_partition = ped_partition_new(disk,PED_PARTITION_NORMAL,ext4,start,end); if (labelType == label_type::gpt) { ped_partition_set_name(root_partition,"root"); //ped_partition_set_flag(root_partition,PED_PARTITION_ROOT,1); } if (!ped_disk_add_partition(disk,root_partition,constraint)) { qDebug() << "error adding partition"; } dirty = true; } ped_constraint_destroy(constraint); } if (dirty) ped_disk_commit(disk); state.boot_path = ped_partition_get_path(boot_partition); state.root_path = ped_partition_get_path(root_partition); return state; }
ScmObj Scm_SysFcntl(ScmObj port_or_fd, int op, ScmObj arg) { #if !defined(GAUCHE_WINDOWS) int fd = Scm_GetPortFd(port_or_fd, TRUE), r; switch (op) { case F_GETFD:; case F_GETFL:; #if defined(F_GETOWN) /* BSD and Linux specific */ case F_GETOWN:; #endif /*F_GETOWN*/ #if defined(F_GETSIG) /* Linux specific */ case F_GETSIG:; #endif /*F_GETSIG */ #if defined(F_GETLEASE) /* Linux specific */ case F_GETLEASE:; #endif /*F_GETLEASE */ SCM_SYSCALL(r, fcntl(fd, op)); if (r == -1) { /*NB: F_GETOWN may return a negative value on success*/ Scm_SysError("fcntl(%s) failed", flag_name(op)); } return Scm_MakeInteger(r); case F_SETFD:; case F_SETFL:; case F_DUPFD:; #if defined(F_SETOWN) /* BSD and Linux specific */ case F_SETOWN:; #endif /*F_SETOWN*/ #if defined(F_SETSIG) /* Linux specific */ case F_SETSIG:; #endif /*F_SETSIG */ #if defined(F_SETLEASE) /* Linux specific */ case F_SETLEASE:; #endif /*F_SETLEASE */ #if defined(F_NOTIFY) /* Linux specific */ case F_NOTIFY:; #endif /*F_NOTIFY */ if (!SCM_EXACTP(arg)) { Scm_Error("exact integer required for fcntl(%s), but got %S", flag_name(op), arg); } SCM_SYSCALL(r, fcntl(fd, op, Scm_GetInteger(arg))); if (r < 0) { Scm_SysError("fcntl(%s) failed", flag_name(op)); } return Scm_MakeInteger(r); case F_GETLK:; case F_SETLK:; case F_SETLKW:; if (!SCM_SYS_FLOCK_P(arg)) { Scm_Error("flock object required for fcntl(%s), but got %S", flag_name(op), arg); } ScmSysFlock *fl = SCM_SYS_FLOCK(arg); SCM_SYSCALL(r, fcntl(fd, op, &fl->lock)); if (op == F_SETLK) { if (r >= 0) return SCM_TRUE; if (errno == EAGAIN) return SCM_FALSE; } if (r < 0) Scm_SysError("fcntl(%s) failed", flag_name(op)); return SCM_TRUE; default: Scm_Error("unknown operation code (%d) for fcntl", op); return SCM_UNDEFINED; /* dummy */ } #else /*GAUCHE_WINDOWS*/ Scm_Error("fcntl not supported on MinGW port"); return SCM_UNDEFINED; /*dummy*/ #endif /*GAUCHE_WINDOWS*/ }
/* * Evaluate the object's overall power level. */ s32b object_power(const object_type* o_ptr, int verbose, ang_file *log_file, bool known) { s32b p = 0, q = 0, slay_pwr = 0; unsigned int i, j; int extra_stat_bonus = 0, mult = 1, num_slays = 0, k = 1; bitflag flags[OF_SIZE], mask[OF_SIZE]; /* Zero the flag counts */ for (i = 0; i < N_ELEMENTS(sets); i++) sets[i].count = 0; /* Extract the flags */ if (known) { file_putf(log_file, "Object is deemed known\n"); object_flags(o_ptr, flags); } else { file_putf(log_file, "Object may not be fully known\n"); object_flags_known(o_ptr, flags); } /* Log the flags in human-readable form */ if (verbose) log_flags(flags, log_file); /* Get the slay power and number of slay/brand types */ create_mask(mask, FALSE, OFT_SLAY, OFT_KILL, OFT_BRAND, OFT_MAX); num_slays = list_slays(flags, mask, NULL, NULL, NULL, TRUE); if (num_slays) slay_pwr = slay_power(o_ptr, verbose, log_file, known); /* Start with any damage boost from the item itself */ p += (o_ptr->to_d * DAMAGE_POWER / 2); file_putf(log_file, "Adding power from to_dam, total is %d\n", p); /* Add damage from dice for any wieldable weapon or ammo */ if (wield_slot(o_ptr) == INVEN_WIELD || obj_is_ammo(o_ptr)) { p += (o_ptr->dd * (o_ptr->ds + 1) * DAMAGE_POWER / 4); file_putf(log_file, "Adding power for dam dice, total is %d\n", p); /* Add 2nd lot of damage power for nonweapons */ } else if (wield_slot(o_ptr) != INVEN_BOW) { p += (o_ptr->to_d * DAMAGE_POWER); file_putf(log_file, "Adding power from nonweap to_dam, total is %d\n", p); /* Add power boost for nonweapons with combat flags */ if (num_slays || of_has(flags, OF_BLOWS) || of_has(flags, OF_SHOTS) || of_has(flags, OF_MIGHT)) { p += (WEAP_DAMAGE * DAMAGE_POWER); file_putf(log_file, "Adding power for nonweap combat flags, total is %d\n", p); } } /* Add ammo damage for launchers, get multiplier and rescale */ if (wield_slot(o_ptr) == INVEN_BOW) { p += (archery[o_ptr->sval / 10].ammo_dam * DAMAGE_POWER / 2); file_putf(log_file, "Adding power from ammo, total is %d\n", p); mult = bow_multiplier(o_ptr->sval); file_putf(log_file, "Base mult for this weapon is %d\n", mult); } /* Add launcher bonus for ego ammo, multiply for launcher and rescale */ if (obj_is_ammo(o_ptr)) { if (o_ptr->ego) p += (archery[o_ptr->tval - TV_SHOT].launch_dam * DAMAGE_POWER / 2); p = p * archery[o_ptr->tval - TV_SHOT].launch_mult / (2 * MAX_BLOWS); file_putf(log_file, "After multiplying ammo and rescaling, power is %d\n", p); } /* Add power for extra blows */ if (of_has(flags, OF_BLOWS)) { j = which_pval(o_ptr, OF_BLOWS); if (known || object_this_pval_is_visible(o_ptr, j)) { if (o_ptr->pval[j] >= INHIBIT_BLOWS) { p += INHIBIT_POWER; file_putf(log_file, "INHIBITING - too many extra blows\n"); } else { p = p * (MAX_BLOWS + o_ptr->pval[j]) / MAX_BLOWS; /* Add boost for assumed off-weapon damage */ p += (NONWEAP_DAMAGE * o_ptr->pval[j] * DAMAGE_POWER / 2); file_putf(log_file, "Adding power for extra blows, total is %d\n", p); } } } /* Add power for extra shots - note that we cannot handle negative shots */ if (of_has(flags, OF_SHOTS)) { j = which_pval(o_ptr, OF_SHOTS); if (known || object_this_pval_is_visible(o_ptr, j)) { if (o_ptr->pval[j] >= INHIBIT_SHOTS) { p += INHIBIT_POWER; file_putf(log_file, "INHIBITING - too many extra shots\n"); } else if (o_ptr->pval[j] > 0) { p = (p * (1 + o_ptr->pval[j])); file_putf(log_file, "Extra shots: multiplying power by 1 + %d, total is %d\n", o_ptr->pval[j], p); } } } /* Add power for extra might */ if (of_has(flags, OF_MIGHT)) { j = which_pval(o_ptr, OF_MIGHT); if (known || object_this_pval_is_visible(o_ptr, j)) { if (o_ptr->pval[j] >= INHIBIT_MIGHT) { p += INHIBIT_POWER; mult = 1; /* don't overflow */ file_putf(log_file, "INHIBITING - too much extra might\n"); } else mult += o_ptr->pval[j]; file_putf(log_file, "Mult after extra might is %d\n", mult); } } p *= mult; file_putf(log_file, "After multiplying power for might, total is %d\n", p); /* Apply the correct slay multiplier */ if (slay_pwr) { p = (p * (slay_pwr / 10)) / (tot_mon_power / 10); file_putf(log_file, "Adjusted for slay power, total is %d\n", p); } /* Melee weapons assume MAX_BLOWS per turn, so we must divide by MAX_BLOWS * to get equal ratings for launchers. */ if (wield_slot(o_ptr) == INVEN_BOW) { p /= MAX_BLOWS; file_putf(log_file, "Rescaling bow power, total is %d\n", p); } /* Add power for +to_hit */ p += (o_ptr->to_h * TO_HIT_POWER / 2); file_putf(log_file, "Adding power for to hit, total is %d\n", p); /* Add power for base AC and adjust for weight */ if (o_ptr->ac) { q += BASE_ARMOUR_POWER; q += (o_ptr->ac * BASE_AC_POWER / 2); file_putf(log_file, "Adding %d power for base AC value\n", q); /* Add power for AC per unit weight */ if (o_ptr->weight > 0) { i = 800 * (o_ptr->ac + o_ptr->to_a) / o_ptr->weight; /* Avoid overpricing Elven Cloaks */ if (i > 450) i = 450; q *= i; q /= 100; /* Weightless (ethereal) armour items get fixed boost */ } else q *= 5; p += q; file_putf(log_file, "Adding power for AC per unit weight, now %d\n", p); } /* Add power for +to_ac */ p += (o_ptr->to_a * TO_AC_POWER / 2); file_putf(log_file, "Adding power for to_ac of %d, total is %d\n", o_ptr->to_a, p); if (o_ptr->to_a > HIGH_TO_AC) { p += ((o_ptr->to_a - (HIGH_TO_AC - 1)) * TO_AC_POWER); file_putf(log_file, "Adding power for high to_ac value, total is %d\n", p); } if (o_ptr->to_a > VERYHIGH_TO_AC) { p += ((o_ptr->to_a - (VERYHIGH_TO_AC -1)) * TO_AC_POWER * 2); file_putf(log_file, "Adding power for very high to_ac value, total is %d\n", p); } if (o_ptr->to_a >= INHIBIT_AC) { p += INHIBIT_POWER; file_putf(log_file, "INHIBITING: AC bonus too high\n"); } /* Add power for light sources by radius XXX Hack - rewrite calc_torch! */ if (wield_slot(o_ptr) == INVEN_LIGHT) { p += BASE_LIGHT_POWER; /* Artifact lights have larger radius so add more */ if (o_ptr->artifact) p += BASE_LIGHT_POWER; file_putf(log_file, "Adding power for light radius, total is %d\n", p); } /* Add base power for jewelry */ if (object_is_jewelry(o_ptr)) { p += BASE_JEWELRY_POWER; file_putf(log_file, "Adding power for jewelry, total is %d\n", p); } /* Add power for non-derived flags (derived flags have flag_power 0) */ for (i = 0; i < OF_MAX; i++) { if (of_has(flags, i)) { if (flag_uses_pval(i)) { j = which_pval(o_ptr, i); if (known || object_this_pval_is_visible(o_ptr, j)) { k = o_ptr->pval[j]; extra_stat_bonus += (k * pval_mult(i)); } } else k = 1; if (flag_power(i)) { p += (k * flag_power(i) * slot_mult(i, wield_slot(o_ptr))); file_putf(log_file, "Adding power for %s, total is %d\n", flag_name(i), p); } /* Track combinations of flag types - note we ignore SUST_CHR */ for (j = 0; j < N_ELEMENTS(sets); j++) if ((sets[j].type == obj_flag_type(i)) && (i != OF_SUST_CHR)) sets[j].count++; } } /* Add extra power term if there are a lot of ability bonuses */ if (extra_stat_bonus > 249) { file_putf(log_file, "Inhibiting! (Total ability bonus of %d is too high)\n", extra_stat_bonus); p += INHIBIT_POWER; } else { p += ability_power[extra_stat_bonus / 10]; file_putf(log_file, "Adding power for pval total of %d, total is %d\n", extra_stat_bonus, p); } /* Add extra power for multiple flags of the same type */ for (i = 0; i < N_ELEMENTS(sets); i++) { if (sets[i].count > 1) { p += (sets[i].factor * sets[i].count * sets[i].count); file_putf(log_file, "Adding power for multiple flags of type %d, total is %d\n", i, p); } /* Add bonus if item has a full set of these flags */ if (sets[i].count == sets[i].size) { p += sets[i].bonus; file_putf(log_file, "Adding power for full set of type %d, total is %d\n", i, p); } } /* add power for effect */ if (known || object_effect_is_known(o_ptr)) { if (o_ptr->artifact && o_ptr->artifact->effect) { p += effect_power(o_ptr->artifact->effect); file_putf(log_file, "Adding power for artifact activation, total is %d\n", p); } else { p += effect_power(o_ptr->kind->effect); file_putf(log_file, "Adding power for item activation, total is %d\n", p); } } file_putf(log_file, "FINAL POWER IS %d\n", p); return p; }