summaryrefslogtreecommitdiff
path: root/3dc/win95/GSPRCHNK.CPP
diff options
context:
space:
mode:
authorRebellion Developments <rebellion@nomail>2000-03-16 11:25:00 +0100
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-19 05:45:17 +0200
commit218ca90543758a20ac326e444ca0643174ca7384 (patch)
tree16bfe3e5307f9f515489000f28728224291a0e3b /3dc/win95/GSPRCHNK.CPP
Import Aliens vs Predator - Gold (Build 116)
Source code release, imported from: https://www.gamefront.com/games/aliens-vs-predator-3/file/avp-gold-complete-source-code All text files were converted to Unix format.
Diffstat (limited to '3dc/win95/GSPRCHNK.CPP')
-rw-r--r--3dc/win95/GSPRCHNK.CPP130
1 files changed, 130 insertions, 0 deletions
diff --git a/3dc/win95/GSPRCHNK.CPP b/3dc/win95/GSPRCHNK.CPP
new file mode 100644
index 0000000..b20293f
--- /dev/null
+++ b/3dc/win95/GSPRCHNK.CPP
@@ -0,0 +1,130 @@
+#include "gsprchnk.hpp"
+
+#ifdef cencon
+#define new my_new
+#endif
+
+//macro for helping to force inclusion of chunks when using libraries
+FORCE_CHUNK_INCLUDE_IMPLEMENT(gsprchnk)
+
+// Class AllSprites_Chunk functions
+
+RIF_IMPLEMENT_DYNCREATE("RSPRITES",AllSprites_Chunk)
+// constructor from buffer
+LOCKABLE_CHUNK_WITH_CHILDREN_LOADER("RSPRITES",AllSprites_Chunk)
+
+/*
+Children for AllSprites_Chunk :
+
+"ASPRHEAD" AllSprites_Header_Chunk
+"SPRIHEAD" Sprite_Header_Chunk
+*/
+
+
+
+// empty constructor
+AllSprites_Chunk::AllSprites_Chunk (Chunk_With_Children * parent)
+:Lockable_Chunk_With_Children (parent, "RSPRITES")
+{
+ // as necessary, generated automatically
+ new AllSprites_Header_Chunk (this);
+}
+
+
+BOOL AllSprites_Chunk::file_equals (HANDLE & /*rif_file*/)
+{
+ return(TRUE);
+}
+
+AllSprites_Header_Chunk * AllSprites_Chunk::get_header()
+{
+ return (AllSprites_Header_Chunk *) this->lookup_single_child ("ASPRHEAD");
+}
+
+const char * AllSprites_Chunk::get_head_id()
+{
+ AllSprites_Header_Chunk * hdptr = get_header();
+
+ if (!hdptr) return (0);
+
+ return(hdptr->identifier);
+
+}
+
+void AllSprites_Chunk::set_lock_user (char * user)
+{
+ AllSprites_Header_Chunk * hdptr = get_header();
+
+ if (!hdptr) return;
+
+ strncpy (hdptr->lock_user, user,16);
+
+ hdptr->lock_user[16] = 0;
+}
+
+void AllSprites_Chunk::post_input_processing()
+{
+ if (get_header())
+ if (get_header()->flags & GENERAL_FLAG_LOCKED)
+ external_lock = TRUE;
+
+ Chunk_With_Children::post_input_processing();
+
+}
+
+///////////////////////////////////////
+
+// Class AllSprites_Header_Chunk functions
+RIF_IMPLEMENT_DYNCREATE("ASPRHEAD",AllSprites_Header_Chunk)
+
+// from buffer
+AllSprites_Header_Chunk::AllSprites_Header_Chunk (Chunk_With_Children * parent, const char * hdata, size_t /*hsize*/)
+ : Chunk (parent, "ASPRHEAD"),
+ flags (0), version_no (0)
+{
+ flags = *((int *) hdata);
+
+ strncpy (lock_user, (hdata + 4), 16);
+ lock_user[16] = '\0';
+
+ version_no = *((int *) (hdata + 20));
+}
+
+BOOL AllSprites_Header_Chunk::output_chunk (HANDLE & hand)
+{
+ unsigned long junk;
+ BOOL ok;
+ char * data_block;
+
+ data_block = make_data_block_from_chunk();
+
+ ok = WriteFile (hand, (long *) data_block, (unsigned long) chunk_size, &junk, 0);
+
+ delete [] data_block;
+
+ if (!ok) return FALSE;
+
+ return TRUE;
+}
+
+void AllSprites_Header_Chunk::fill_data_block ( char * data_start)
+{
+ strncpy (data_start, identifier, 8);
+
+ data_start += 8;
+
+ *((int *) data_start) = chunk_size;
+
+ data_start += 4;
+
+ *((int *) data_start) = flags;
+ strncpy ((data_start + 4), lock_user, 16);
+
+ *((int *) (data_start+20)) = version_no;
+}
+
+void AllSprites_Header_Chunk::prepare_for_output()
+{
+ version_no ++;
+}
+