Commit 4bf7ef38 authored by hybrid's avatar hybrid

Fix pack and unpack include file to properly work under MSVC as well. Needs to...

Fix pack and unpack include file to properly work under MSVC as well. Needs to suppress warning as we don't have the push and pop together anymore.
Fix push and pop usage - some files forgot to add the define, so effectively not work under gcc with special architectures - and move all files to use the new include files.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4196 dfc29bdd-3216-0410-991c-e03cc46cb475
parent b4f7ef5f
...@@ -75,31 +75,23 @@ namespace scene ...@@ -75,31 +75,23 @@ namespace scene
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
//! this holds the header info of the MD3 file //! this holds the header info of the MD3 file
struct SMD3Header struct SMD3Header
{ {
c8 headerID[4]; //id of file, always "IDP3" c8 headerID[4]; //id of file, always "IDP3"
s32 Version; //this is a version number, always 15 s32 Version; //this is a version number, always 15
s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars s8 fileName[68]; //sometimes left Blank... 65 chars, 32bit aligned == 68 chars
s32 numFrames; //number of KeyFrames s32 numFrames; //number of KeyFrames
s32 numTags; //number of 'tags' per frame s32 numTags; //number of 'tags' per frame
s32 numMeshes; //number of meshes/skins s32 numMeshes; //number of meshes/skins
s32 numMaxSkins; //maximum number of unique skins used in md3 file. artefact md2 s32 numMaxSkins; //maximum number of unique skins used in md3 file. artefact md2
s32 frameStart; //starting position of frame-structur s32 frameStart; //starting position of frame-structur
s32 tagStart; //starting position of tag-structures s32 tagStart; //starting position of tag-structures
s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures s32 tagEnd; //ending position of tag-structures/starting position of mesh-structures
s32 fileSize; s32 fileSize;
}; } PACK_STRUCT;
//! this holds the header info of an MD3 mesh section //! this holds the header info of an MD3 mesh section
struct SMD3MeshHeader struct SMD3MeshHeader
...@@ -117,7 +109,7 @@ namespace scene ...@@ -117,7 +109,7 @@ namespace scene
s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header s32 offset_st; //starting position of texvector data, relative to start of Mesh_Header
s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header s32 vertexStart; //starting position of vertex data,relative to start of Mesh_Header
s32 offset_end; s32 offset_end;
}; } PACK_STRUCT;
//! Compressed Vertex Data //! Compressed Vertex Data
...@@ -125,28 +117,24 @@ namespace scene ...@@ -125,28 +117,24 @@ namespace scene
{ {
s16 position[3]; s16 position[3];
u8 normal[2]; u8 normal[2];
}; } PACK_STRUCT;
//! Texture Coordinate //! Texture Coordinate
struct SMD3TexCoord struct SMD3TexCoord
{ {
f32 u; f32 u;
f32 v; f32 v;
}; } PACK_STRUCT;
//! Triangle Index //! Triangle Index
struct SMD3Face struct SMD3Face
{ {
s32 Index[3]; s32 Index[3];
}; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Holding Frame Data for a Mesh //! Holding Frame Data for a Mesh
struct SMD3MeshBuffer : public IReferenceCounted struct SMD3MeshBuffer : public IReferenceCounted
......
...@@ -2,11 +2,25 @@ ...@@ -2,11 +2,25 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
// include this file right before the data structures to be 1-aligned
// and add to each structure the PACK_STRUCT define just like this:
// struct mystruct
// {
// ...
// } PACK_STRUCT;
// Always include the irrunpack.h file right after the last type declared
// like this, and do not put any other types with different alignment
// in between!
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma warning(disable: 4103)
# pragma pack( push, packing ) # pragma pack( push, packing )
# pragma pack( 1 ) # pragma pack( 1 )
# define PACK_STRUCT # define PACK_STRUCT
#elif defined( __DMC__ )
# pragma pack( push, 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ ) #elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed)) # define PACK_STRUCT __attribute__((packed))
#else #else
......
...@@ -2,9 +2,14 @@ ...@@ -2,9 +2,14 @@
// This file is part of the "Irrlicht Engine". // This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h // For conditions of distribution and use, see copyright notice in irrlicht.h
// include this file to switch back to default alignment
// file belongs to irrpack.h, see there for more info
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing ) # pragma pack( pop, packing )
#elif defined (__DMC__)
# pragma pack( pop )
#endif #endif
#undef PACK_STRUCT #undef PACK_STRUCT
......
...@@ -40,16 +40,8 @@ public: ...@@ -40,16 +40,8 @@ public:
private: private:
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct ChunkHeader struct ChunkHeader
{ {
...@@ -57,13 +49,8 @@ private: ...@@ -57,13 +49,8 @@ private:
s32 length; s32 length;
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
struct ChunkData struct ChunkData
{ {
......
...@@ -19,16 +19,6 @@ namespace scene ...@@ -19,16 +19,6 @@ namespace scene
{ {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
// STUDIO MODELS, Copyright (c) 1998, Valve LLC. All rights reserved. // STUDIO MODELS, Copyright (c) 1998, Valve LLC. All rights reserved.
#define MAXSTUDIOTRIANGLES 20000 // TODO: tune this #define MAXSTUDIOTRIANGLES 20000 // TODO: tune this
#define MAXSTUDIOVERTS 2048 // TODO: tune this #define MAXSTUDIOVERTS 2048 // TODO: tune this
...@@ -48,6 +38,9 @@ namespace scene ...@@ -48,6 +38,9 @@ namespace scene
typedef f32 vec3_hl[3]; // x,y,z typedef f32 vec3_hl[3]; // x,y,z
typedef f32 vec4_hl[4]; // x,y,z,w typedef f32 vec4_hl[4]; // x,y,z,w
// byte-align structures
#include "irrpack.h"
struct SHalflifeHeader struct SHalflifeHeader
{ {
c8 id[4]; c8 id[4];
...@@ -104,14 +97,14 @@ namespace scene ...@@ -104,14 +97,14 @@ namespace scene
} PACK_STRUCT; } PACK_STRUCT;
// header for demand loaded sequence group data // header for demand loaded sequence group data
typedef struct struct studioseqhdr_t
{ {
s32 id; s32 id;
s32 version; s32 version;
c8 name[64]; c8 name[64];
s32 length; s32 length;
} PACK_STRUCT studioseqhdr_t; } PACK_STRUCT;
// bones // bones
struct SHalflifeBone struct SHalflifeBone
...@@ -207,22 +200,22 @@ namespace scene ...@@ -207,22 +200,22 @@ namespace scene
} PACK_STRUCT; } PACK_STRUCT;
// events // events
typedef struct struct mstudioevent_t
{ {
s32 frame; s32 frame;
s32 event; s32 event;
s32 type; s32 type;
c8 options[64]; c8 options[64];
} PACK_STRUCT mstudioevent_t; } PACK_STRUCT;
// pivots // pivots
typedef struct struct mstudiopivot_t
{ {
vec3_hl org; // pivot point vec3_hl org; // pivot point
s32 start; s32 start;
s32 end; s32 end;
} PACK_STRUCT mstudiopivot_t; } PACK_STRUCT;
// attachment // attachment
struct SHalflifeAttachment struct SHalflifeAttachment
...@@ -298,14 +291,17 @@ namespace scene ...@@ -298,14 +291,17 @@ namespace scene
// meshes // meshes
typedef struct struct SHalflifeMesh
{ {
u32 numtris; u32 numtris;
u32 triindex; u32 triindex;
u32 skinref; u32 skinref;
u32 numnorms; // per mesh normals u32 numnorms; // per mesh normals
u32 normindex; // normal vec3_hl u32 normindex; // normal vec3_hl
} PACK_STRUCT SHalflifeMesh; } PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
// lighting options // lighting options
#define STUDIO_NF_FLATSHADE 0x0001 #define STUDIO_NF_FLATSHADE 0x0001
...@@ -343,12 +339,6 @@ namespace scene ...@@ -343,12 +339,6 @@ namespace scene
#define RAD_TO_STUDIO (32768.0/M_PI) #define RAD_TO_STUDIO (32768.0/M_PI)
#define STUDIO_TO_RAD (M_PI/32768.0) #define STUDIO_TO_RAD (M_PI/32768.0)
// Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
/*! /*!
Textureatlas Textureatlas
Combine Source Images with arbitrary size and bithdepth to an Image with 2^n size Combine Source Images with arbitrary size and bithdepth to an Image with 2^n size
......
...@@ -14,16 +14,8 @@ namespace scene ...@@ -14,16 +14,8 @@ namespace scene
{ {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) // byte-align structures
# pragma pack( push, packing ) #include "irrpack.h"
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
//! General properties of a single animation frame. //! General properties of a single animation frame.
struct SMD3Frame struct SMD3Frame
...@@ -33,7 +25,7 @@ struct SMD3Frame ...@@ -33,7 +25,7 @@ struct SMD3Frame
f32 position[3]; // position of bounding box f32 position[3]; // position of bounding box
f32 radius; // radius of bounding sphere f32 radius; // radius of bounding sphere
c8 creator[16]; // name of frame c8 creator[16]; // name of frame
}; } PACK_STRUCT;
//! An attachment point for another MD3 model. //! An attachment point for another MD3 model.
...@@ -42,23 +34,17 @@ struct SMD3Tag ...@@ -42,23 +34,17 @@ struct SMD3Tag
c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part. c8 Name[64]; //name of 'tag' as it's usually called in the md3 files try to see it as a sub-mesh/seperate mesh-part.
f32 position[3]; //relative position of tag f32 position[3]; //relative position of tag
f32 rotationMatrix[9]; //3x3 rotation direction of tag f32 rotationMatrix[9]; //3x3 rotation direction of tag
}; } PACK_STRUCT;
//!Shader //!Shader
struct SMD3Shader struct SMD3Shader
{ {
c8 name[64]; // name of shader c8 name[64]; // name of shader
s32 shaderIndex; s32 shaderIndex;
}; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Constructor //! Constructor
......
...@@ -18,16 +18,8 @@ namespace video ...@@ -18,16 +18,8 @@ namespace video
#if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_) #if defined(_IRR_COMPILE_WITH_BMP_LOADER_) || defined(_IRR_COMPILE_WITH_BMP_WRITER_)
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SBMPHeader struct SBMPHeader
{ {
...@@ -64,13 +56,8 @@ namespace video ...@@ -64,13 +56,8 @@ namespace video
u32 ImportantColors; u32 ImportantColors;
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
#endif // defined with loader or writer #endif // defined with loader or writer
......
...@@ -16,18 +16,6 @@ namespace video ...@@ -16,18 +16,6 @@ namespace video
#if defined(_IRR_COMPILE_WITH_DDS_LOADER_) #if defined(_IRR_COMPILE_WITH_DDS_LOADER_)
// byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# define PACK_STRUCT
#endif
/* dependencies */ /* dependencies */
/* dds definition */ /* dds definition */
enum eDDSPixelFormat enum eDDSPixelFormat
...@@ -49,6 +37,9 @@ enum eDDSPixelFormat ...@@ -49,6 +37,9 @@ enum eDDSPixelFormat
#define DDS_HI_555 0x7C00; #define DDS_HI_555 0x7C00;
// byte-align structures
#include "irrpack.h"
/* structures */ /* structures */
struct ddsColorKey struct ddsColorKey
{ {
...@@ -193,6 +184,9 @@ struct ddsColor ...@@ -193,6 +184,9 @@ struct ddsColor
u8 r, g, b, a; u8 r, g, b, a;
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment
#include "irrunpack.h"
/* endian tomfoolery */ /* endian tomfoolery */
typedef union typedef union
...@@ -275,13 +269,6 @@ floatSwapUnion; ...@@ -275,13 +269,6 @@ floatSwapUnion;
#endif /*__BIG_ENDIAN__*/ #endif /*__BIG_ENDIAN__*/
// Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
#endif // compiled with loader or reader #endif // compiled with loader or reader
#ifdef _IRR_COMPILE_WITH_DDS_LOADER_ #ifdef _IRR_COMPILE_WITH_DDS_LOADER_
......
...@@ -17,15 +17,7 @@ namespace video ...@@ -17,15 +17,7 @@ namespace video
#if defined(_IRR_COMPILE_WITH_PCX_LOADER_) || defined(_IRR_COMPILE_WITH_PCX_WRITER_) #if defined(_IRR_COMPILE_WITH_PCX_LOADER_) || defined(_IRR_COMPILE_WITH_PCX_WRITER_)
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SPCXHeader struct SPCXHeader
{ {
...@@ -51,11 +43,7 @@ namespace video ...@@ -51,11 +43,7 @@ namespace video
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
#endif // compile with loader or writer #endif // compile with loader or writer
......
...@@ -18,15 +18,7 @@ namespace video ...@@ -18,15 +18,7 @@ namespace video
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct PsdHeader struct PsdHeader
{ {
...@@ -42,11 +34,7 @@ namespace video ...@@ -42,11 +34,7 @@ namespace video
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
/*! /*!
Surface Loader for psd images Surface Loader for psd images
......
...@@ -32,41 +32,29 @@ namespace video ...@@ -32,41 +32,29 @@ namespace video
{ {
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
// the RGB image file header structure // the RGB image file header structure
struct SRGBHeader struct SRGBHeader
{ {
u16 Magic; // IRIS image file magic number u16 Magic; // IRIS image file magic number
u8 Storage; // Storage format u8 Storage; // Storage format
u8 BPC; // Number of bytes per pixel channel u8 BPC; // Number of bytes per pixel channel
u16 Dimension; // Number of dimensions u16 Dimension; // Number of dimensions
u16 Xsize; // X size in pixels u16 Xsize; // X size in pixels
u16 Ysize; // Y size in pixels u16 Ysize; // Y size in pixels
u16 Zsize; // Z size in pixels u16 Zsize; // Z size in pixels
u32 Pixmin; // Minimum pixel value u32 Pixmin; // Minimum pixel value
u32 Pixmax; // Maximum pixel value u32 Pixmax; // Maximum pixel value
u32 Dummy1; // ignored u32 Dummy1; // ignored
char Imagename[80]; // Image name char Imagename[80];// Image name
u32 Colormap; // Colormap ID u32 Colormap; // Colormap ID
// char Dummy2[404]; // Ignored // char Dummy2[404];// Ignored
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
// this structure holds context specific data about the file being loaded. // this structure holds context specific data about the file being loaded.
......
...@@ -18,15 +18,7 @@ namespace video ...@@ -18,15 +18,7 @@ namespace video
#if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_) #if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_)
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# define PACK_STRUCT
#endif
// these structs are also used in the TGA writer // these structs are also used in the TGA writer
struct STGAHeader{ struct STGAHeader{
...@@ -52,11 +44,7 @@ namespace video ...@@ -52,11 +44,7 @@ namespace video
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
#endif // compiled with loader or reader #endif // compiled with loader or reader
......
...@@ -17,53 +17,6 @@ namespace irr ...@@ -17,53 +17,6 @@ namespace irr
{ {
namespace video namespace video
{ {
#if 0
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SWALHeader {
char FrameName[32];
u32 ImageWidth;
u32 ImageHeight;
s32 MipmapOffset[4];
char NextFrameName[32];
u32 Flags; // surface properties, i.e. slick, sky, nodraw
u32 Contents; // i.e. solid, clip, area portal
u32 Value; // light
} PACK_STRUCT;
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! An Irrlicht image loader for Quake engine WAL textures
class CImageLoaderWAL : public irr::video::IImageLoader
{
public:
virtual bool isALoadableFileExtension(const io::path& filename) const;
virtual bool isALoadableFileFormat(irr::io::IReadFile* file) const;
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
private:
static s32 DefaultPaletteQ2[256];
};
#endif
//! An Irrlicht image loader for Quake1,2 engine lmp textures/palette //! An Irrlicht image loader for Quake1,2 engine lmp textures/palette
class CImageLoaderLMP : public irr::video::IImageLoader class CImageLoaderLMP : public irr::video::IImageLoader
...@@ -92,23 +45,14 @@ public: ...@@ -92,23 +45,14 @@ public:
virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const; virtual irr::video::IImage* loadImage(irr::io::IReadFile* file) const;
}; };
// byte-align structures
#include "irrpack.h"
struct SLMPHeader {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) u32 width; // width
# pragma pack( push, packing ) u32 height; // height
# pragma pack( 1 ) // variably sized
# define PACK_STRUCT } PACK_STRUCT;
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SLMPHeader {
u32 width; // width
u32 height; // height
// variably sized
} PACK_STRUCT;
// Halfelife wad3 type 67 file // Halfelife wad3 type 67 file
struct miptex_halflife struct miptex_halflife
...@@ -131,11 +75,8 @@ public: ...@@ -131,11 +75,8 @@ public:
s32 value; s32 value;
}; };
// Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
} }
} }
......
...@@ -50,15 +50,7 @@ private: ...@@ -50,15 +50,7 @@ private:
void cleanup(); void cleanup();
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SLMTSHeader struct SLMTSHeader
{ {
...@@ -98,11 +90,7 @@ private: ...@@ -98,11 +90,7 @@ private:
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
SLMTSHeader Header; SLMTSHeader Header;
SLMTSTextureInfoEntry* Textures; SLMTSTextureInfoEntry* Textures;
......
...@@ -15,22 +15,15 @@ namespace scene ...@@ -15,22 +15,15 @@ namespace scene
{ {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
// structs needed to load the md2-format // structs needed to load the md2-format
const s32 MD2_MAGIC_NUMBER = 844121161; const s32 MD2_MAGIC_NUMBER = 844121161;
const s32 MD2_VERSION = 8; const s32 MD2_VERSION = 8;
const s32 MD2_MAX_VERTS = 2048; const s32 MD2_MAX_VERTS = 2048;
// byte-align structures
#include "irrpack.h"
struct SMD2Header struct SMD2Header
{ {
s32 magic; // four character code "IDP2" s32 magic; // four character code "IDP2"
...@@ -85,11 +78,7 @@ namespace scene ...@@ -85,11 +78,7 @@ namespace scene
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Constructor //! Constructor
CMD2MeshFileLoader::CMD2MeshFileLoader() CMD2MeshFileLoader::CMD2MeshFileLoader()
......
...@@ -21,15 +21,7 @@ namespace scene ...@@ -21,15 +21,7 @@ namespace scene
#endif #endif
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
namespace { namespace {
// File header // File header
...@@ -103,11 +95,7 @@ struct MS3DVertexWeights ...@@ -103,11 +95,7 @@ struct MS3DVertexWeights
} // end namespace } // end namespace
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
struct SGroup struct SGroup
{ {
......
...@@ -29,18 +29,8 @@ namespace scene ...@@ -29,18 +29,8 @@ namespace scene
// MY3D stuff // MY3D stuff
//********************************************************************** //**********************************************************************
//--------------------------------------------------------------------
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
//----------------------------------------------------------------------
struct SMyVector3 struct SMyVector3
{ SMyVector3 () {;} { SMyVector3 () {;}
...@@ -135,9 +125,7 @@ struct SMyRLEHeader ...@@ -135,9 +125,7 @@ struct SMyRLEHeader
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
} // end namespace } // end namespace
} // end namespace } // end namespace
......
...@@ -43,18 +43,9 @@ namespace irr ...@@ -43,18 +43,9 @@ namespace irr
namespace scene namespace scene
{ {
//--------------------------------------------------------------------
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
//----------------------------------------------------------------------
struct SMyColor struct SMyColor
{ SMyColor () {;} { SMyColor () {;}
SMyColor (s32 __R, s32 __G, s32 __B, s32 __A) SMyColor (s32 __R, s32 __G, s32 __B, s32 __A)
...@@ -76,9 +67,7 @@ struct SMyMaterialHeader ...@@ -76,9 +67,7 @@ struct SMyMaterialHeader
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
class CMY3DMeshFileLoader : public IMeshLoader class CMY3DMeshFileLoader : public IMeshLoader
{ {
......
...@@ -46,16 +46,8 @@ public: ...@@ -46,16 +46,8 @@ public:
private: private:
// byte-align structures // byte-align structures
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrpack.h"
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct ChunkHeader struct ChunkHeader
{ {
...@@ -63,12 +55,8 @@ private: ...@@ -63,12 +55,8 @@ private:
u32 length; u32 length;
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
struct ChunkData struct ChunkData
......
...@@ -21,16 +21,6 @@ namespace irr ...@@ -21,16 +21,6 @@ namespace irr
namespace io namespace io
{ {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
enum E_TAR_LINK_INDICATOR enum E_TAR_LINK_INDICATOR
{ {
ETLI_REGULAR_FILE_OLD = 0 , ETLI_REGULAR_FILE_OLD = 0 ,
...@@ -44,6 +34,9 @@ namespace io ...@@ -44,6 +34,9 @@ namespace io
ETLI_CONTIGUOUS_FILE = '7' ETLI_CONTIGUOUS_FILE = '7'
}; };
// byte-align structures
#include "irrpack.h"
struct STarHeader struct STarHeader
{ {
c8 FileName[100]; c8 FileName[100];
...@@ -64,13 +57,8 @@ namespace io ...@@ -64,13 +57,8 @@ namespace io
c8 FileNamePrefix[155]; c8 FileNamePrefix[155];
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Archiveloader capable of loading ZIP Archives //! Archiveloader capable of loading ZIP Archives
class CArchiveLoaderTAR : public IArchiveLoader class CArchiveLoaderTAR : public IArchiveLoader
......
...@@ -20,16 +20,6 @@ namespace irr ...@@ -20,16 +20,6 @@ namespace irr
{ {
namespace io namespace io
{ {
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
# pragma pack( push, packing )
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
enum eWADFileTypes enum eWADFileTypes
{ {
...@@ -53,6 +43,9 @@ namespace io ...@@ -53,6 +43,9 @@ namespace io
WAD_TYP_FONT = 70, WAD_TYP_FONT = 70,
}; };
// byte-align structures
#include "irrpack.h"
struct SWADFileHeader struct SWADFileHeader
{ {
c8 tag[4]; // type of WAD format WAD2 = quake2, WAD3 = halflife c8 tag[4]; // type of WAD format WAD2 = quake2, WAD3 = halflife
...@@ -72,11 +65,7 @@ namespace io ...@@ -72,11 +65,7 @@ namespace io
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
struct SWADFileEntry struct SWADFileEntry
{ {
......
...@@ -25,16 +25,8 @@ namespace io ...@@ -25,16 +25,8 @@ namespace io
// zero in the local header // zero in the local header
const s16 ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008; const s16 ZIP_INFO_IN_DATA_DESCRIPTOR = 0x0008;
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) // byte-align structures
# pragma pack( push, packing ) #include "irrpack.h"
# pragma pack( 1 )
# define PACK_STRUCT
#elif defined( __GNUC__ )
# define PACK_STRUCT __attribute__((packed))
#else
# error compiler not supported
#endif
struct SZIPFileDataDescriptor struct SZIPFileDataDescriptor
{ {
...@@ -131,11 +123,7 @@ namespace io ...@@ -131,11 +123,7 @@ namespace io
} PACK_STRUCT; } PACK_STRUCT;
// Default alignment // Default alignment
#if defined(_MSC_VER) || defined(__BORLANDC__) || defined (__BCPLUSPLUS__) #include "irrunpack.h"
# pragma pack( pop, packing )
#endif
#undef PACK_STRUCT
//! Contains extended info about zip files in the archive //! Contains extended info about zip files in the archive
struct SZipFileEntry struct SZipFileEntry
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment