Remove unused piggy_dump_all

This commit is contained in:
Kp 2013-10-27 19:53:28 +00:00
parent 313c36d8ee
commit e2a2cc579a
5 changed files with 0 additions and 333 deletions

View file

@ -76,7 +76,6 @@ extern ubyte bogus_data[64 * 64];
int properties_init();
void piggy_close();
void piggy_dump_all();
bitmap_index piggy_register_bitmap( grs_bitmap * bmp, const char * name, int in_file );
int piggy_register_sound( digi_sound * snd, const char * name, int in_file );
bitmap_index piggy_find_bitmap( char * name );

View file

@ -546,10 +546,6 @@ int gamedata_read_tbl(int pc_shareware)
}
#endif
#ifdef EDITOR
// piggy_dump_all(); // causes problems - we're not going to bother
#endif
return 0;
}

View file

@ -665,233 +665,6 @@ void piggy_load_level_data()
paging_touch_all();
}
#ifdef EDITOR
void piggy_dump_all()
{
int i, xlat_offset;
PHYSFS_file * fp;
#ifndef RELEASE
PHYSFS_file * fp1;
PHYSFS_file * fp2;
#endif
const char * filename;
int data_offset;
int org_offset;
DiskBitmapHeader bmh;
DiskSoundHeader sndh;
int header_offset;
char subst_name[32];
#ifdef NO_DUMP_SOUNDS
Num_sound_files = 0;
Num_sound_files_new = 0;
#endif
// {
// bitmap_index bi;
// bi.index = 614;
// PIGGY_PAGE_IN( bi );
// count_colors( bi.index, &GameBitmaps[bi.index] );
// key_getch();
// }
// {
// bitmap_index bi;
// bi.index = 478;
// PIGGY_PAGE_IN( bi );
// Int3();
// count_colors( bi.index, &GameBitmaps[bi.index] );
// key_getch();
// }
// {
// bitmap_index bi;
// bi.index = 1398;
// PIGGY_PAGE_IN( bi );
// count_colors( bi.index, &GameBitmaps[bi.index] );
// key_getch();
// }
// {
// bitmap_index bi;
// bi.index = 642;
// PIGGY_PAGE_IN( bi );
// count_colors( bi.index, &GameBitmaps[bi.index] );
// key_getch();
// }
// {
// bitmap_index bi;
// bi.index = 529;
// PIGGY_PAGE_IN( bi );
// count_colors( bi.index, &GameBitmaps[bi.index] );
// key_getch();
// }
// exit(0);
//
if ((Num_bitmap_files_new == 0) && (Num_sound_files_new == 0) )
return;
for (i=0; i < Num_bitmap_files; i++ ) {
bitmap_index bi;
bi.index = i;
PIGGY_PAGE_IN( bi );
}
piggy_close_file();
filename = SHAREPATH "descent.pig";
fp = PHYSFSX_openWriteBuffered( filename );
Assert( fp!=NULL );
#ifndef RELEASE
fp1 = PHYSFSX_openWriteBuffered( "piggy.lst" );
fp2 = PHYSFSX_openWriteBuffered( "piggy.all" );
#endif
i = 0;
PHYSFS_write( fp, &i, sizeof(int), 1 );
bm_write_all(fp);
xlat_offset = PHYSFS_tell(fp);
PHYSFS_write( fp, GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1 );
i = PHYSFS_tell(fp);
PHYSFSX_fseek( fp, 0, SEEK_SET );
PHYSFS_write( fp, &i, sizeof(int), 1 );
PHYSFSX_fseek( fp, i, SEEK_SET );
Num_bitmap_files--;
PHYSFS_write( fp, &Num_bitmap_files, sizeof(int), 1 );
Num_bitmap_files++;
PHYSFS_write( fp, &Num_sound_files, sizeof(int), 1 );
header_offset = PHYSFS_tell(fp);
header_offset += ((Num_bitmap_files-1)*sizeof(DiskBitmapHeader)) + (Num_sound_files*sizeof(DiskSoundHeader));
data_offset = header_offset;
for (i=1; i < Num_bitmap_files; i++ ) {
int *size;
grs_bitmap *bmp;
{
char * p, *p1;
p = strchr(AllBitmaps[i].name,'#');
if (p) {
int n;
p1 = p; p1++;
n = atoi(p1);
*p = 0;
#ifndef RELEASE
if (n==0) {
PHYSFSX_printf( fp2, "%s.abm\n", AllBitmaps[i].name );
}
#endif
memcpy( bmh.name, AllBitmaps[i].name, 8 );
Assert( n <= 63 );
bmh.dflags = DBM_FLAG_ABM + n;
*p = '#';
}else {
#ifndef RELEASE
PHYSFSX_printf( fp2, "%s.bbm\n", AllBitmaps[i].name );
#endif
memcpy( bmh.name, AllBitmaps[i].name, 8 );
bmh.dflags = 0;
}
}
bmp = &GameBitmaps[i];
Assert( !(bmp->bm_flags&BM_FLAG_PAGED_OUT) );
#ifndef RELEASE
PHYSFSX_printf( fp1, "BMP: %s, size %d bytes", AllBitmaps[i].name, bmp->bm_rowsize * bmp->bm_h );
#endif
org_offset = PHYSFS_tell(fp);
bmh.offset = data_offset - header_offset;
PHYSFSX_fseek( fp, data_offset, SEEK_SET );
if ( bmp->bm_flags & BM_FLAG_RLE ) {
size = (int *)bmp->bm_data;
PHYSFS_write( fp, bmp->bm_data, sizeof(ubyte), *size );
data_offset += *size;
//bmh.data_length = *size;
#ifndef RELEASE
PHYSFSX_printf( fp1, ", and is already compressed to %d bytes.\n", *size );
#endif
} else {
PHYSFS_write( fp, bmp->bm_data, sizeof(ubyte), bmp->bm_rowsize * bmp->bm_h );
data_offset += bmp->bm_rowsize * bmp->bm_h;
//bmh.data_length = bmp->bm_rowsize * bmp->bm_h;
#ifndef RELEASE
PHYSFSX_printf( fp1, ".\n" );
#endif
}
PHYSFSX_fseek( fp, org_offset, SEEK_SET );
if ( GameBitmaps[i].bm_w > 255 ) {
Assert( GameBitmaps[i].bm_w < 512 );
bmh.width = GameBitmaps[i].bm_w - 256;
bmh.dflags |= DBM_FLAG_LARGE;
} else {
bmh.width = GameBitmaps[i].bm_w;
}
Assert( GameBitmaps[i].bm_h < 256 );
bmh.height = GameBitmaps[i].bm_h;
bmh.flags = GameBitmaps[i].bm_flags;
if (piggy_is_substitutable_bitmap( AllBitmaps[i].name, subst_name )) {
bitmap_index other_bitmap;
other_bitmap = piggy_find_bitmap( subst_name );
GameBitmapXlat[i] = other_bitmap.index;
bmh.flags |= BM_FLAG_PAGED_OUT;
} else {
bmh.flags &= ~BM_FLAG_PAGED_OUT;
}
bmh.avg_color=GameBitmaps[i].avg_color;
PHYSFS_write( fp, &bmh, sizeof(DiskBitmapHeader), 1 ); // Mark as a bitmap
}
for (i=0; i < Num_sound_files; i++ )
{
digi_sound *snd;
snd = &GameSounds[i];
strcpy( sndh.name, AllSounds[i].name );
#ifdef ALLEGRO
sndh.length = GameSounds[i].len;
#else
sndh.length = GameSounds[i].length;
#endif
sndh.offset = data_offset - header_offset;
org_offset = PHYSFS_tell(fp);
PHYSFSX_fseek( fp, data_offset, SEEK_SET );
sndh.data_length = sndh.length;
PHYSFS_write( fp, snd->data, sizeof(ubyte), sndh.length );
data_offset += sndh.length;
PHYSFSX_fseek( fp, org_offset, SEEK_SET );
PHYSFS_write( fp, &sndh, sizeof(DiskSoundHeader), 1 ); // Mark as a bitmap
#ifndef RELEASE
PHYSFSX_printf( fp1, "SND: %s, size %d bytes\n", AllSounds[i].name, sndh.length );
PHYSFSX_printf( fp2, "%s.raw\n", AllSounds[i].name );
#endif
}
PHYSFSX_fseek( fp, xlat_offset, SEEK_SET );
PHYSFS_write( fp, GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1 );
PHYSFS_close(fp);
#ifndef RELEASE
PHYSFSX_printf( fp1, " Dumped %d assorted bitmaps.\n", Num_bitmap_files );
PHYSFSX_printf( fp1, " Dumped %d assorted sounds.\n", Num_sound_files );
PHYSFS_close(fp1);
PHYSFS_close(fp2);
#endif
// Never allow the game to run after building pig.
exit(0);
}
#endif
void piggy_close()
{
int i;

View file

@ -616,10 +616,6 @@ int gamedata_read_tbl(int pc_shareware)
}
#endif
#ifdef EDITOR
// piggy_dump_all(); // causes problems - we're not going to bother
#endif
gr_use_palette_table(D2_DEFAULT_PALETTE);
return 0;

View file

@ -1232,103 +1232,6 @@ static void write_int(int i, PHYSFS_file *file)
Error( "Error reading int in gamesave.c" );
}
void piggy_dump_all()
{
int i, xlat_offset;
PHYSFS_file * ham_fp;
int org_offset,data_offset=0;
DiskSoundHeader sndh;
int sound_data_start=0;
PHYSFS_file *fp1,*fp2;
#ifdef NO_DUMP_SOUNDS
Num_sound_files = 0;
Num_sound_files_new = 0;
#endif
if (!Must_write_hamfile && (Num_bitmap_files_new == 0) && (Num_sound_files_new == 0) )
return;
fp1 = PHYSFSX_openWriteBuffered( "ham.lst" );
fp2 = PHYSFSX_openWriteBuffered( "ham.all" );
if (Must_write_hamfile || Num_bitmap_files_new) {
ham_fp = PHYSFSX_openWriteBuffered( DEFAULT_HAMFILE_REGISTERED ); //open HAM file
Assert( ham_fp!=NULL );
write_int(HAMFILE_ID,ham_fp);
write_int(HAMFILE_VERSION,ham_fp);
bm_write_all(ham_fp);
xlat_offset = PHYSFS_tell(ham_fp);
PHYSFS_write( ham_fp, GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1 );
//Dump bitmaps
if (Num_bitmap_files_new)
piggy_write_pigfile(DEFAULT_PIGFILE_REGISTERED);
//free up memeory used by new bitmaps
for (i=Num_bitmap_files-Num_bitmap_files_new;i<Num_bitmap_files;i++)
d_free(GameBitmaps[i].bm_data);
//next thing must be done after pig written
PHYSFSX_fseek( ham_fp, xlat_offset, SEEK_SET );
PHYSFS_write( ham_fp, GameBitmapXlat, sizeof(ushort)*MAX_BITMAP_FILES, 1 );
PHYSFS_close(ham_fp);
}
if (Num_sound_files_new) {
// Now dump sound file
ham_fp = PHYSFSX_openWriteBuffered( DEFAULT_SNDFILE );
Assert( ham_fp!=NULL );
write_int(SNDFILE_ID,ham_fp);
write_int(SNDFILE_VERSION,ham_fp);
PHYSFS_write( ham_fp, &Num_sound_files, sizeof(int), 1 );
sound_data_start = PHYSFS_tell(ham_fp);
sound_data_start += Num_sound_files*sizeof(DiskSoundHeader);
data_offset = sound_data_start;
for (i=0; i < Num_sound_files; i++ ) {
digi_sound *snd;
snd = &GameSounds[i];
strcpy( sndh.name, AllSounds[i].name );
sndh.length = GameSounds[i].length;
sndh.offset = data_offset - sound_data_start;
org_offset = PHYSFS_tell(ham_fp);
PHYSFSX_fseek( ham_fp, data_offset, SEEK_SET );
sndh.data_length = GameSounds[i].length;
PHYSFS_write( ham_fp, snd->data, sizeof(ubyte), snd->length );
data_offset += snd->length;
PHYSFSX_fseek( ham_fp, org_offset, SEEK_SET );
PHYSFS_write( ham_fp, &sndh, sizeof(DiskSoundHeader), 1 ); // Mark as a bitmap
PHYSFSX_printf( fp1, "SND: %s, size %d bytes\n", AllSounds[i].name, snd->length );
PHYSFSX_printf( fp2, "%s.raw\n", AllSounds[i].name );
}
PHYSFS_close(ham_fp);
}
PHYSFSX_printf( fp1, "Total sound size: %d bytes\n", data_offset-sound_data_start);
PHYSFSX_printf( fp1, " Dumped %d assorted sounds.\n", Num_sound_files );
PHYSFS_close(fp1);
PHYSFS_close(fp2);
// Never allow the game to run after building ham.
exit(0);
}
#endif
void piggy_close()