Пример #1
0
void lightning_modify_palette(struct Thing *thing)
{
    struct PlayerInfo *myplyr;
    // _DK_lightning_modify_palette(thing);
    myplyr = get_my_player();

    if (thing->health == 0)
    {
      PaletteSetPlayerPalette(myplyr, engine_palette);
      myplyr->field_3 &= ~0x08;
      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 & 0x08) != 0)
        {
            if (get_2d_box_distance(&myplyr->acamera->mappos, &thing->mappos) < 11520)
            {
                PaletteSetPlayerPalette(myplyr, engine_palette);
                myplyr->field_3 &= ~0x08;
            }
        }
        return;
    }
    if ((myplyr->view_mode != PVM_ParchFadeIn) && (myplyr->view_mode != PVM_ParchFadeOut) && (myplyr->view_mode != PVM_ParchmentView))
    {
        if ((myplyr->field_3 & 0x08) == 0)
        {
            if (get_2d_box_distance(&myplyr->acamera->mappos, &thing->mappos) < 11520)
            {
              PaletteSetPlayerPalette(myplyr, lightning_palette);
              myplyr->field_3 |= 0x08;
            }
        }
    }
}
Пример #2
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;
}