Example #1
0
void frontnet_join_game_maintain(struct GuiButton *gbtn)
{
    if (net_service_index_selected == 1)
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, ( net_session_index_active != -1 && net_config_info.str_join[0] ));
    }
    else
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_session_index_active != -1));
    }
}
Example #2
0
/**
 * Makes a bonus level for current SP level visible on the land map screen.
 */
TbBool activate_bonus_level(struct PlayerInfo *player)
{
  TbBool result;
  LevelNumber sp_lvnum;
  SYNCDBG(5,"Starting");
  set_flag_byte(&game.flags_font,FFlg_unk02,true);
  sp_lvnum = get_loaded_level_number();
  result = set_bonus_level_visibility_for_singleplayer_level(player, sp_lvnum, true);
  if (!result)
    ERRORLOG("No Bonus level assigned to level %d",(int)sp_lvnum);
  set_flag_byte(&game.operation_flags,GOF_SingleLevel,false);
  return result;
}
Example #3
0
void set_thing_draw(struct Thing *thing, long anim, long speed, long scale, char a5, char start_frame, unsigned char draw_class)
{
    unsigned long i;
    thing->anim_sprite = convert_td_iso(anim);
    thing->field_50 &= 0x03;
    thing->field_50 |= (draw_class << 2);
    thing->field_49 = keepersprite_frames(thing->anim_sprite);
    if (speed != -1) {
        thing->field_3E = speed;
    }
    if (scale != -1) {
        thing->sprite_size = scale;
    }
    if (a5 != -1) {
        set_flag_byte(&thing->field_4F, TF4F_Unknown40, a5);
    }
    if (start_frame == -2)
    {
        i = keepersprite_frames(thing->anim_sprite) - 1;
        thing->field_48 = i;
        thing->field_40 = i << 8;
    } else if (start_frame == -1)
    {
        i = ACTION_RANDOM(thing->field_49);
        thing->field_48 = i;
        thing->field_40 = i << 8;
    } else
    {
        i = start_frame;
        thing->field_48 = i;
        thing->field_40 = i << 8;
    }
}
Example #4
0
void frontnet_maintain_alliance(struct GuiButton *gbtn)
{
    long plyr_idx1, plyr_idx2;
    plyr_idx1 = gbtn->btype_value;
    plyr_idx2 = (long)gbtn->content - 74;

    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, ( plyr_idx2 >= net_number_of_enum_players || net_number_of_enum_players <= plyr_idx1 || plyr_idx2 == plyr_idx1 ));
}
Example #5
0
short setup_network_service(int srvidx)
{
  struct ServiceInitData *init_data;
  long maxplayrs;

  switch (srvidx)
  {
  case 0:
      maxplayrs = 2;
      init_data = &net_serial_data;
      set_flag_byte(&game.flags_font,FFlg_unk10,true);
      SYNCMSG("Initializing %d-players serial network",maxplayrs);
      break;
  case 1:
      maxplayrs = 2;
      init_data = &net_modem_data;
      set_flag_byte(&game.flags_font,FFlg_unk10,true);
      SYNCMSG("Initializing %d-players modem network",maxplayrs);
      break;
  case 2:
      maxplayrs = 4;
      init_data = NULL;
      set_flag_byte(&game.flags_font,FFlg_unk10,false);
      SYNCMSG("Initializing %d-players IPX network",maxplayrs);
      break;
  default:
      maxplayrs = 4;
      init_data = NULL;
      set_flag_byte(&game.flags_font,FFlg_unk10,false);
      SYNCMSG("Initializing %d-players type %d network",maxplayrs,srvidx);
      break;
  }
  LbMemorySet(&net_player_info[0], 0, sizeof(struct TbNetworkPlayerInfo));
  if ( LbNetwork_Init(srvidx, maxplayrs, &net_screen_packet,
      sizeof(struct ScreenPacket), &net_player_info[0], init_data) )
  {
    if (srvidx != 0)
      process_network_error(-800);
    return 0;
  }
  net_service_index_selected = srvidx;
  if ((game.flags_font & FFlg_unk10) != 0)
    LbNetwork_ChangeExchangeTimeout(10);
  frontend_set_state(FeSt_NET_SESSION);
  return 1;
}
Example #6
0
void maintain_resurrect_creature_select(struct GuiButton *gbtn)
{
    struct Dungeon *dungeon;
    dungeon = get_my_dungeon();
    long listitm_idx;
    listitm_idx = resurrect_creature_scroll_offset + gbtn->btype_value;
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (listitm_idx < dungeon->dead_creatures_count));
}
Example #7
0
void maintain_transfer_creature_select(struct GuiButton *gbtn)
{
    struct Dungeon *dungeon;
    dungeon = get_my_dungeon();
    long listitm_idx;
    listitm_idx = transfer_creature_scroll_offset + gbtn->btype_value;

    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled,  (listitm_idx < dungeon->num_active_creatrs));
}
Example #8
0
TbBool movie_record_start(void)
{
    if ( anim_record() )
    {
        set_flag_byte(&game.system_flags,GSF_CaptureMovie,true);
        return true;
    }
    return false;
}
Example #9
0
void gui_load_game_maintain(struct GuiButton *gbtn)
{
  long slot_num;
  struct CatalogueEntry *centry;
  if (gbtn != NULL)
      slot_num = gbtn->field_1B;
  else
      slot_num = 0;
  centry = &save_game_catalogue[slot_num];
  set_flag_byte(&gbtn->flags, LbBtnF_Unknown08, ((centry->flags & CEF_InUse) != 0));
}
Example #10
0
TbBool set_creature_tendencies(struct PlayerInfo *player, unsigned short tend_type, TbBool val)
{
    struct Dungeon *dungeon;
    dungeon = get_dungeon(player->id_number);
    if (dungeon_invalid(dungeon)) {
        ERRORLOG("Can't set tendency; player %d has no dungeon.",(int)player->id_number);
        return false;
    }
    switch (tend_type)
    {
    case CrTend_Imprison:
        set_flag_byte(&dungeon->creature_tendencies, 0x01, val);
        return true;
    case CrTend_Flee:
        set_flag_byte(&dungeon->creature_tendencies, 0x02, val);
        return true;
    default:
        ERRORLOG("Can't set tendency; bad tendency type %d",(int)tend_type);
        return false;
    }
}
Example #11
0
void maintain_transfer_creature_scroll(struct GuiButton *gbtn)
{
    struct Dungeon *dungeon;
    dungeon = get_my_dungeon();
    int count;
    count = dungeon->num_active_creatrs;
    if (transfer_creature_scroll_offset > count-transfer_creature_items_visible+1)
    {
        if (count > transfer_creature_items_visible) {
            transfer_creature_scroll_offset = count-transfer_creature_items_visible+1;
        } else {
            transfer_creature_scroll_offset = 0;
        }
    }
    if (gbtn->btype_value == 1)
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (transfer_creature_scroll_offset > 0));
    }
    else
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (transfer_creature_scroll_offset < count-transfer_creature_items_visible+1));
    }
}
Example #12
0
void maintain_resurrect_creature_scroll(struct GuiButton *gbtn)
{
    struct Dungeon *dungeon;
    dungeon = get_my_dungeon();
    int count;
    count = dungeon->dead_creatures_count;
    if (resurrect_creature_scroll_offset >= count-resurrect_creature_items_visible+1)
    {
        if (count+1 > resurrect_creature_items_visible) {
            resurrect_creature_scroll_offset = count-resurrect_creature_items_visible+1;
        } else {
            resurrect_creature_scroll_offset = 0;
        }
    }
    if (gbtn->btype_value == 1)
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (resurrect_creature_scroll_offset > 0));
    }
    else
    {
        set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (resurrect_creature_scroll_offset < count-resurrect_creature_items_visible+1));
    }
}
Example #13
0
/**
 * Makes the bonus level visible on the land map screen.
 */
TbBool set_bonus_level_visibility(LevelNumber bn_lvnum, TbBool visible)
{
  int i,n,k;
  i = storage_index_for_bonus_level(bn_lvnum);
  if (i < 0)
  {
      WARNLOG("Can't set state of non-existing bonus level %d.",(int)bn_lvnum);
      return false;
  }
  n = i/8;
  k = (1 << (i%8));
  if ((n < 0) || (n >= BONUS_LEVEL_STORAGE_COUNT))
  {
    WARNLOG("Bonus level %d has invalid store position.",(int)bn_lvnum);
    return false;
  }
  set_flag_byte(&intralvl.bonuses_found[n], k, visible);
  return true;
}
Example #14
0
long light_create_light(struct InitLight *ilght)
{
    struct Light *lgt;
    struct ShadowCache *shdc;
    unsigned long k;
    lgt = light_allocate_light();
    if (light_is_invalid(lgt)) {
        return 0;
    }
    if (ilght->is_dynamic)
    {
        shdc = light_allocate_shadow_cache();
        if (light_shadow_cache_invalid(shdc))
        {
            ERRORDBG(11,"Cannot allocate cache for dynamic light");
            light_free_light(lgt);
            return 0;
        }
        light_total_dynamic_lights++;
        lgt->shadow_index = light_shadow_cache_index(shdc);
        light_add_light_to_list(lgt, &game.thing_lists[TngList_DynamLights]);
    } else
    {
        light_total_stat_lights++;
        light_add_light_to_list(lgt, &game.thing_lists[TngList_StaticLights]);
        stat_light_needs_updating = 1;
    }
    lgt->flags |= LgtF_Unkn02;
    lgt->flags |= LgtF_Unkn08;
    lgt->mappos.x.val = ilght->mappos.x.val;
    lgt->mappos.y.val = ilght->mappos.y.val;
    lgt->mappos.z.val = ilght->mappos.z.val;
    lgt->field_16 = ilght->field_0;
    lgt->field_2 = ilght->field_2;
    k = 2 * ilght->field_3;
    lgt->field_1 = k ^ ((k ^ lgt->field_1) & 0x01);
    set_flag_byte(&lgt->flags,LgtF_Dynamic,ilght->is_dynamic);
    lgt->field_1A = ilght->field_8;
    lgt->field_18 = ilght->field_4;
    lgt->field_12 = ilght->field_12;
    return lgt->index;
}
Example #15
0
/**
 * Captures the screen to make a gameplay movie or screenshot image.
 * @return Returns 0 if no capturing was performed, nonzero otherwise.
 */
TbBool perform_any_screen_capturing(void)
{
    TbBool captured=0;
    if ((game.system_flags & GSF_CaptureSShot) != 0)
    {
        captured |= cumulative_screen_shot();
        set_flag_byte(&game.system_flags,GSF_CaptureSShot,false);
    }
    if ((game.system_flags & GSF_CaptureMovie) != 0)
    {
        captured |= movie_record_frame();
    }
    // Draw a text with bitmap font
    if (captured) {
        //Set font; if winfont isn't loaded, it should be NULL, so text will just be invisible
        LbTextSetFont(winfont);
        LbTextDraw(600*units_per_pixel/16, 4*units_per_pixel/16, "REC");
    }
    return captured;
}
Example #16
0
void frontend_load_game_up_maintain(struct GuiButton *gbtn)
{
  set_flag_byte(&gbtn->flags, LbBtnF_Unknown08, (load_game_scroll_offset != 0));
}
Example #17
0
void frontnet_session_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled,  (net_session_scroll_offset + (long)gbtn->content - 45 < net_number_of_sessions));
}
Example #18
0
TbBool load_game(long slot_num)
{
    TbFileHandle fh;
    long file_len;
    struct PlayerInfo *player;
    struct Dungeon *dungeon;
    struct CatalogueEntry *centry;
//  unsigned char buf[14];
//  char cmpgn_fname[CAMPAIGN_FNAME_LEN];
    SYNCDBG(6,"Starting");
    reset_eye_lenses();
    {
        // Use fname only here - it is overwritten by next use of prepare_file_fmtpath()
        char *fname;
        fname = prepare_file_fmtpath(FGrp_Save,saved_game_filename,slot_num);
        if (!wait_for_cd_to_be_available())
          return false;
        fh = LbFileOpen(fname,Lb_FILE_MODE_READ_ONLY);
        if (fh == -1)
        {
          WARNMSG("Cannot open saved game file \"%s\".",fname);
          save_catalogue_slot_disable(slot_num);
          return false;
        }
    }
    file_len = LbFileLengthHandle(fh);
    if (is_primitive_save_version(file_len))
    {
        //if (LbFileRead(handle, buf, sizeof(buf)) != sizeof(buf))
        {
          LbFileClose(fh);
          save_catalogue_slot_disable(slot_num);
          return false;
        }
        /*LbFileSeek(fh, (char *)&game.campaign_fname[0] - (char *)&game, Lb_FILE_SEEK_BEGINNING);
        LbFileRead(fh, cmpgn_fname, CAMPAIGN_FNAME_LEN);
        cmpgn_fname[CAMPAIGN_FNAME_LEN-1] = '\0';
        if (!change_campaign(cmpgn_fname))
        {
          ERRORLOG("Unable to load campaign associated with saved game");
        }
        LbFileClose(fh);
        WARNMSG("Saved game file \"%s\" has incompatible version; restarting level.",fname);
        player = get_my_player();
        player->field_7 = 0;
        my_player_number = default_loc_player;
        player = get_my_player();
        game.flagfield_14EA4A = 2;
        set_flag_byte(&game.system_flags,GSF_NetworkActive,false);
        player->field_2C = 1;
        set_selected_level_number(((struct Game *)buf)->load_restart_level);
        set_continue_level_number(((struct Game *)buf)->continue_level_number);
        startup_network_game();
        return true;*/
    }
    centry = &save_game_catalogue[slot_num];
    LbFileSeek(fh, 0, Lb_FILE_SEEK_BEGINNING);
    // Here is the actual loading
    if (load_game_chunks(fh,centry) != GLoad_SavedGame)
    {
        LbFileClose(fh);
        WARNMSG("Couldn't correctly load saved game in slot %d.",(int)slot_num);
        init_lookups();
        return false;
    }
    LbFileClose(fh);
    LbStringCopy(game.campaign_fname,campaign.fname,sizeof(game.campaign_fname));
    reinit_level_after_load();
    output_message(SMsg_GameLoaded, 0, true);
    pannel_map_update(0, 0, map_subtiles_x+1, map_subtiles_y+1);
    calculate_moon_phase(false,false);
    update_extra_levels_visibility();
    player = get_my_player();
    set_flag_byte(&player->field_3,0x08,false);
    set_flag_byte(&player->field_3,0x04,false);
    player->field_4C1 = 0;
    player->field_4C5 = 0;
    player->field_7 = 0;
    PaletteSetPlayerPalette(player, engine_palette);
    reinitialise_eye_lens(game.numfield_1B);
    // Update the lights system state
    light_import_system_state(&gameadd.lightst);
    // Victory state
    if (player->victory_state != VicS_Undecided)
    {
      frontstats_initialise();
      dungeon = get_players_dungeon(player);
      dungeon->lvstats.player_score = 0;
      dungeon->lvstats.allow_save_score = 1;
    }
    game.loaded_swipe_idx = -1;
    return true;
}
Example #19
0
void frontnet_speed_select(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_speed_scroll_offset + (long)gbtn->content - 47 < number_of_speeds));
}
Example #20
0
void frontnet_players_down_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_number_of_enum_players - 1 > net_player_scroll_offset));
}
Example #21
0
void frontnet_start_game_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_number_of_enum_players > 1));
}
Example #22
0
void frontnet_comport_select_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_comport_scroll_offset + (long)gbtn->content - 45 < number_of_comports));
}
Example #23
0
void frontnet_net_serial_start_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, ((net_comport_index_active == -1) || (net_speed_index_active == -1)));
}
Example #24
0
void frontnet_session_down_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_number_of_sessions - 1 > net_session_scroll_offset));
}
Example #25
0
void frontend_load_game_down_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnF_Unknown08, (load_game_scroll_offset < number_of_saved_games-frontend_load_menu_items_visible+1));
}
Example #26
0
TbBool movie_record_stop(void)
{
    set_flag_byte(&game.system_flags,GSF_CaptureMovie,false);
    anim_stop();
    return true;
}
Example #27
0
void frontnet_session_up_maintain(struct GuiButton *gbtn)
{
    set_flag_byte(&gbtn->flags, LbBtnFlag_Enabled, (net_session_scroll_offset != 0));
}