]> git.xonotic.org Git - xonotic/netradiant.git/blobdiff - contrib/gtkgensurf/bitmap.cpp
Merge commit '4645e19ce9e8f8034233ac965a4103a13b75714c' into garux-merge
[xonotic/netradiant.git] / contrib / gtkgensurf / bitmap.cpp
index b49c6ca9e97c9ef2ca9bf3ae82dc1db84c44033d..68eea5c2c43ee611a0bec432075a855bf2dc8cf6 100644 (file)
 
 #include <stdio.h>
 #include <stdlib.h>
-
-#ifdef _WIN32
-// cough, cough
-typedef __int32 int32_t;
-typedef unsigned __int16 uint16_t;
-typedef unsigned __int8 uint8_t;
-typedef unsigned __int32 uint32_t;
-typedef __int16 int16_t;
-#endif
-
 #include <math.h>
 #include "gensurf.h"
 
@@ -90,7 +80,7 @@ static unsigned char* OpenBitmapFile(){
                fprintf( stderr,"%s:%d: Error file '%s' is malformed.\n",__FILE__,__LINE__,gbmp.name ); \
                fclose( fp ); \
                return NULL; \
-} while ( 0 )
+} while ( 0 );
 
        int32_t bmWidth;
        int32_t bmHeight;
@@ -117,8 +107,7 @@ static unsigned char* OpenBitmapFile(){
        rc = fread( &m1, 1, 1, fp );
        m_bytesRead++;
        if ( rc == -1 ) {
-               fclose( fp );
-               return NULL;
+               INVALID_FORMAT;
        }
 
        rc = fread( &m2, 1, 1, fp );
@@ -204,8 +193,9 @@ static unsigned char* OpenBitmapFile(){
 
        if ( bmBitsPixel != 8 ) {
                g_FuncTable.m_pfnMessageBox( g_pWnd, "This is not an 8-bit image. GenSurf can't use it.",
-                                                                        "Bitmap", MB_ICONEXCLAMATION, NULL );
-               INVALID_FORMAT;
+                                                                        "Bitmap", eMB_OK, eMB_ICONWARNING );
+               fclose( fp );
+               return NULL;
        }
 
        if ( colors == 0 ) {
@@ -439,17 +429,16 @@ bool OpenBitmap(){
        OpenBitmapFile();
 
        if ( !gbmp.colors ) {
-               g_print( "failed to load file gbmp %s\n",gbmp.name );
                char Text[256];
 
                sprintf( Text, "Error opening %s", gbmp.name );
-               g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "Bitmap", MB_ICONEXCLAMATION, NULL );
+               g_FuncTable.m_pfnMessageBox( g_pWnd, Text, "Bitmap", eMB_OK, eMB_ICONWARNING );
                strcpy( gbmp.name, "" );
        }
 
        if ( g_pWnd ) {
                gtk_entry_set_text( GTK_ENTRY( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_file" ) ), gbmp.name );
-               gtk_widget_set_sensitive( GTK_WIDGET( g_object_get_data( G_OBJECT( g_pWnd ), "bmp_reload" ) ),
+               gtk_widget_set_sensitive( g_object_get_data( G_OBJECT( g_pWnd , "bmp_reload" ) ),
                                                                  strlen( gbmp.name ) ? TRUE : FALSE );
 
                UpdatePreview( true );