Warning() => GFX2_Log(GFX2_WARNING)
This commit is contained in:
parent
7f08ad5bb9
commit
2c9b79a6af
10
src/errors.h
10
src/errors.h
@ -47,13 +47,3 @@ void Error_function(int error_code, const char *filename, int line_number, const
|
||||
/// - If the error code is 0, just do a red screen flash and resume.
|
||||
/// - If the error code is non-zero, abort the program.
|
||||
#define Error(n) Error_function(n, __FILE__,__LINE__,__func__)
|
||||
|
||||
/// Helper function used by the macro ::Warning
|
||||
void Warning_function(const char *message, const char *filename, int line_number, const char *function_name);
|
||||
|
||||
///
|
||||
/// Report a run-time abnormal condition : It will print to standard output
|
||||
/// some information about the calling function, and then resume silently.
|
||||
/// This is most useful in debugger so you can put a breakpoint on
|
||||
/// ::Warning_function and examine the stack trace.
|
||||
#define Warning(msg) Warning_function(msg, __FILE__,__LINE__,__func__)
|
||||
|
||||
@ -367,7 +367,7 @@ static byte * Decode_NewIcons(const byte * p, int bits, unsigned int * len)
|
||||
value = value - 0x51;
|
||||
else
|
||||
{
|
||||
Warning("Invalid value");
|
||||
GFX2_Log(GFX2_WARNING, "Decode_NewIcons(): Invalid value 0x%02x\n", value);
|
||||
break;
|
||||
}
|
||||
current_byte = (current_byte << 7) | value;
|
||||
@ -571,7 +571,7 @@ void Load_INFO(T_IO_Context * context)
|
||||
palette_color_count++;
|
||||
}
|
||||
else
|
||||
Warning("Too much colors in new icons");
|
||||
GFX2_Log(GFX2_WARNING, "Too much colors in new icons\n");
|
||||
}
|
||||
palette_conv[i] = (byte)j;
|
||||
}
|
||||
@ -629,7 +629,7 @@ void Load_INFO(T_IO_Context * context)
|
||||
palette_color_count++;
|
||||
}
|
||||
else
|
||||
Warning("Too much colors in new icons");
|
||||
GFX2_Log(GFX2_WARNING, "Too much colors in new icons\n");
|
||||
}
|
||||
palette_conv[i+palette_continues] = (byte)j;
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ static void Load_BMP_Pixels(T_IO_Context * context, FILE * file, unsigned int co
|
||||
if (0 == memcmp(png_header, "\x89PNG", 4))
|
||||
{
|
||||
// NO PNG Support
|
||||
Warning("PNG Signature : Compiled without libpng support");
|
||||
GFX2_Log(GFX2_WARNING, "PNG Signature : Compiled without libpng support\n");
|
||||
File_error = 2;
|
||||
}
|
||||
#endif
|
||||
@ -1122,7 +1122,7 @@ static void Load_BMP_Pixels(T_IO_Context * context, FILE * file, unsigned int co
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Warning("Unknown compression type");
|
||||
GFX2_Log(GFX2_WARNING, "BMP: Unknown compression type %d\n", compression);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1227,7 +1227,7 @@ void Load_BMP(T_IO_Context * context)
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning("Unknown BMP type");
|
||||
GFX2_Log(GFX2_WARNING, "Unknown BMP type Size_2=%u\n", header.Size_2);
|
||||
File_error = 1;
|
||||
}
|
||||
}
|
||||
@ -1629,7 +1629,7 @@ void Load_ICO(T_IO_Context * context)
|
||||
// check that real_height == entry->height
|
||||
if (real_height != entry->height)
|
||||
{
|
||||
Warning("Load_ICO() : real_height != entry->height");
|
||||
GFX2_Log(GFX2_WARNING, "Load_ICO() : real_height(%hd) != entry->height(%hd)\n", real_height, entry->height);
|
||||
}
|
||||
|
||||
// Image 16/24/32 bits
|
||||
@ -1694,7 +1694,7 @@ void Save_ICO(T_IO_Context * context)
|
||||
if (context->Width > 256 || context->Height > 256)
|
||||
{
|
||||
File_error=1;
|
||||
Warning(".ICO files can handle images up to 256x256");
|
||||
GFX2_Log(GFX2_WARNING, ".ICO files can handle images up to 256x256\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -2446,7 +2446,7 @@ void Load_SCx(T_IO_Context * context)
|
||||
{
|
||||
if (SCx_header.StorageType == 0x80)
|
||||
{
|
||||
Warning("Compressed SCx files are not supported");
|
||||
GFX2_Log(GFX2_WARNING, "Compressed SCx files are not supported\n");
|
||||
File_error = 2;
|
||||
}
|
||||
else
|
||||
|
||||
@ -70,7 +70,7 @@ void Set_GFX2_Surface_pixel(T_GFX2_Surface * surface, int x, int y, byte value)
|
||||
if (surface == NULL) return;
|
||||
if (x<0 || x>=surface->w || y<0 || y>=surface->h)
|
||||
{
|
||||
Warning("Set_GFX2_Surface_pixel() out of bound access");
|
||||
GFX2_Log(GFX2_WARNING, "Set_GFX2_Surface_pixel() out of bound access (%d,%d)\n", x, y);
|
||||
return;
|
||||
}
|
||||
surface->pixels[x + surface->w * y] = value;
|
||||
|
||||
@ -34,6 +34,8 @@
|
||||
#include "io.h"
|
||||
#include "errors.h"
|
||||
#include "unicode.h"
|
||||
#include "gfx2mem.h"
|
||||
#include "gfx2log.h"
|
||||
|
||||
#include "recoil.h"
|
||||
|
||||
@ -82,17 +84,16 @@ void Load_Recoil_Image(T_IO_Context *context)
|
||||
File_error = 1;
|
||||
return;
|
||||
}
|
||||
file_content = malloc(file_length);
|
||||
file_content = GFX2_malloc(file_length);
|
||||
if (file_content == NULL)
|
||||
{
|
||||
Warning("Memory allocation error");
|
||||
fclose(f);
|
||||
File_error = 1;
|
||||
return;
|
||||
}
|
||||
if (!Read_bytes(f, file_content, file_length))
|
||||
{
|
||||
Warning("Read error");
|
||||
GFX2_Log(GFX2_WARNING, "Load_Recoil_Image(): Read error on file\n");
|
||||
fclose(f);
|
||||
free(file_content);
|
||||
File_error = 1;
|
||||
@ -116,7 +117,7 @@ void Load_Recoil_Image(T_IO_Context *context)
|
||||
// ie .DEE instead of .deep
|
||||
size_t i;
|
||||
size_t len = Unicode_strlen(context->File_name_unicode);
|
||||
tempfilename = (char *)malloc(len + 1);
|
||||
tempfilename = (char *)GFX2_malloc(len + 1);
|
||||
for (i = 0; i < len; i++)
|
||||
tempfilename[i] = (context->File_name_unicode[i] < 256) ? (char)context->File_name_unicode[i] : '_';
|
||||
tempfilename[i] = '\0';
|
||||
@ -143,10 +144,9 @@ void Load_Recoil_Image(T_IO_Context *context)
|
||||
ratio = PIXEL_WIDE;
|
||||
else if(x_ratio == 1 && y_ratio > 1)
|
||||
ratio = PIXEL_TALL;
|
||||
pixels = malloc(width * height);
|
||||
pixels = GFX2_malloc(width * height);
|
||||
if (pixels == NULL)
|
||||
{
|
||||
Warning("Memory allocation error");
|
||||
File_error = 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -615,7 +615,7 @@ void Load_image(T_IO_Context *context)
|
||||
f = Open_file_read(context);
|
||||
if (f == NULL)
|
||||
{
|
||||
Warning("Cannot open file for reading");
|
||||
GFX2_Log(GFX2_WARNING, "Cannot open file for reading\n");
|
||||
Error(0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -204,13 +204,6 @@ void Display_syntax(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------- Sortie impromptue ----------------------------
|
||||
void Warning_function(const char *message, const char *filename, int line_number, const char *function_name)
|
||||
{
|
||||
GFX2_Log(GFX2_WARNING, "Warning in file %s, line %d, function %s : %s\n", filename, line_number, function_name, message);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------- Sortie impromptue ----------------------------
|
||||
void Error_function(int error_code, const char *filename, int line_number, const char *function_name)
|
||||
{
|
||||
|
||||
@ -705,7 +705,7 @@ byte Readline_ex_unicode(word x_pos, word y_pos, char * str, word * str_unicode,
|
||||
}
|
||||
else
|
||||
{
|
||||
Warning("Unicode conversion of input text failed");
|
||||
GFX2_Log(GFX2_WARNING, "Unicode conversion of input text failed\n");
|
||||
unicode_text[0] = 0;
|
||||
}
|
||||
#elif defined(WIN32)
|
||||
|
||||
@ -83,7 +83,7 @@ byte Get_Screen_pixel(int x, int y)
|
||||
{
|
||||
if (y < 0 || x < 0 || y >= Screen_SDL->h || x >= Screen_SDL->w)
|
||||
{
|
||||
Warning("Get_Screen_pixel() coordinates out of bound");
|
||||
GFX2_Log(GFX2_WARNING, "Get_Screen_pixel() coordinates out of bound\n");
|
||||
return 0;
|
||||
}
|
||||
return ((byte *)Screen_SDL->pixels)[x + y*(Screen_SDL->pitch)];
|
||||
@ -93,7 +93,7 @@ void Set_Screen_pixel(int x, int y, byte value)
|
||||
{
|
||||
if (y < 0 || x < 0 || y >= Screen_SDL->h || x >= Screen_SDL->w)
|
||||
{
|
||||
Warning("Set_Screen_pixel() coordinates out of bound");
|
||||
GFX2_Log(GFX2_WARNING, "Set_Screen_pixel() coordinates out of bound\n");
|
||||
return;
|
||||
}
|
||||
((byte *)Screen_SDL->pixels)[x + y*(Screen_SDL->pitch)] = value;
|
||||
|
||||
@ -748,7 +748,7 @@ byte *Render_text_SFont(const char *str, int font_number, int *width, int *heigh
|
||||
text_surface = New_GFX2_Surface(*width, *height);
|
||||
if (text_surface == NULL)
|
||||
{
|
||||
Warning("Failed to allocate text surface");
|
||||
GFX2_Log(GFX2_WARNING, "Failed to allocate text surface\n");
|
||||
SFont_FreeFont(font);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -427,7 +427,7 @@ int Init_Win32(HINSTANCE hInstance, HINSTANCE hPrevInstance)
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = TEXT("grafx2");
|
||||
if (!RegisterClass(&wc)) {
|
||||
Warning("RegisterClass failed\n");
|
||||
GFX2_Log(GFX2_WARNING, "RegisterClass failed\n");
|
||||
Error(ERROR_INIT);
|
||||
return 0;
|
||||
}
|
||||
@ -457,7 +457,7 @@ static int Video_AllocateDib(int width, int height)
|
||||
dc = GetDC(NULL);
|
||||
Windows_DIB = CreateDIBSection(dc, bi, DIB_RGB_COLORS, &Windows_Screen, NULL, 0);
|
||||
if (Windows_DIB == NULL) {
|
||||
Warning("CreateDIBSection failed");
|
||||
GFX2_Log(GFX2_WARNING, "CreateDIBSection failed\n");
|
||||
return -1;
|
||||
}
|
||||
ReleaseDC(NULL, dc);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user