]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/bobtoolz/bsploader.cpp
Merge remote-tracking branch 'ttimo/master'
[xonotic/netradiant.git] / contrib / bobtoolz / bsploader.cpp
index aadd2b31f81e3ccd9478c9cc77a523fd1285ceb9..6c8b09e90f185431e78c748a932e51eaf6e23527 100644 (file)
@@ -1,7 +1,6 @@
-#include "StdAfx.h"
-#include "./dialogs/dialogs-gtk.h"
 #include "bsploader.h"
-#include "../../libs/cmdlib.h"
+#include "dialogs/dialogs-gtk.h"
+#include "cmdlib.h"
 
 int numnodes;
 int numplanes;
@@ -51,7 +50,7 @@ int FileLength( FILE *f ){
    LoadFile
    ==============
  */
-qboolean    LoadFile( const char *filename, byte **bufferptr ){
+bool    LoadFile( const char *filename, byte **bufferptr ){
        FILE    *f;
        int length;
        byte    *buffer;
@@ -71,15 +70,19 @@ qboolean    LoadFile( const char *filename, byte **bufferptr ){
        return true;
 }
 
-/*int    LittleLong (int l)
-   {
-    return l;
-   }
+int    LittleLong( int l ){
+#if defined( __BIG_ENDIAN__ )
+       std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( int ) );
+#endif
+       return l;
+}
 
-   float       LittleFloat (float l)
-   {
-    return l;
-   }*/
+float   LittleFloat( float l ){
+#if defined( __BIG_ENDIAN__ )
+       std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( float ) );
+#endif
+       return l;
+}
 
 /*
    =============
@@ -194,7 +197,7 @@ int CopyLump( dheader_t *header, int lump, void **dest, int size ) {
    LoadBSPFile
    =============
  */
-qboolean    LoadBSPFile( const char *filename ) {
+bool    LoadBSPFile( const char *filename ) {
        dheader_t   *header;
 
        // load the file header
@@ -206,12 +209,12 @@ qboolean    LoadBSPFile( const char *filename ) {
        SwapBlock( (int *)header, sizeof( *header ) );
 
        if ( header->ident != BSP_IDENT ) {
-               DoMessageBox( "Cant find a valid IBSP file", "Error", MB_OK );
+               DoMessageBox( "Cant find a valid IBSP file", "Error", eMB_OK );
                return false;
        }
        if ( ( header->version != Q3_BSP_VERSION ) &&
                 ( header->version != WOLF_BSP_VERSION ) ) {
-               DoMessageBox( "File is incorrect version", "Error", MB_OK );
+               DoMessageBox( "File is incorrect version", "Error", eMB_OK );
                return false;
        }