move hoard data saving from main to save_hoard_data
authorChris Taylor <chris@icculus.org>
Thu, 27 Jul 2006 10:07:31 +0000 (10:07 +0000)
committerChris Taylor <chris@icculus.org>
Thu, 27 Jul 2006 10:07:31 +0000 (10:07 +0000)
ChangeLog
main/inferno.c
main/multi.c
main/multi.h

index 2521935..a706d0b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-27  Chris Taylor  <chris@icculus.org>
+
+       * main/inferno.c, main/multi.c, main/multi.h:
+       move hoard data saving from main to save_hoard_data
+
 2006-07-24  Chris Taylor  <chris@icculus.org>
 
        * main/state.c: make the thumbnail properly when doing fast save
index 5f6a007..e68aaa9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: inferno.c,v 1.106 2006-03-05 11:10:27 chris Exp $ */
+/* $Id: inferno.c,v 1.107 2006-07-27 10:07:31 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -68,7 +68,6 @@ char copyright[] = "DESCENT II  COPYRIGHT (C) 1994-1996 PARALLAX SOFTWARE CORPOR
 #include "polyobj.h"
 #include "effects.h"
 #include "digi.h"
-#include "iff.h"
 #include "pcx.h"
 #include "palette.h"
 #include "args.h"
@@ -947,65 +946,9 @@ int main(int argc, char *argv[])
                bm_init();
 
        #ifdef EDITOR
-       if (FindArg("-hoarddata") != 0) {
-               #define MAX_BITMAPS_PER_BRUSH 30
-               grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
-               grs_bitmap icon;
-               int nframes;
-               ubyte palette[256*3];
-               PHYSFS_file *ofile;
-               int iff_error,i;
-               char *sounds[] = {"selforb.raw","selforb.r22",          //SOUND_YOU_GOT_ORB                     
-                                                               "teamorb.raw","teamorb.r22",            //SOUND_FRIEND_GOT_ORB                  
-                                                               "enemyorb.raw","enemyorb.r22",  //SOUND_OPPONENT_GOT_ORB        
-                                                               "OPSCORE1.raw","OPSCORE1.r22"}; //SOUND_OPPONENT_HAS_SCORED
-
-               ofile = PHYSFSX_openWriteBuffered("hoard.ham");
-
-          iff_error = iff_read_animbrush("orb.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
-               Assert(iff_error == IFF_NO_ERROR);
-               PHYSFS_writeULE16(ofile, nframes);
-               PHYSFS_writeULE16(ofile, bm[0]->bm_w);
-               PHYSFS_writeULE16(ofile, bm[0]->bm_h);
-               PHYSFS_write(ofile, palette, 3, 256);
-               for (i=0;i<nframes;i++)
-                       PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
-
-               iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
-               Assert(iff_error == IFF_NO_ERROR);
-               Assert(bm[0]->bm_w == 64 && bm[0]->bm_h == 64);
-               PHYSFS_writeULE16(ofile, nframes);
-               PHYSFS_write(ofile, palette, 3, 256);
-               for (i=0;i<nframes;i++)
-                       PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
-
-               for (i=0;i<2;i++) {
-                       iff_error = iff_read_bitmap(i?"orbb.bbm":"orb.bbm",&icon,BM_LINEAR,palette);
-                       Assert(iff_error == IFF_NO_ERROR);
-                       PHYSFS_writeULE16(ofile, icon.bm_w);
-                       PHYSFS_writeULE16(ofile, icon.bm_h);
-                       PHYSFS_write(ofile, palette, 3, 256);
-                       PHYSFS_write(ofile, icon.bm_data, icon.bm_w*icon.bm_h, 1);
-               }
-
-               for (i=0;i<sizeof(sounds)/sizeof(*sounds);i++) {
-                       PHYSFS_file *ifile;
-                       int size;
-                       ubyte *buf;
-
-                       ifile = PHYSFS_openRead(sounds[i]);
-                       Assert(ifile != NULL);
-                       size = PHYSFS_fileLength(ifile);
-                       buf = d_malloc(size);
-                       PHYSFS_read(ifile, buf, size, 1);
-                       PHYSFS_writeULE32(ofile, size);
-                       PHYSFS_write(ofile, buf, size, 1);
-                       d_free(buf);
-                       PHYSFS_close(ifile);
-               }
-
-               PHYSFS_close(ofile);
-
+       if (FindArg("-hoarddata") != 0)
+       {
+               save_hoard_data();
                exit(1);
        }
        #endif
index a7c68d8..62b5708 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: multi.c,v 1.18 2004-12-17 13:17:46 btb Exp $ */
+/* $Id: multi.c,v 1.19 2006-07-27 10:07:31 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -72,6 +72,7 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
 #include "args.h"
 #include "cfile.h"
 #include "effects.h"
+#include "iff.h"
 
 void multi_reset_player_object(object *objp);
 void multi_reset_object_texture(object *objp);
@@ -5233,6 +5234,70 @@ void init_hoard_data()
        first_time = 0;
 }
 
+#ifdef EDITOR
+void save_hoard_data(void)
+{
+#define MAX_BITMAPS_PER_BRUSH 30
+       grs_bitmap * bm[MAX_BITMAPS_PER_BRUSH];
+       grs_bitmap icon;
+       int nframes;
+       ubyte palette[256*3];
+       PHYSFS_file *ofile;
+       int iff_error,i;
+       char *sounds[] = {"selforb.raw","selforb.r22",          //SOUND_YOU_GOT_ORB                     
+                                                               "teamorb.raw","teamorb.r22",            //SOUND_FRIEND_GOT_ORB                  
+                                                               "enemyorb.raw","enemyorb.r22",  //SOUND_OPPONENT_GOT_ORB        
+                                                               "OPSCORE1.raw","OPSCORE1.r22"}; //SOUND_OPPONENT_HAS_SCORED
+
+       ofile = PHYSFSX_openWriteBuffered("hoard.ham");
+
+       iff_error = iff_read_animbrush("orb.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
+       Assert(iff_error == IFF_NO_ERROR);
+       PHYSFS_writeULE16(ofile, nframes);
+       PHYSFS_writeULE16(ofile, bm[0]->bm_w);
+       PHYSFS_writeULE16(ofile, bm[0]->bm_h);
+       PHYSFS_write(ofile, palette, 3, 256);
+       for (i=0;i<nframes;i++)
+               PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
+
+       iff_error = iff_read_animbrush("orbgoal.abm",bm,MAX_BITMAPS_PER_BRUSH,&nframes,palette);
+       Assert(iff_error == IFF_NO_ERROR);
+       Assert(bm[0]->bm_w == 64 && bm[0]->bm_h == 64);
+       PHYSFS_writeULE16(ofile, nframes);
+       PHYSFS_write(ofile, palette, 3, 256);
+       for (i=0;i<nframes;i++)
+               PHYSFS_write(ofile, bm[i]->bm_data, bm[i]->bm_w*bm[i]->bm_h, 1);
+
+       for (i=0;i<2;i++)
+       {
+               iff_error = iff_read_bitmap(i?"orbb.bbm":"orb.bbm",&icon,BM_LINEAR,palette);
+               Assert(iff_error == IFF_NO_ERROR);
+               PHYSFS_writeULE16(ofile, icon.bm_w);
+               PHYSFS_writeULE16(ofile, icon.bm_h);
+               PHYSFS_write(ofile, palette, 3, 256);
+               PHYSFS_write(ofile, icon.bm_data, icon.bm_w*icon.bm_h, 1);
+       }
+
+       for (i=0;i<sizeof(sounds)/sizeof(*sounds);i++) {
+               PHYSFS_file *ifile;
+               int size;
+               ubyte *buf;
+
+               ifile = PHYSFS_openRead(sounds[i]);
+               Assert(ifile != NULL);
+               size = PHYSFS_fileLength(ifile);
+               buf = d_malloc(size);
+               PHYSFS_read(ifile, buf, size, 1);
+               PHYSFS_writeULE32(ofile, size);
+               PHYSFS_write(ofile, buf, size, 1);
+               d_free(buf);
+               PHYSFS_close(ifile);
+       }
+
+       PHYSFS_close(ofile);
+}
+#endif
+
 void
 multi_process_data(char *buf, int len)
 {
index 26e8f25..fb2d96c 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: multi.h,v 1.15 2004-10-23 18:59:02 schaffner Exp $ */
+/* $Id: multi.h,v 1.16 2006-07-27 10:07:31 chris Exp $ */
 /*
 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
@@ -417,4 +417,8 @@ void change_playernum_to(int new_pnum);
 #define MISSILE_ADJUST  100
 #define FLARE_ADJUST    127
 
+#ifdef EDITOR
+void save_hoard_data(void);
+#endif
+
 #endif /* _MULTI_H */