Ejemplo n.º 1
0
g_error gl_init(void) {
    const char *s;
    g_error e;

    /* Load an inlib to handle rendering continuously (or not) */
    e = load_inlib(&gl_continuous_regfunc,&gl_global.continuous_inlib);
    errorcheck;

    s = get_param_str(GL_SECTION,"texture_filtering","linear");
    if (!strcmp(s,"linear")) {
        gl_global.texture_filtering = GL_LINEAR_MIPMAP_LINEAR;
    }
    else {
        gl_global.texture_filtering = GL_NEAREST;
    }

    sscanf(get_param_str(GL_SECTION,"fps_interval","0.25"),"%f",&gl_global.fps_interval);
    gl_global.continuous = get_param_int(GL_SECTION,"continuous",0);
    gl_global.antialias = get_param_int(GL_SECTION,"antialias",0);

    if (get_param_int(GL_SECTION,"keys",1)) {
        e = infilter_insert(&infilter_list, &gl_global.h_infilter, -1, &infilter_gl);
        errorcheck;
    }

    return success;
}
Ejemplo n.º 2
0
// local function definitions
static void mavlink_send_heartbeat(void)
{
    MAV_MODE armed_mode = MAV_MODE_ENUM_END; // used for failsafe
    if(_armed_state == ARMED)
        armed_mode = MAV_MODE_MANUAL_ARMED;
    else if(_armed_state == DISARMED)
        armed_mode = MAV_MODE_MANUAL_DISARMED;

    uint8_t control_mode = 0;
    if(get_param_int(PARAM_FIXED_WING))
    {
        control_mode = MODE_PASS_THROUGH;
    }
    else if(rc_switch(get_param_int(PARAM_RC_F_CONTROL_TYPE_CHANNEL)))
    {
        control_mode = MODE_ROLL_PITCH_YAWRATE_ALTITUDE;
    }
    else
    {
        control_mode = rc_switch(get_param_int(PARAM_RC_ATT_CONTROL_TYPE_CHANNEL)) ? MODE_ROLL_PITCH_YAWRATE_THROTTLE : MODE_ROLLRATE_PITCHRATE_YAWRATE_THROTTLE;
    }

    mavlink_msg_heartbeat_send(MAVLINK_COMM_0,
                               get_param_int(PARAM_FIXED_WING) ? MAV_TYPE_FIXED_WING : MAV_TYPE_QUADROTOR,
                               MAV_AUTOPILOT_GENERIC,
                               armed_mode,
                               control_mode,
                               MAV_STATE_STANDBY);
}
Ejemplo n.º 3
0
bard_window *bard_make_help_window(bard_reader *br)
{
    bard_window *hw;
    int indent = 10;
    char *bhs;

    hw = bard_window_new("help",
                         br->display->screen_width-(2*indent),
                         br->display->screen_height-(2*indent),
                         br->display->screen->format);
    hw->x_offset = indent;
    hw->y_offset = indent;
    hw->font_name = 
        cst_strdup(get_param_string(br->config,"-font",BARD_DEFAULT_FONT));
    hw->font_size =
        get_param_int(br->config,"-help_font_size",
                      get_param_int(br->config,"-font_size",
                                    BARD_DEFAULT_FONT_SIZE));
    /* We assume we can open this font, as if we couldn't when initializing */
    /* the display window, we'd have failed by now */
    hw->font = bard_window_open_font(hw->font_name,hw->font_size);

    hw->background_color = 
        bard_color_get(br->colors,
         get_param_string(br->config,"-help_background_color","cornsilk"));
    hw->foreground_color = 
        bard_color_get(br->colors,
         get_param_string(br->config,"-help_foreground_color","steelblue"));
    hw->highlight_color = 
        bard_color_get(br->colors,
         get_param_string(br->config,"-help_highlight_color","blue"));

    hw->tm=10;
    hw->bm=10;
    hw->tlm=10;
    hw->trm=10;

    bhs = cst_alloc(char,cst_strlen(bard_help_string)+
                    cst_strlen(BARD_PROJECT_VERSION)+
                    cst_strlen(BARD_PROJECT_STATE)+
                    cst_strlen(BARD_PROJECT_DATE)+1);
    cst_sprintf(bhs,bard_help_string,BARD_PROJECT_VERSION,
                BARD_PROJECT_STATE,
                BARD_PROJECT_DATE);

    hw->ts = ts_open_string(bhs,
                     cst_ts_default_whitespacesymbols,
                     "",
                     cst_ts_default_prepunctuationsymbols,
                     cst_ts_default_postpunctuationsymbols);
    hw->ts_mode = "literal";
    cst_free(bhs);

    hw->update = bard_window_help_update;

    /* Put something on the screen */
    bard_window_display_from_pos(hw,0);

    return hw;
}
Ejemplo n.º 4
0
void F_label(Rainbow_hdr *rainbow_header, char* buf)
{
    int labelnum, day, month, year, sec, minute, hour;
    float lat, lon;

    sscanf(buf, "%*c%d", &labelnum);

    switch (labelnum) {
	case 3:
	    rainbow_header->compressed = get_param_int(buf);
	    break;
	case 4:
	    sscanf(buf, "%*c%*d : %f %f", &lon, &lat);
	    rainbow_header->lon = lon;
	    rainbow_header->lat = lat;
	    break;
	case 5:
	    sscanf(buf, "%*c%*d : %d %d %d", &day, &month, &year);
	    rainbow_header->month = month;
	    rainbow_header->day = day;
	    rainbow_header->year = year;
	    break;
	case 6:
	    sscanf(buf, "%*c%*d : %d %d %d", &sec, &minute, &hour);
	    rainbow_header->hour = hour;
	    rainbow_header->minute = minute;
	    rainbow_header->sec = sec;
	    break;
	case 9:
	    rainbow_header->datatype = get_param_int(buf);
	    break;
    }
}
Ejemplo n.º 5
0
static int
find_modem_node(const char* pattern, int fetch_pref, int fetch_devnum, int fetch_index, int *devnum_out)
{
	FILE *fp;
	int i, node_pref, node_devnum, node_valid_last;
	char node_fname[64];
	
	node_valid_last = -1;
	if (devnum_out)
		*devnum_out = 0;
	
	for (i=0; i<MAX_USB_NODE; i++) {
		node_pref = 0;
		node_devnum = 0;
		sprintf(node_fname, "%s/%s%d", MODEM_NODE_DIR, pattern, i);
		fp = fopen(node_fname, "r+");
		if (fp) {
			char buf[32];
			while (fgets(buf, sizeof(buf), fp)) {
				int tmp;
				char *ptr;
				if ((ptr = strchr(buf, '\n')))
					*ptr = 0;
				tmp = get_param_int(buf, "pref=", 10, -1);
				if (tmp >= 0) {
					node_pref = tmp;
				} else {
					tmp = get_param_int(buf, "devnum=", 10, -1);
					if (tmp >= 0) {
						node_devnum = tmp;
						if (devnum_out)
							*devnum_out = tmp;
					}
				}
			}
			fclose(fp);
			
			node_valid_last = i;
			
			if (fetch_index >= 0) {
				if (i == fetch_index)
					return i;
			} else {
				if (fetch_devnum && fetch_devnum != node_devnum)
					continue;
				
				if (!fetch_pref || node_pref > 0)
					return i;
			}
		}
	}
	
	if (fetch_index >= 0 && node_valid_last >= 0)
		return node_valid_last;
	
	return -1;
}
Ejemplo n.º 6
0
static void test_param_int(CuTest * tc)
{
    struct param *par = 0;
    test_cleanup();
    CuAssertIntEquals(tc, 13, get_param_int(par, "foo", 13));
    set_param(&par, "foo", "23");
    set_param(&par, "bar", "42");
    CuAssertIntEquals(tc, 23, get_param_int(par, "foo", 0));
    CuAssertIntEquals(tc, 42, get_param_int(par, "bar", 0));
}
Ejemplo n.º 7
0
static int do_potion(unit * u, region *r, const potion_type * ptype, int amount)
{
  if (ptype == oldpotiontype[P_LIFE]) {
    int holz = 0;
    static int tree_type = -1;
    static int tree_count = -1;
    if (tree_type < 0) {
      tree_type = get_param_int(global.parameters, "rules.magic.wol_type", 1);
      tree_count =
        get_param_int(global.parameters, "rules.magic.wol_effect", 10);
    }
    /* mallorn is required to make mallorn forests, wood for regular ones */
    if (fval(r, RF_MALLORN)) {
      holz = use_pooled(u, rt_find("mallorn"),
        GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
    } else {
      holz = use_pooled(u, rt_find("log"),
        GET_SLACK | GET_RESERVE | GET_POOLED_SLACK, tree_count * amount);
    }
    if (r->land == 0)
      holz = 0;
    if (holz < tree_count * amount) {
      int x = holz / tree_count;
      if (holz % tree_count)
        ++x;
      if (x < amount)
        amount = x;
    }
    rsettrees(r, tree_type, rtrees(r, tree_type) + holz);
    ADDMSG(&u->faction->msgs, msg_message("growtree_effect",
        "mage amount", u, holz));
  } else if (ptype == oldpotiontype[P_HEILWASSER]) {
    u->hp = _min(unit_max_hp(u) * u->number, u->hp + 400 * amount);
  } else if (ptype == oldpotiontype[P_PEOPLE]) {
    attrib *a = (attrib *) a_find(r->attribs, &at_peasantluck);
    if (!a)
      a = a_add(&r->attribs, a_new(&at_peasantluck));
    a->data.i += amount;
  } else if (ptype == oldpotiontype[P_HORSE]) {
    attrib *a = (attrib *) a_find(r->attribs, &at_horseluck);
    if (!a)
      a = a_add(&r->attribs, a_new(&at_horseluck));
    a->data.i += amount;
  } else if (ptype == oldpotiontype[P_WAHRHEIT]) {
    fset(u, UFL_DISBELIEVES);
    amount = 1;
  } else if (ptype == oldpotiontype[P_MACHT]) {
    /* Verfünffacht die HP von max. 10 Personen in der Einheit */
    u->hp += _min(u->number, 10 * amount) * unit_max_hp(u) * 4;
  } else {
    change_effect(u, ptype, 10 * amount);
  }
  return amount;
}
Ejemplo n.º 8
0
void R_label(Rainbow_hdr *rainbow_header, char* buf)
{
    int labelnum;

    sscanf(buf, "%*c%d", &labelnum);

    if (labelnum == 1)
      rainbow_header->nbins = get_param_int(buf);
    else if (labelnum == 2)
      rainbow_header->bin_resolution = get_param_float(buf);
    else if (labelnum == 8)
      rainbow_header->nvalues = get_param_int(buf);
}
Ejemplo n.º 9
0
void terraform_resources(region * r)
{
    int i;
    const terrain_type *terrain = r->terrain;
    static int terraform_all = -1;
    if (terraform_all < 0) {
        terraform_all = get_param_int(global.parameters, "rules.terraform.all", 0);
    }

    if (terrain->production == NULL)
        return;
    for (i = 0; terrain->production[i].type; ++i) {
        rawmaterial *rm;
        const terrain_production *production = terrain->production + i;
        const resource_type *rtype = production->type;

        for (rm = r->resources; rm; rm = rm->next) {
            if (rm->type->rtype == rtype)
                break;
        }
        if (rm) {
            continue;
        }

        if (terraform_all || chance(production->chance)) {
            add_resource(r, dice_rand(production->startlevel),
                dice_rand(production->base), dice_rand(production->divisor),
                production->type);
        }
    }
}
Ejemplo n.º 10
0
static inline int
spd_say_sending(SPDConnection *connection, const char* text)
{
    int msg_id = -1;
    int err = 0;
    char *reply = NULL;
    char *pret = NULL;

    /* Send data */
    SPD_DBG("Sending data");
    pret = spd_send_data_wo_mutex(connection, text, SPD_NO_REPLY);
    if (pret==NULL) {
	SPD_DBG("Can't send data wo mutex");
    } else {
	/* Terminate data flow */
	SPD_DBG("Terminating data flow");
	err = spd_execute_command_with_reply(connection, "\r\n.", &reply);
	if (err) {
	    SPD_DBG("Can't terminate data flow");
	} else {
	    msg_id = get_param_int(reply, 1, &err);
	    if (err < 0) {
		SPD_DBG("Can't determine SSIP message unique ID parameter.");
		msg_id = -1;
	    }
	}
    }

    xfree(reply);
    xfree(pret);
    return msg_id;
}
Ejemplo n.º 11
0
int study_cost(unit * u, skill_t sk)
{
    static int cost[MAXSKILLS];
    int stufe, k = 50;

    if (cost[sk] == 0) {
        char buffer[256];
        sprintf(buffer, "skills.cost.%s", skillnames[sk]);
        cost[sk] = get_param_int(global.parameters, buffer, -1);
    }
    if (cost[sk] >= 0) {
        return cost[sk];
    }
    switch (sk) {
    case SK_SPY:
        return 100;
    case SK_TACTICS:
    case SK_HERBALISM:
    case SK_ALCHEMY:
        return 200;
    case SK_MAGIC:               /* Die Magiekosten betragen 50+Summe(50*Stufe) */
        /* 'Stufe' ist dabei die naechste zu erreichende Stufe */
        stufe = 1 + get_level(u, SK_MAGIC);
        return k * (1 + ((stufe + 1) * stufe / 2));
    default:
        return 0;
    }
}
Ejemplo n.º 12
0
static int rc_herb_trade(const struct race *rc)
{
    if (rc) {
        return get_param_int(rc->parameters, "herb_trade", 500);
    }
    return 500;
}
Ejemplo n.º 13
0
int unit_max_hp(const unit * u)
{
  static int rules_stamina = -1;
  int h;
  double p;
  static const curse_type *heal_ct = NULL;

  if (rules_stamina < 0) {
    rules_stamina =
      get_param_int(global.parameters, "rules.stamina", STAMINA_AFFECTS_HP);
  }
  h = u_race(u)->hitpoints;
  if (heal_ct == NULL)
    heal_ct = ct_find("healingzone");

  if (rules_stamina & 1) {
    p = pow(effskill(u, SK_STAMINA) / 2.0, 1.5) * 0.2;
    h += (int)(h * p + 0.5);
  }
  /* der healing curse verändert die maximalen hp */
  if (heal_ct) {
    curse *c = get_curse(u->region->attribs, heal_ct);
    if (c) {
      h = (int)(h * (1.0 + (curse_geteffect(c) / 100)));
    }
  }

  return h;
}
Ejemplo n.º 14
0
static int rc_luxury_trade(const struct race *rc)
{
    if (rc) {
        return get_param_int(rc->parameters, "luxury_trade", 1000);
    }
    return 1000;
}
Ejemplo n.º 15
0
/// TODO: Be able to tell if the RC has become disconnected during flight
bool check_failsafe(void)
{
  for(int8_t i = 0; i<get_param_int(PARAM_RC_NUM_CHANNELS); i++)
  {
    if(pwmRead(i) < 900 || pwmRead(i) > 2100)
    {
      if(_armed_state == ARMED || _armed_state == DISARMED)
      {
        _armed_state = FAILSAFE_DISARMED;
      }

      // blink LED
      static uint8_t count = 0;
      if(count > 25)
      {
        LED1_TOGGLE;
        count = 0;
      }
      count++;
      return true;
    }
  }

  // we got a valid RC measurement for all channels
  if(_armed_state == FAILSAFE_ARMED || _armed_state == FAILSAFE_DISARMED)
  {
    // return to appropriate mode
    _armed_state = (_armed_state == FAILSAFE_ARMED) ? ARMED : DISARMED;
  }
  return false;
}
Ejemplo n.º 16
0
g_error x11_create_window(hwrbitmap *hbmp) {
  struct x11bitmap *xb;
  g_error e;
  XSetWindowAttributes attr;

  e = g_malloc((void**)&xb, sizeof(struct x11bitmap));
  errorcheck;
  memset(xb,0,sizeof(struct x11bitmap));
  xb->is_window = 1;

  /* Create the window.
   * The size and everything else will be configured in x11_internal_window_resize()
   */
  xb->d = XCreateSimpleWindow(x11_display, RootWindow(x11_display, x11_screen),0,0,1,1,0,0,0);
  xb->sb.w = xb->sb.h = 0;

  /* This prevents X from redrawing the window background at all */
  XSetWindowBackgroundPixmap(x11_display, xb->d, None);

  /* Optionally double-buffer this window */
  if (get_param_int("video-x11","doublebuffer",1)) {
    e = x11_new_backbuffer(&xb, xb);
    errorcheck;
  }

  xb->next_window = x11_window_list;
  x11_window_list = xb;

  *hbmp = (hwrbitmap) xb;
  return success;
}
Ejemplo n.º 17
0
void read_rainbow_header(Rainbow_hdr *rainbow_header, FILE *fp)
{
    /* Reads parameters from Rainbow file header into a rainbow header
       structure. */

    char buf[BUFSIZE];
    int label;

    /* Read each line of the header and extract parameters according to the
     * label.  The label is a single alphabetic character at the beginning
     * of the line which indicates a category of parameters.
     */

    while ((label = read_hdr_line(buf, BUFSIZE, fp)) != ETX && label > 0) {
	switch (label) {
	    case 'H': H_label(rainbow_header, buf);
		      break;
	    case 'P': P_label(rainbow_header, buf);
		      break;
	    case 'W': W_label(rainbow_header, buf);
		      break;
	    case 'F': F_label(rainbow_header, buf);
		      break;
	    case 'R': R_label(rainbow_header, buf);
		      break;
	    case 'A': A_label(rainbow_header, buf);
		      break;
	    case 'N': rainbow_header->product = get_param_int(buf);
		      break;
	    case 'X': /* X_label(rainbow_header, buf); */
		      break;
	}
    }
}
Ejemplo n.º 18
0
g_error panelbar_install(struct widget *self) {
  /* Divtree set up almost exactly like the box widget */
  g_error e;

  WIDGET_ALLOC_DATA(panelbardata);

  e = newdiv(&self->in,self);
  errorcheck;
  self->in->flags |= PG_S_BOTTOM;
  self->in->flags &= ~DIVNODE_SIZE_AUTOSPLIT;
  e = newdiv(&self->in->div,self);
  errorcheck;
  self->in->div->flags |= DIVNODE_SPLIT_BORDER;
  self->in->div->flags &= ~DIVNODE_SIZE_AUTOSPLIT;
  self->in->div->build = &build_bgfill_only;
  self->in->div->state = PGTH_O_PANELBAR_H;
  DATA->panelbar = self->in->div;

  self->out = &self->in->next;
  self->sub = &self->in->div->div;

  self->trigger_mask = PG_TRIGGER_ENTER | PG_TRIGGER_LEAVE | PG_TRIGGER_DOWN |
    PG_TRIGGER_UP | PG_TRIGGER_RELEASE | PG_TRIGGER_DRAG | PG_TRIGGER_MOVE;

  /* Panelbars use auto-orientation by default */
  self->auto_orientation = PG_AUTO_SIDE | PG_AUTO_DIRECTION;

#ifdef CONFIG_DRAGSOLID
  DATA->solid = get_param_int("pgserver","dragsolid",0);
#endif

  return success;
}
Ejemplo n.º 19
0
static void mavlink_send_imu(void)
{
    if (get_param_int(PARAM_STREAM_ADJUSTED_GYRO))
    {
        mavlink_msg_small_imu_send(MAVLINK_COMM_0,
                                   _imu_time,
                                   _accel.x,
                                   _accel.y,
                                   _accel.z,
                                   _gyro.x - _adaptive_gyro_bias.x,
                                   _gyro.y - _adaptive_gyro_bias.y,
                                   _gyro.z - _adaptive_gyro_bias.z,
                                   _imu_temperature);
    }
    else
    {
        mavlink_msg_small_imu_send(MAVLINK_COMM_0,
                                   _imu_time,
                                   _accel.x,
                                   _accel.y,
                                   _accel.z,
                                   _gyro.x,
                                   _gyro.y,
                                   _gyro.z,
                                   _imu_temperature);
    }
}
Ejemplo n.º 20
0
int roqf_factor(void)
{
    int value = -1;
    if (value < 0) {
        value = get_param_int(global.parameters, "rules.economy.roqf", 10);
    }
    return value;
}
Ejemplo n.º 21
0
// function definitions
void init_mavlink(void)
{
  // Initialize Serial ports
  mavlink_system.sysid = get_param_int(PARAM_SYSTEM_ID);
  mavlink_system.compid = 250;

  _offboard_control_time = 0;
}
Ejemplo n.º 22
0
void A_label(Rainbow_hdr *rainbow_header, char* buf)
{
    int labelnum;
    char label;

    sscanf(buf, "%c%d", &label, &labelnum);

    if (labelnum == 3) 
	rainbow_header->az_step = get_param_float(buf);
     else if (labelnum == 9)
	rainbow_header->nsweeps = get_param_int(buf);
}
Ejemplo n.º 23
0
void H_label(Rainbow_hdr *rainbow_header, char* buf)
{
    int labelnum;
    char label;

    sscanf(buf, "%c%d", &label, &labelnum);

    if (labelnum == 3)
      rainbow_header->filetype = get_param_int(buf);
    else if (labelnum == 8)
      strcpy(rainbow_header->radarname, get_param_string(buf));
}
Ejemplo n.º 24
0
/** Talente von Dämonen verschieben sich.
 */
static void demon_skillchanges(void)
{
  region *r;

  for (r = regions; r; r = r->next) {
    unit *u;
    for (u = r->units; u; u = u->next) {
        if (u_race(u) == get_race(RC_DAEMON)) {
        skill *sv = u->skills;
        int upchance = 15;
        int downchance = 10;

        if (fval(u, UFL_HUNGER)) {
          /* hungry demons only go down, never up in skill */
          static int rule_hunger = -1;
          if (rule_hunger < 0) {
            rule_hunger =
              get_param_int(global.parameters, "hunger.demon.skill", 0);
          }
          if (rule_hunger) {
            upchance = 0;
            downchance = 15;
          }
        }

        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 {
              while (weeks--)
                learn_skill(u, sv->id, 1.0);
            }
            if (sv->old > sv->level) {
              if (verbosity >= 3) {
                log_printf(stdout, "%s dropped from %u to %u:%u in %s\n",
                  unitname(u), sv->old, sv->level, sv->weeks, skillname(sv->id,
                    NULL));
              }
            }
          }
          ++sv;
        }
      }
    }
  }
}
Ejemplo n.º 25
0
static buddy *get_friends(const unit * u, int *numfriends)
{
  buddy *friends = 0;
  faction *f = u->faction;
  region *r = u->region;
  int number = 0;
  unit *u2;

  for (u2 = r->units; u2; u2 = u2->next) {
    if (u2->faction != f && u2->number > 0) {
      int allied = 0;
      if (get_param_int(global.parameters, "rules.alliances", 0) != 0) {
        allied = (f->alliance && f->alliance == u2->faction->alliance);
      } else if (alliedunit(u, u2->faction, HELP_MONEY)
        && alliedunit(u2, f, HELP_GIVE)) {
        allied = 1;
      }
      if (allied) {
        buddy *nf, **fr = &friends;

        /* some units won't take stuff: */
        if (u_race(u2)->ec_flags & GETITEM) {
          while (*fr && (*fr)->faction->no < u2->faction->no)
            fr = &(*fr)->next;
          nf = *fr;
          if (nf == NULL || nf->faction != u2->faction) {
            nf = malloc(sizeof(buddy));
            nf->next = *fr;
            nf->faction = u2->faction;
            nf->unit = u2;
            nf->number = 0;
            *fr = nf;
          } else if (nf->faction == u2->faction
            && (u_race(u2)->ec_flags & GIVEITEM)) {
            /* we don't like to gift it to units that won't give it back */
            if ((u_race(nf->unit)->ec_flags & GIVEITEM) == 0) {
              nf->unit = u2;
            }
          }
          nf->number += u2->number;
          number += u2->number;
        }
      }
    }
  }
  if (numfriends)
    *numfriends = number;
  return friends;
}
Ejemplo n.º 26
0
g_error ftgl_engine_init(void) {
  g_error e;

  ftgl_default_size = get_param_int(CFGSECTION,"default_size",14);

  e = ftgl_fontload_init(&ftgl_load);
  errorcheck;

  os_dir_scan(get_param_str(CFGSECTION,"path","/usr/share/fonts"), &ftgl_load_callback);

  if (!ftgl_font_list)
    return mkerror(PG_ERRT_IO, 66);  /* Can't find fonts */

  ftgl_fontload_finish(ftgl_load);
  return success;
}
Ejemplo n.º 27
0
float flite_ssml_to_speech(const char *filename,
                           cst_voice *voice,
                           const char *outtype)
{
    cst_tokenstream *ts;
    int fp;
    cst_wave *w;
    float d;

    if ((ts = ts_open(filename,
	      get_param_string(voice->features,"text_whitespace",NULL),
	      get_param_string(voice->features,"text_singlecharsymbols",NULL),
	      get_param_string(voice->features,"text_prepunctuation",NULL),
	      get_param_string(voice->features,"text_postpunctuation",NULL)))
	== NULL)
    {
	cst_errmsg("failed to open file \"%s\" for ssml reading\n",
		   filename);
	return 1;
    }
    fp = get_param_int(voice->features,"file_start_position",0);
    if (fp > 0)
        ts_set_stream_pos(ts,fp);

    /* If its a file to write to, create and save an empty wave file */
    /* as we are going to incrementally append to it                 */
    if (!cst_streq(outtype,"play") && 
        !cst_streq(outtype,"none") &&
        !cst_streq(outtype,"stream"))
    {
	w = new_wave();
	cst_wave_resize(w,0,1);
	cst_wave_set_sample_rate(w,16000);
	cst_wave_save_riff(w,outtype);  /* an empty wave */
	delete_wave(w);
    }

    d = flite_ssml_to_speech_ts(ts,voice,outtype);

    ts_close(ts);
    
    return d;

}
Ejemplo n.º 28
0
bool can_leave(unit * u)
{
  static int gamecookie = -1;
  static int rule_leave = -1;

  if (!u->building) {
    return true;
  }

  if (rule_leave < 0 || gamecookie != global.cookie) {
    gamecookie = global.cookie;
    rule_leave = get_param_int(global.parameters, "rules.move.owner_leave", 0);
  }

  if (rule_leave && u->building && u == building_owner(u->building)) {
    return false;
  }
  return true;
}
Ejemplo n.º 29
0
static int begin_potion(unit * u, const potion_type * ptype, struct order *ord)
{
  static int rule_multipotion = -1;
  assert(ptype != NULL);

  if (rule_multipotion < 0) {
    /* should we allow multiple different potions to be used the same turn? */
    rule_multipotion =
      get_param_int(global.parameters, "rules.magic.multipotion", 0);
  }
  if (!rule_multipotion) {
    const potion_type *use = ugetpotionuse(u);
    if (use != NULL && use != ptype) {
      ADDMSG(&u->faction->msgs,
        msg_message("errusingpotion", "unit using command",
          u, use->itype->rtype, ord));
      return ECUSTOM;
    }
  }
  return 0;
}
Ejemplo n.º 30
0
g_error sdlgl_setmode(s16 xres,s16 yres,s16 bpp,u32 flags) {
  u32 sdlflags = SDL_RESIZABLE | SDL_OPENGL;
  char str[80];
  g_error e;
  static SDL_Surface *surface = NULL;

  /* Interpret flags */
  if (get_param_int("video-sdlgl","fullscreen",0))
    sdlflags |= SDL_FULLSCREEN;
   
  /* Set the video mode */
  if ((!surface) || xres != vid->xres || 
      yres !=vid->yres || bpp != vid->bpp) {
    surface = SDL_SetVideoMode(xres,yres,bpp,sdlflags);
    if (!surface)
      return mkerror(PG_ERRT_IO,47);
  }

  vid->bpp  = surface->format->BitsPerPixel;
  vid->xres = xres;
  vid->yres = yres;

#ifdef CONFIG_SDLSKIN
  /* If we've got SDL skinning support, set the relevant vars to good values 
   * so the input driver won't get wacky on us.
   */
  sdlfb_display_x = 0;
  sdlfb_display_y = 0;
  sdlfb_scale     = 1;
#endif
   
  e = gl_setmode(xres,yres,bpp,flags);
  errorcheck;

  snprintf(str,sizeof(str),get_param_str("video-sdlgl","caption","PicoGUI (sdlgl@%dx%dx%d)"),
	   vid->xres,vid->yres,bpp);
  SDL_WM_SetCaption(str,NULL);
  
  return success; 
}