static int ShipSpeedBonus(const unit * u) { const ship * sh = u->ship; static int config; static int bonus; if (config_changed(&config)) { bonus = config_get_int("movement.shipspeed.skillbonus", 0); } if (bonus > 0) { int skl = effskill(u, SK_SAILING, NULL); int minsk = (sh->type->cptskill + 1) / 2; return (skl - minsk) / bonus; } else if (sh->type->flags & SFL_SPEEDY) { int base = 3; int speed = 0; int minsk = sh->type->cptskill * base; int skl = effskill(u, SK_SAILING, NULL); while (skl >= minsk) { ++speed; minsk *= base; } return speed; } return 0; }
static int produceexp_days(void) { static int config, rule; if (config_changed(&config)) { rule = config_get_int("study.produceexp", EXPERIENCEDAYS); } return rule; }
static bool ExpensiveMigrants(void) { static bool rule; static int cache; if (config_changed(&cache)) { rule = config_get_int("study.expensivemigrants", 0) != 0; } return rule; }
bool DevInst::set_config(const sr_probe_group *group, int key, GVariant *data) { assert(_owner); sr_dev_inst *const sdi = dev_inst(); assert(sdi); if(sr_config_set(sdi, group, key, data) == SR_OK) { config_changed(); return true; } return false; }
int main(int count, char **options) { int res; if (strcmp(options[1], "-d") != 0) { res = daemon(0, 0); printf("return value: %s\n", res); } res_init(); _res.retrans = 4; _res.retry = 2; int running = 1; if (parse_config()) { printf("error reading configuration!\n"); return 1; } if (open_status_socket()) printf("error opening status socket; no status will be provided\n"); stat(config_file, &config_last_mod); printf("last config modified time: %s\n", ctime(&config_last_mod.st_mtime)); while (running) { struct config_interfaces *cur = config; printf("checking if conf file has changed\n"); if (config_changed()) { printf("modifying:\n"); clear_config(config); cur = 0; if (parse_config()) printf("error reading configuration!\n"); else cur = config; } while (cur) { if (check_interface(cur)) { printf("media type: %s\n", mediatype(cur->if_name)); if (strcmp(mediatype(cur->if_name), "Ethernet") == 0) { if (setup_ethernetinterface(cur)) break; } else if (strcmp(mediatype(cur->if_name), "IEEE802.11") == 0) { if (setup_wlaninterface(cur)) break; } } cur = cur->next; } printf("Sleeping... waiting %d seconds\n", poll_wait); sleep(poll_wait); printf("restarto\n"); } return 0; }
void DevInst::enable_probe(const sr_probe *probe, bool enable) { assert(_owner); sr_dev_inst *const sdi = dev_inst(); assert(sdi); for (const GSList *p = sdi->probes; p; p = p->next) if (probe == p->data) { const_cast<sr_probe*>(probe)->enabled = enable; config_changed(); return; } // Probe was not found in the device assert(0); }
void CQueryWindowOptionsDialog::okButtonClicked() { #ifdef DEBUG qDebug("CQueryWindowOptionsDialog::okButtonClicked()"); #endif bool ret = save(config); ret &= config->save(); if (!ret) { mysql->showMessage(CRITICAL, tr("An error occurred while saving the Query configuration")); return; } emit config_changed(); mysql->showMessage(INFORMATION, tr("Query configuration updated successfully")); dialogAccepted(); }
/** Talente von Daemonen verschieben sich. */ void demon_skillchange(unit *u) { skill *sv = u->skills; int upchance = 15, downchance = 10; static int config; static bool rule_hunger; static int cfgup, cfgdown; if (config_changed(&config)) { rule_hunger = config_get_int("hunger.demon.skills", 0) != 0; cfgup = config_get_int("skillchange.demon.up", 15); cfgdown = config_get_int("skillchange.demon.down", 10); } if (cfgup == 0) { /* feature is disabled */ return; } upchance = cfgup; downchance = cfgdown; if (fval(u, UFL_HUNGER)) { /* hungry demons only go down, never up in skill */ if (rule_hunger) { downchance = upchance; upchance = 0; } } while (sv != u->skills + u->skill_size) { int roll = rng_int() % 100; if (sv->level > 0 && roll < upchance + downchance) { int weeks = 1 + rng_int() % 3; if (roll < downchance) { reduce_skill(u, sv, weeks); if (sv->level < 1) { /* demons should never forget below 1 */ set_level(u, sv->id, 1); } } else { learn_skill(u, sv->id, STUDYDAYS * u->number * weeks); } } ++sv; } }
int max_magicians(const faction * f) { static int rule, config, rc_cache; static const race *rc_elf; int m; if (config_changed(&config)) { rule = config_get_int("rules.maxskills.magic", 3); } m = rule; if (rc_changed(&rc_cache)) { rc_elf = get_race(RC_ELF); } if (f->race == rc_elf) { ++m; } return m; }
int study_cost(struct unit *u, skill_t sk) { if (sk == SK_MAGIC) { static int config; static int cost; /* Die Magiekosten betragen 50+Summe(50*Stufe) */ /* 'Stufe' ist dabei die naechste zu erreichende Stufe */ if (config_changed(&config)) { cost = config_get_int("skills.cost.magic", 50); } if (cost > 0) { int next_level = 1 + (u ? get_level(u, sk) : 0); return cost * (1 + ((next_level + next_level * next_level) / 2)); } return cost; } return skill_cost(sk); }
gboolean nm_dns_manager_add_ip6_config (NMDnsManager *mgr, const char *iface, NMIP6Config *config, NMDnsIPConfigType cfg_type) { NMDnsManagerPrivate *priv; GError *error = NULL; g_return_val_if_fail (mgr != NULL, FALSE); g_return_val_if_fail (iface != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE); priv = NM_DNS_MANAGER_GET_PRIVATE (mgr); switch (cfg_type) { case NM_DNS_IP_CONFIG_TYPE_VPN: /* FIXME: not quite yet... */ g_return_val_if_fail (cfg_type != NM_DNS_IP_CONFIG_TYPE_VPN, FALSE); priv->ip6_vpn_config = config; break; case NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE: priv->ip6_device_config = config; break; default: break; } /* Don't allow the same zone added twice */ if (!g_slist_find (priv->configs, config)) priv->configs = g_slist_append (priv->configs, g_object_ref (config)); if (!config_changed (mgr)) return TRUE; if (!update_dns (mgr, iface, FALSE, &error)) { nm_log_warn (LOGD_DNS, "could not commit DNS changes: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); } return TRUE; }
static int AllianceRestricted(void) { static int config, rule; if (config_changed(&config)) { const char *str = config_get("alliance.restricted"); rule = 0; if (str != NULL) { char *sstr = str_strdup(str); char *tok = strtok(sstr, " "); while (tok) { rule |= ally_flag(tok, -1); tok = strtok(NULL, " "); } free(sstr); } rule &= HelpMask(); } return rule; }
bool check_student(const struct unit *u, struct order *ord, skill_t sk) { int err = 0; const race *rc = u_race(u); if (sk < 0) { err = 77; } /* Hack: Talente mit Malus -99 koennen nicht gelernt werden */ else if (rc->bonus[sk] == -99) { err = 771; } else { static int config; static bool learn_newskills; if (config_changed(&config)) { learn_newskills = config_get_int("study.newskills", 1) != 0; } if (!learn_newskills) { skill *sv = unit_skill(u, sk); if (sv == NULL) { /* we can only learn skills we already have */ err = 771; } } } if (err) { if (ord) { cmistake(u, ord, err, MSG_EVENT); } return false; } if ((u_race(u)->flags & RCF_NOLEARN) || fval(u, UFL_WERE)) { if (ord) { ADDMSG(&u->faction->msgs, msg_feedback(u, ord, "error_race_nolearn", "race", u_race(u))); } return false; } return true; }
/** Limits the available help modes * The bitfield returned by this function specifies the available help modes * in this game (so you can, for example, disable HELP GIVE globally). * Disabling a status will disable the command sequence entirely (order parsing * uses this function). */ int HelpMask(void) { static int config, rule; if (config_changed(&config)) { const char *str = config_get("rules.help.mask"); if (str != NULL) { char *sstr = str_strdup(str); char *tok = strtok(sstr, " "); rule = 0; while (tok) { rule |= ally_flag(tok, -1); tok = strtok(NULL, " "); } free(sstr); } else { rule = HELP_ALL; } } return rule; }
gboolean nm_dns_manager_remove_ip6_config (NMDnsManager *mgr, const char *iface, NMIP6Config *config) { NMDnsManagerPrivate *priv; GError *error = NULL; g_return_val_if_fail (mgr != NULL, FALSE); g_return_val_if_fail (iface != NULL, FALSE); g_return_val_if_fail (config != NULL, FALSE); priv = NM_DNS_MANAGER_GET_PRIVATE (mgr); /* Can't remove it if it wasn't in the list to begin with */ if (!g_slist_find (priv->configs, config)) return FALSE; priv->configs = g_slist_remove (priv->configs, config); if (config == priv->ip6_vpn_config) priv->ip6_vpn_config = NULL; if (config == priv->ip6_device_config) priv->ip6_device_config = NULL; g_object_unref (config); if (!config_changed (mgr)) return TRUE; if (!update_dns (mgr, iface, FALSE, &error)) { nm_log_warn (LOGD_DNS, "could not commit DNS changes: (%d) %s", error ? error->code : -1, error && error->message ? error->message : "(unknown)"); g_clear_error (&error); } return TRUE; }