-#include "StdAfx.h"
-#include "./dialogs/dialogs-gtk.h"
+#include <globaldefs.h>
#include "bsploader.h"
-#include "../../libs/cmdlib.h"
+#include "dialogs/dialogs-gtk.h"
+#include "cmdlib.h"
int numnodes;
int numplanes;
dbrushside_t *dbrushsides = NULL;
int *dleafbrushes = NULL;
-#define BSP_IDENT ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' )
-#define Q3_BSP_VERSION 46
-#define WOLF_BSP_VERSION 47
+const int BSP_IDENT = ( ( 'P' << 24 ) + ( 'S' << 16 ) + ( 'B' << 8 ) + 'I' );
+const int Q3_BSP_VERSION = 46;
+const int WOLF_BSP_VERSION = 47;
/*
================
LoadFile
==============
*/
-qboolean LoadFile( const char *filename, byte **bufferptr ){
+bool LoadFile( const char *filename, byte **bufferptr ){
FILE *f;
int length;
byte *buffer;
return true;
}
-/*int LittleLong (int l)
- {
- return l;
- }
+int LittleLong( int l ){
+ if (GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse(reinterpret_cast<unsigned char *>( &l ), reinterpret_cast<unsigned char *>( &l ) + sizeof(int));
+ }
+ return l;
+}
- float LittleFloat (float l)
- {
- return l;
- }*/
+float LittleFloat( float l ){
+ if (GDEF_ARCH_ENDIAN_BIG) {
+ std::reverse( reinterpret_cast<unsigned char*>( &l ), reinterpret_cast<unsigned char*>( &l ) + sizeof( float ) );
+ }
+ return l;
+}
/*
=============
LoadBSPFile
=============
*/
-qboolean LoadBSPFile( const char *filename ) {
+bool LoadBSPFile( const char *filename ) {
dheader_t *header;
// load the file header
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;
}