コード例 #1
0
/**
 * Searches levels folder for LIF files and adds them to campaign levels list.
 */
TbBool find_and_load_lif_files(void)
{
  struct TbFileFind fileinfo;
  unsigned char *buf;
  char *fname;
  short result;
  int rc;
  long i;
  buf = LbMemoryAlloc(MAX_LIF_SIZE);
  if (buf == NULL)
  {
    ERRORLOG("Can't allocate memory for .LIF files parsing.");
    return false;
  }
  result = false;
  fname = prepare_file_path(FGrp_VarLevels,"*.lif");
  rc = LbFileFindFirst(fname, &fileinfo, 0x21u);
  while (rc != -1)
  {
    fname = prepare_file_path(FGrp_VarLevels,fileinfo.Filename);
    i = LbFileLength(fname);
    if ((i < 0) || (i >= MAX_LIF_SIZE))
    {
      WARNMSG("File \"%s\" too long (Max size %d)", fileinfo.Filename, MAX_LIF_SIZE);

    } else
    if (LbFileLoadAt(fname, buf) != i)
    {
      WARNMSG("Unable to read .LIF file, \"%s\"", fileinfo.Filename);
    } else
    {
      buf[i] = '\0';
      if (level_lif_file_parse(fileinfo.Filename, (char *)buf, i))
        result = true;
    }
    rc = LbFileFindNext(&fileinfo);
  }
  LbFileFindEnd(&fileinfo);
  LbMemoryFree(buf);
  return result;
}
コード例 #2
0
ファイル: instrument.cpp プロジェクト: heng-O/hydrogen
Instrument* Instrument::load_from( XMLNode* node, const QString& dk_path, const QString& dk_name )
{
	int id = node->read_int( "id", EMPTY_INSTR_ID, false, false );
	if ( id==EMPTY_INSTR_ID ) return 0;
	Instrument* instrument = new Instrument( id, node->read_string( "name", "" ), 0 );
	instrument->set_drumkit_name( dk_name );
	instrument->set_volume( node->read_float( "volume", 1.0f ) );
	instrument->set_muted( node->read_bool( "isMuted", false ) );
	instrument->set_pan_l( node->read_float( "pan_L", 1.0f ) );
	instrument->set_pan_r( node->read_float( "pan_R", 1.0f ) );
	// may not exist, but can't be empty
	instrument->set_filter_active( node->read_bool( "filterActive", true, false ) );
	instrument->set_filter_cutoff( node->read_float( "filterCutoff", 1.0f, true, false ) );
	instrument->set_filter_resonance( node->read_float( "filterResonance", 0.0f, true, false ) );
	instrument->set_random_pitch_factor( node->read_float( "randomPitchFactor", 0.0f, true, false ) );
	float attack = node->read_float( "Attack", 0.0f, true, false );
	float decay = node->read_float( "Decay", 0.0f, true, false  );
	float sustain = node->read_float( "Sustain", 1.0f, true, false );
	float release = node->read_float( "Release", 1000.0f, true, false );
	instrument->set_adsr( new ADSR( attack, decay, sustain, release ) );
	instrument->set_gain( node->read_float( "gain", 1.0f, true, false ) );
	instrument->set_mute_group( node->read_int( "muteGroup", -1, true, false ) );
	instrument->set_midi_out_channel( node->read_int( "midiOutChannel", -1, true, false ) );
	instrument->set_midi_out_note( node->read_int( "midiOutNote", MIDI_MIDDLE_C, true, false ) );
	instrument->set_stop_notes( node->read_bool( "isStopNote", true ,false ) );
	for ( int i=0; i<MAX_FX; i++ ) {
		instrument->set_fx_level( node->read_float( QString( "FX%1Level" ).arg( i+1 ), 0.0 ), i );
	}
	int n = 0;
	XMLNode layer_node = node->firstChildElement( "layer" );
	while ( !layer_node.isNull() ) {
		if ( n >= MAX_LAYERS ) {
			ERRORLOG( QString( "n >= MAX_LAYERS (%1)" ).arg( MAX_LAYERS ) );
			break;
		}
		instrument->set_layer( InstrumentLayer::load_from( &layer_node, dk_path ), n );
		n++;
		layer_node = layer_node.nextSiblingElement( "layer" );
	}
	return instrument;
}
コード例 #3
0
short good_wait_in_exit_door(struct Thing *thing)
{
    struct CreatureControl *cctrl;
    struct Thing *tmptng;
    // Debug code to find incorrect states
    if (!is_hero_thing(thing))
    {
        ERRORLOG("Non hero thing %s index %d, owner %d - reset",
            thing_model_name(thing), (int)thing->index, (int)thing->owner);
        set_start_state(thing);
        erstat_inc(ESE_BadCreatrState);
        return 0;
    }
    //return _DK_good_wait_in_exit_door(thing);
    cctrl = creature_control_get_from_thing(thing);
    if (cctrl->field_282 <= 0)
        return 0;
    cctrl->field_282--;
    if (cctrl->field_282 == 0)
    {
        tmptng = find_base_thing_on_mapwho(TCls_Object, 49, thing->mappos.x.stl.num, thing->mappos.y.stl.num);
        if (!thing_is_invalid(tmptng))
        {
            if (cctrl->byte_8A == tmptng->creation_turn)
            {
                remove_thing_from_creature_controlled_limbo(thing);
                set_start_state(thing);
                return 1;
            }
        }
        thing->creature.gold_carried = 0;
        tmptng = thing_get(cctrl->dragtng_idx);
        TRACE_THING(tmptng);
        if (!thing_is_invalid(tmptng))
        {
            delete_thing_structure(tmptng, 0);
        }
        kill_creature(thing, INVALID_THING, -1, CrDed_NoEffects|CrDed_NotReallyDying);
    }
    return 0;
}
コード例 #4
0
short good_back_at_start(struct Thing *thing)
{
    // Debug code to find incorrect states
    if (!is_hero_thing(thing))
    {
        ERRORLOG("Non hero thing %ld, %s, owner %ld - reset",(long)thing->index,thing_model_name(thing),(long)thing->owner);
        set_start_state(thing);
        return false;
    }
    //return _DK_good_back_at_start(thing);
    if (thing->creature.gold_carried <= 0)
    {
        set_start_state(thing);
        return 1;
    }
    SubtlCodedCoords stl_num;
    long m,n;
    stl_num = get_subtile_number(thing->mappos.x.stl.num,thing->mappos.y.stl.num);
    m = ACTION_RANDOM(AROUND_MAP_LENGTH);
    for (n=0; n < AROUND_MAP_LENGTH; n++)
    {
        struct Map *mapblk;
        mapblk = get_map_block_at_pos(stl_num+around_map[m]);
        // Per-block code
        if ((mapblk->flags & MapFlg_IsTall) == 0)
        {
            MapSubtlCoord stl_x, stl_y;
            stl_x = stl_num_decode_x(stl_num+around_map[m]);
            stl_y = stl_num_decode_y(stl_num+around_map[m]);
            if (setup_person_move_to_position(thing, stl_x, stl_y, NavRtF_Default)) {
                thing->continue_state = CrSt_GoodDropsGold;
                return 1;
            }
        }
        // Per-block code ends
        m = (m + 1) % AROUND_MAP_LENGTH;
    }
    set_start_state(thing);
    return 1;

}
コード例 #5
0
ファイル: config_trapdoor.c プロジェクト: dsserega/keeperfx
/**
 * Returns if the door was at least one built by a player.
 */
TbBool is_door_built(PlayerNumber plyr_idx, long door_idx)
{
    struct Dungeon *dungeon;
    dungeon = get_players_num_dungeon(plyr_idx);
    // Check if the player even have a dungeon
    if (dungeon_invalid(dungeon)) {
        return false;
    }
    // Player must have dungeon heart to build anything
    if (!player_has_heart(plyr_idx)) {
        return false;
    }
    if ((door_idx <= 0) || (door_idx >= DOOR_TYPES_COUNT)) {
        ERRORLOG("Incorrect door %d (player %d)",(int)door_idx, (int)plyr_idx);
        return false;
    }
    if ((dungeon->door_build_flags[door_idx] & MnfBldF_Built) != 0) {
        return true;
    }
    return false;
}
コード例 #6
0
TbBool attempt_job_work_in_room_near_pos(struct Thing *creatng, MapSubtlCoord stl_x, MapSubtlCoord stl_y, CreatureJob new_job)
{
    struct CreatureControl *cctrl;
    cctrl = creature_control_get_from_thing(creatng);
    SYNCDBG(16,"Starting for %s (owner %d) and job %s",thing_model_name(creatng),(int)creatng->owner,creature_job_code_name(new_job));
    struct Room *room;
    room = subtile_room_get(stl_x, stl_y);
    if (get_arrive_at_state_for_job(new_job) == CrSt_Unused) {
        ERRORLOG("No arrive at state for job %s in %s room",creature_job_code_name(new_job),room_code_name(room->kind));
        return false;
    }
    if (!creature_move_to_place_in_room(creatng, room, new_job)) {
        return false;
    }
    creatng->continue_state = get_arrive_at_state_for_job(new_job);
    cctrl->target_room_id = room->index;
    if ((new_job == Job_TRAIN) && (creatng->model == get_players_special_digger_model(room->owner))) {
        cctrl->digger.last_did_job = SDLstJob_UseTraining4;
    }
    return true;
}
コード例 #7
0
ファイル: config_trapdoor.c プロジェクト: dsserega/keeperfx
/**
 * Returns if the trap can be placed by a player.
 * Checks only if it's available and if the player is 'alive'.
 * Doesn't check if map position is on correct spot.
 */
TbBool is_trap_placeable(PlayerNumber plyr_idx, long tngmodel)
{
    struct Dungeon *dungeon;
    dungeon = get_players_num_dungeon(plyr_idx);
    // Check if the player even have a dungeon
    if (dungeon_invalid(dungeon)) {
        return false;
    }
    // Player must have dungeon heart to place traps
    if (!player_has_heart(plyr_idx)) {
        return false;
    }
    if ((tngmodel <= 0) || (tngmodel >= TRAP_TYPES_COUNT)) {
        ERRORLOG("Incorrect trap %d (player %d)",(int)tngmodel, (int)plyr_idx);
        return false;
    }
    if (dungeon->trap_amount_placeable[tngmodel] > 0) {
        return true;
    }
    return false;
}
コード例 #8
0
struct Thing *get_group_last_member(struct Thing *thing)
{
    struct Thing *ctng;
    struct CreatureControl *cctrl;
    long k;
    ctng = thing;
    cctrl = creature_control_get_from_thing(ctng);
    k = 0;
    while (cctrl->next_in_group > 0)
    {
        ctng = thing_get(cctrl->next_in_group);
        cctrl = creature_control_get_from_thing(ctng);
        k++;
        if (k > CREATURES_COUNT)
        {
          ERRORLOG("Infinite loop detected when sweeping creatures group");
          break;
        }
    }
    return ctng;
}
コード例 #9
0
short creature_choose_room_for_lair_site(struct Thing *thing)
{
    TRACE_THING(thing);
    //return _DK_creature_choose_room_for_lair_site(thing);
    struct Room *room;
    room = get_best_new_lair_for_creature(thing);
    if (room_is_invalid(room))
    {
        update_cannot_find_room_wth_spare_capacity_event(thing->owner, thing, RoK_LAIR);
        set_start_state(thing);
        return 0;
    }
    if (!setup_head_for_random_unused_lair_slab(thing, room))
    {
        ERRORLOG("Chosen lair is not valid, internal inconsistency.");
        set_start_state(thing);
        return 0;
    }
    thing->continue_state = CrSt_CreatureAtNewLair;
    return 1;
}
コード例 #10
0
ファイル: transport_info.cpp プロジェクト: AdamFf/hydrogen
void TransportInfo::printInfo()
{
	switch ( m_status ) {
	case STOPPED:
		INFOLOG( "status = STOPPED" );
		break;

	case ROLLING:
		INFOLOG( "status = ROLLING" );
		break;

	case BAD:
		INFOLOG( "status = BAD" );
		break;

	default:
		ERRORLOG( "status = unknown" );
	}
	INFOLOG( QString( "frames = %1" ).arg( m_nFrames ) );
	INFOLOG( QString( "tickSize = %1" ).arg( m_nTickSize ) );
}
コード例 #11
0
ファイル: config_trapdoor.c プロジェクト: dsserega/keeperfx
/**
 * Returns if the trap can be manufactured by a player.
 * Checks only if it's set as buildable in level script.
 * Doesn't check if player has workshop or workforce for the task.
 */
TbBool is_trap_buildable(PlayerNumber plyr_idx, long tngmodel)
{
    struct Dungeon *dungeon;
    dungeon = get_players_num_dungeon(plyr_idx);
    // Check if the player even have a dungeon
    if (dungeon_invalid(dungeon)) {
        return false;
    }
    // Player must have dungeon heart to build anything
    if (!player_has_heart(plyr_idx)) {
        return false;
    }
    if ((tngmodel <= 0) || (tngmodel >= TRAP_TYPES_COUNT)) {
        ERRORLOG("Incorrect trap %d (player %d)",(int)tngmodel, (int)plyr_idx);
        return false;
    }
    if ((dungeon->trap_build_flags[tngmodel] & MnfBldF_Manufacturable) != 0) {
        return true;
    }
    return false;
}
コード例 #12
0
TbBool load_map_wlb_file(unsigned long lv_num)
{
    struct SlabMap *slb;
    unsigned long x,y;
    unsigned char *buf;
    unsigned long i;
    unsigned long n;
    unsigned long nfixes;
    long fsize;
    SYNCDBG(7,"Starting");
    nfixes = 0;
    fsize = map_tiles_y*map_tiles_x;
    buf = load_single_map_file_to_buffer(lv_num,"wlb",&fsize,LMFF_Optional);
    if (buf == NULL)
      return false;
    i = 0;
    for (y=0; y < map_tiles_y; y++)
      for (x=0; x < map_tiles_x; x++)
      {
        slb = get_slabmap_block(x,y);
        n = (buf[i] << 3);
        n = slb->field_5 ^ ((slb->field_5 ^ n) & 0x18);
        slb->field_5 = n;
        n &= (0x08|0x10);
        if ((n != 0x10) || (slb->kind != SlbT_WATER))
          if ((n != 0x08) || (slb->kind != SlbT_LAVA))
            if (((n == 0x10) || (n == 0x08)) && (slb->kind != SlbT_BRIDGE))
            {
                nfixes++;
                slb->field_5 &= ~(0x08|0x10);
            }
        i++;
      }
    LbMemoryFree(buf);
    if (nfixes > 0)
    {
      ERRORLOG("WLB file is muddled - Fixed values for %lu tiles",nfixes);
    }
    return true;
}
コード例 #13
0
ファイル: ariadne_navitree.c プロジェクト: dsserega/keeperfx
long delaunay_seeded(long start_x, long start_y, long end_x, long end_y)
{
    long tri_idx,cor_idx;
    long tri_id2,cor_id2;
    long count;
    NAVIDBG(19,"Starting");
    //return _DK_delaunay_seeded(start_x, start_y, end_x, end_y);
    tags_init();
    delaunay_init();
    delaunay_stack_point(start_x, start_y);
    delaunay_stack_point(start_x, end_y);
    delaunay_stack_point(end_x, start_y);
    delaunay_stack_point(end_x, end_y);
    count = 0;
    while (ix_delaunay > 0)
    {
        ix_delaunay--;
        tri_idx = delaunay_stack[ix_delaunay];
        for (cor_idx=0; cor_idx < 3; cor_idx++)
        {
            if (!optimise_heuristic(tri_idx, cor_idx))
                continue;
            count++;
            edge_rotateAC(tri_idx, cor_idx);
            if (ix_delaunay+4 >= DELAUNAY_COUNT)
            {
              ERRORLOG("stack full");
              return count;
            }
            for (cor_id2=0; cor_id2 < 3; cor_id2++)
            {
                tri_id2 = Triangles[tri_idx].tags[cor_id2];
                if (tri_id2 == -1)
                    continue;
                delaunay_add_triangle(tri_id2);
            }
        }
    }
    return count;
}
コード例 #14
0
ファイル: game_saves.c プロジェクト: ommmmmmm/keeperfx
short load_continue_game(void)
{
    unsigned char buf[14];
    unsigned char bonus[20];
    char cmpgn_fname[CAMPAIGN_FNAME_LEN];
    long lvnum;
    long i;

    if (!read_continue_game_part(buf,0,14))
    {
        WARNLOG("Can't read continue game file head");
        return false;
    }
    i = (char *)&game.campaign_fname[0] - (char *)&game;
    read_continue_game_part((unsigned char *)cmpgn_fname,i,CAMPAIGN_FNAME_LEN);
    cmpgn_fname[CAMPAIGN_FNAME_LEN-1] = '\0';
    if (!change_campaign(cmpgn_fname))
    {
        ERRORLOG("Unable to load campaign");
        return false;
    }
    lvnum = ((struct Game *)buf)->continue_level_number;
    if (!is_singleplayer_like_level(lvnum))
    {
      WARNLOG("Level number in continue file is incorrect");
      return false;
    }
    set_continue_level_number(lvnum);
    LbMemorySet(bonus, 0, sizeof(bonus));
    i = (char *)&game.intralvl.bonuses_found[0] - (char *)&game;
    read_continue_game_part(bonus,i,16);
    for (i=0; i < BONUS_LEVEL_STORAGE_COUNT; i++)
      game.intralvl.bonuses_found[i] = bonus[i];
    LbStringCopy(game.campaign_fname,campaign.fname,sizeof(game.campaign_fname));
    update_extra_levels_visibility();
    i = (char *)&game.intralvl_transfered_creature - (char *)&game.intralvl.bonuses_found[0];
    game.intralvl_transfered_creature.model = bonus[i];
    game.intralvl_transfered_creature.explevel = bonus[i+1];
    return true;
}
コード例 #15
0
TbBool load_action_point_file(LevelNumber lv_num)
{
  struct InitActionPoint iapt;
  unsigned long i;
  long k;
  long total;
  unsigned char *buf;
  long fsize;
  SYNCDBG(5,"Starting");
  fsize = 4;
  buf = load_single_map_file_to_buffer(lv_num,"apt",&fsize,LMFF_None);
  if (buf == NULL)
    return false;
  i = 0;
  total = llong(&buf[i]);
  i += 4;
  // Validate total amount of action points
  if ((total < 0) || (total > (fsize-4)/sizeof(struct InitActionPoint)))
  {
    total = (fsize-4)/sizeof(struct InitActionPoint);
    WARNMSG("Bad amount of action points in APT file; corrected to %ld.",total);
  }
  if (total > ACTN_POINTS_COUNT-1)
  {
    WARNMSG("Only %d action points supported, APT file has %ld.",ACTN_POINTS_COUNT-1,total);
    total = ACTN_POINTS_COUNT-1;
  }
  // Create action points
  for (k=0; k < total; k++)
  {
    LbMemoryCopy(&iapt, &buf[i], sizeof(struct InitActionPoint));
    if (actnpoint_create_actnpoint(&iapt) == INVALID_ACTION_POINT)
    {
      ERRORLOG("Cannot allocate action point %d during APT load",k);
    }
    i += sizeof(struct InitActionPoint);
  }
  LbMemoryFree(buf);
  return true;
}
コード例 #16
0
void lightning_modify_palette(struct Thing *thing)
{
    struct PlayerInfo *myplyr;
    myplyr = get_my_player();

    if (thing->health == 0)
    {
      PaletteSetPlayerPalette(myplyr, engine_palette);
      myplyr->field_3 &= ~Pf3F_Unkn08;
      return;
    }
    if (myplyr->acamera == NULL)
    {
        ERRORLOG("No active camera");
        return;
    }
    if (((thing->health % 8) != 7) && (thing->health != 1) && (ACTION_RANDOM(4) != 0))
    {
        if ((myplyr->field_3 & Pf3F_Unkn08) != 0)
        {
            if (get_2d_box_distance(&myplyr->acamera->mappos, &thing->mappos) < 11520)
            {
                PaletteSetPlayerPalette(myplyr, engine_palette);
                myplyr->field_3 &= ~Pf3F_Unkn08;
            }
        }
        return;
    }
    if ((myplyr->view_mode != PVM_ParchFadeIn) && (myplyr->view_mode != PVM_ParchFadeOut) && (myplyr->view_mode != PVM_ParchmentView))
    {
        if ((myplyr->field_3 & Pf3F_Unkn08) == 0)
        {
            if (get_2d_box_distance(&myplyr->acamera->mappos, &thing->mappos) < 11520)
            {
              PaletteSetPlayerPalette(myplyr, lightning_palette);
              myplyr->field_3 |= Pf3F_Unkn08;
            }
        }
    }
}
コード例 #17
0
void SCDEVICE::LateInit(void)
{
  DEBUGLOG("%s", __FUNCTION__);
  int n = CardIndex();
  if (DeviceNumber() != n)
    ERRORLOG("CardIndex - DeviceNumber mismatch! Put DVBAPI plugin first on VDR commandline!");
  softcsa = (fd_ca < 0);
  if (softcsa)
  {
    if (HasDecoder())
      INFOLOG("Card %s is a full-featured card but no ca device found!", devId);
  }
  else if (cScDevices::ForceBudget(n))
  {
    INFOLOG("Budget mode forced on card %s", devId);
    softcsa = true;
  }
  if (softcsa)
  {
    INFOLOG("Using software decryption on card %s", devId);
  }
}
コード例 #18
0
struct CreatureSound *get_creature_sound(struct Thing *thing, long snd_idx)
{
    unsigned int cmodel;
    cmodel = thing->model;
    if ((cmodel < 1) || (cmodel >= CREATURE_TYPES_COUNT))
    {
        ERRORLOG("Trying to get sound for undefined creature type");
        // Return dummy element
        return &creature_sounds[0].foot;
    }
    switch (snd_idx)
    {
    case CrSnd_Hurt:
        return &creature_sounds[cmodel].hurt;
    case CrSnd_Hit:
        return &creature_sounds[cmodel].hit;
    case CrSnd_Happy:
        return &creature_sounds[cmodel].happy;
    case CrSnd_Sad:
        return &creature_sounds[cmodel].sad;
    case CrSnd_Hang:
        return &creature_sounds[cmodel].hang;
    case CrSnd_Drop:
        return &creature_sounds[cmodel].drop;
    case CrSnd_Torture:
        return &creature_sounds[cmodel].torture;
    case CrSnd_Slap:
        return &creature_sounds[cmodel].slap;
    case CrSnd_Die:
        return &creature_sounds[cmodel].die;
    case CrSnd_Foot:
        return &creature_sounds[cmodel].foot;
    case CrSnd_Fight:
        return &creature_sounds[cmodel].fight;
    default:
        // Return dummy element
        return &creature_sounds[0].foot;
    }
}
コード例 #19
0
ファイル: front_network.c プロジェクト: ommmmmmm/keeperfx
void process_network_error(long errcode)
{
  const char *text;
  switch (errcode)
  {
  case 4:
      text = get_string(GUIStr_NetLineEngaged);
      break;
  case 5:
      text = get_string(GUIStr_NetUnknownError);
      break;
  case 6:
      text = get_string(GUIStr_NetNoCarrier);
      break;
  case 7:
      text = get_string(GUIStr_NetNoDialTone);
      break;
  case -1:
      text = get_string(GUIStr_NetNoResponse);
      break;
  case -2:
      text = get_string(GUIStr_NetNoServer);
      break;
  case -800:
      text = get_string(GUIStr_NetUnableToInit);
      break;
  case -801:
      text = get_string(GUIStr_NetUnableToCrGame);
      break;
  case -802:
      text = get_string(GUIStr_NetUnableToJoin);
      break;
  default:
      ERRORLOG("Unknown modem error code %ld",errcode);
      return;
  }
  //display_centered_message(3000, text);
  create_frontend_error_box(3000, text);
}
コード例 #20
0
InstrumentComponent* InstrumentComponent::load_from( XMLNode* node, const QString& dk_path )
{
	int id = node->read_int( "component_id", EMPTY_INSTR_ID, false, false );
	if ( id==EMPTY_INSTR_ID ) {
		return nullptr;
	}

	InstrumentComponent* pInstrumentComponent = new InstrumentComponent( id );
	pInstrumentComponent->set_gain( node->read_float( "gain", 1.0f, true, false ) );
	XMLNode layer_node = node->firstChildElement( "layer" );
	int n = 0;
	while ( !layer_node.isNull() ) {
		if ( n >= maxLayers ) {
			ERRORLOG( QString( "n (%1) >= maxLayers (%2)" ).arg( n ).arg( maxLayers ) );
			break;
		}
		pInstrumentComponent->set_layer( InstrumentLayer::load_from( &layer_node, dk_path ), n );
		n++;
		layer_node = layer_node.nextSiblingElement( "layer" );
	}
	return pInstrumentComponent;
}
コード例 #21
0
struct audio_oops*
setup_alsa(const char *dev, const char *ctl)
{
  static int init_complete = 0;

  if(dev && strlen(dev) > 0) {
    device = strdup(dev);
  } else {
    device = strdup("plughw:0,0"); /* playback device */
  }

  if(init_complete) {
    ERRORLOG("already initialized\n");
    return NULL;
  }
  if(!alsa_open())
    init_complete = 1;
  else
    return NULL;

  return &alsa_oops;
}
コード例 #22
0
bool MovieController::processGetMarks(MsgPacket* request, MsgPacket* response) {
    const char* recid = request->get_String();
    uint32_t uid = recid2uid(recid);

    cRecording* recording = RecordingsCache::instance().lookup(uid);

    if(recording == NULL) {
        ERRORLOG("GetMarks: recording not found !");
        response->put_U32(ROBOTV_RET_DATAUNKNOWN);
        return true;
    }

    cMarks marks;

    if(!marks.Load(recording->FileName(), recording->FramesPerSecond(), recording->IsPesRecording())) {
        INFOLOG("no marks found for: '%s'", recording->FileName());
        response->put_U32(ROBOTV_RET_NOTSUPPORTED);
        return true;
    }

    response->put_U32(ROBOTV_RET_OK);
    response->put_U64(recording->FramesPerSecond() * 10000);

    cMark* end = NULL;
    cMark* begin = NULL;

    while((begin = marks.GetNextBegin(end)) != NULL) {
        end = marks.GetNextEnd(begin);

        if(end != NULL) {
            response->put_String("SCENE");
            response->put_U64(begin->Position());
            response->put_U64(end->Position());
            response->put_String(begin->ToText());
        }
    }

    return true;
}
コード例 #23
0
///
/// Constructor
///
Knob::Knob( QWidget* pParent )
 : QWidget( pParent )
 , Object( __class_name )
{
	setAttribute(Qt::WA_NoBackground);

	m_nWidgetWidth = 18;
	m_nWidgetHeight = 18;
	m_fValue = 0.0;
	m_fMousePressValue = 0.0;
	m_fMousePressY = 0.0;

	if ( m_background == NULL ) {
		QString sBackground_path = Skin::getImagePath() + "/mixerPanel/knob_images.png";
		m_background = new QPixmap();
		if ( m_background->load( sBackground_path ) == false ){
			ERRORLOG( "Error loading pixmap" );
		}
	}

	resize( m_nWidgetWidth, m_nWidgetHeight );
}
コード例 #24
0
ファイル: dungeon_data.c プロジェクト: dsserega/keeperfx
TbBool mark_creature_joined_dungeon(struct Thing *creatng)
{
    if (creatng->owner == game.neutral_player_num) {
        // Neutral player has no dungeon
        return false;
    }
    struct Dungeon *dungeon;
    dungeon = get_dungeon(creatng->owner);
    if (dungeon_invalid(dungeon)) {
        ERRORLOG("Can't mark; player %d has no dungeon",(int)creatng->owner);
        return false;
    }
    if ((dungeon->owned_creatures_of_model[creatng->model] <= 1) && (dungeon->creature_models_joined[creatng->model] <= 0))
    {
        event_create_event(creatng->mappos.x.val, creatng->mappos.y.val, EvKind_NewCreature, creatng->owner, creatng->index);
    }
    if (dungeon->creature_models_joined[creatng->model] < 255)
    {
        dungeon->creature_models_joined[creatng->model]++;
    }
    return true;
}
コード例 #25
0
ファイル: livequeue.c プロジェクト: giga91/vdr-plugin-xvdr
bool cLiveQueue::Add(MsgPacket* p)
{
  cMutexLock lock(&m_lock);

  // in timeshift mode ?
  if(m_pause || (!m_pause && m_writefd != -1))
  {
    // write packet
    if(!p->write(m_writefd, 1000))
    {
      ERRORLOG("Unable to write packet into timeshift ringbuffer !");
      delete p;
      return false;
    }

    // ring-buffer overrun ?
    off_t length = lseek(m_writefd, 0, SEEK_CUR);
    if(length >= (off_t)BufferSize)
    {
      // truncate to current position
      if(ftruncate(m_writefd, length) == 0)
        lseek(m_writefd, 0, SEEK_SET);
    }
    delete p;
    return true;
  }

  // queue too long ?
  if (size() > 100) {
    delete p;
    return false;
  }

  // add packet to queue
  push(p);
  m_cond.Signal();

  return true;
}
コード例 #26
0
ファイル: videobuffer.c プロジェクト: Alloyed/xbmc-pvr-addons
bool cVideoBufferTest::Init()
{
  m_ReadCache = 0;
  m_ReadCacheMaxSize = 8000;

  m_ReadCache = (uint8_t*)malloc(m_ReadCacheMaxSize);
  if (!m_ReadCache)
    return false;

  m_Fd = open(m_Filename, O_RDONLY);
  if (m_Fd == -1)
  {
    ERRORLOG("Could not open file: %s", (const char*)m_Filename);
    return false;
  }

  m_WritePtr = 0;
  m_ReadPtr = 0;
  m_ReadCacheSize = 0;
  m_InputAttached = false;
  return true;
}
コード例 #27
0
TbBool attempt_job_work_in_room_and_cure_near_pos(struct Thing *creatng, MapSubtlCoord stl_x, MapSubtlCoord stl_y, CreatureJob new_job)
{
    struct CreatureControl *cctrl;
    cctrl = creature_control_get_from_thing(creatng);
    SYNCDBG(16,"Starting for %s (owner %d) and job %s",thing_model_name(creatng),(int)creatng->owner,creature_job_code_name(new_job));
    struct Room *room;
    room = subtile_room_get(stl_x, stl_y);
    if (get_arrive_at_state_for_job(new_job) == CrSt_Unused) {
        ERRORLOG("No arrive at state for job %s in %s room",creature_job_code_name(new_job),room_code_name(room->kind));
        return false;
    }
    struct Coord3d pos;
    if (!find_first_valid_position_for_thing_in_room(creatng, room, &pos)) {
        return false;
    }
    if (!setup_person_move_to_position(creatng, pos.x.stl.num, pos.y.stl.num, NavRtF_Default)) {
        return false;
    }
    creatng->continue_state = get_arrive_at_state_for_job(new_job);
    cctrl->target_room_id = room->index;
    process_temple_cure(creatng);
    return true;
}
コード例 #28
0
short good_returns_to_start(struct Thing *thing)
{
    struct Thing *heartng;
    // Debug code to find incorrect states
    SYNCDBG(7,"Starting");
    if (!is_hero_thing(thing))
    {
        ERRORLOG("Non hero thing %ld, %s, owner %ld - reset",(long)thing->index,thing_model_name(thing),(long)thing->owner);
        set_start_state(thing);
        erstat_inc(ESE_BadCreatrState);
        return 0;
    }
    //return _DK_good_returns_to_start(thing);
    heartng = get_player_soul_container(thing->owner);
    TRACE_THING(heartng);
    //TODO CREATURE_AI Heroes don't usually have hearts; maybe they should also go back to hero gates, or any room?
    if (!setup_person_move_to_coord(thing, &heartng->mappos, NavRtF_Default))
    {
        return 0;
    }
    thing->continue_state = CrSt_GoodBackAtStart;
    return 1;
}
コード例 #29
0
ファイル: coreaudio_driver.cpp プロジェクト: AdamFf/hydrogen
void CoreAudioDriver::retrieveDefaultDevice(void)
{
	UInt32 dataSize = 0;
	OSStatus err = 0;

	AudioObjectPropertyAddress propertyAddress = {
		kAudioHardwarePropertyDefaultOutputDevice,
		kAudioObjectPropertyScopeGlobal,
		kAudioObjectPropertyElementMaster
	};

	dataSize = sizeof(AudioDeviceID);
	err = AudioObjectGetPropertyData(kAudioObjectSystemObject,
											&propertyAddress,
											0,
											NULL,
											&dataSize,
											&m_outputDevice);

	if ( err != noErr ) {
		ERRORLOG( "Could not get Default Output Device" );
	}
}
コード例 #30
0
void cRecordingsCache::SaveResumeData()
{
  cMutexLock lock(&m_mutex);

  cString filename = AddDirectory(XVDRServerConfig.ConfigDirectory, RESUME_DATA_FILE);
  FILE* f = fopen((const char*)filename, "w");

  if(f == NULL)
  {
    ERRORLOG("unable to create resume data: %s", (const char*)filename);
    return;
  }

  std::map<uint32_t, struct RecEntry>::iterator i;
  for(i = m_recordings.begin(); i != m_recordings.end(); i++)
  {
    if(i->second.lastplayedposition != 0 || i->second.playcount != 0)
      fprintf(f, "%08x = %"PRIu64", %i\n", i->first, i->second.lastplayedposition, i->second.playcount);
  }

  fclose(f);
  return;
}