#include <stdio.h>
#include <stdarg.h>
#include <SDL2/SDL_log.h>
+#if defined(_WIN32)
+#include <windows.h>
+#endif
void __attribute__ ((format (printf, 1, 2))) _print_info(const char *format, ...)
{
va_list args;
va_start(args, format);
+#if defined(_WIN32)
+ char title[123], text[1234];
+ snprintf(title, sizeof(title), "Error in %s line %d:\n", _file, _line);
+ title[sizeof(title) - 1] = '\0';
+ vsnprintf(text, sizeof(text), format, args);
+ text[sizeof(text) - 1] = '\0';
+ MessageBox(NULL, text, title, MB_OK);
+#else
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "Error in %s line %d:\n", _file, _line);
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, format, args);
+#endif
va_end(args);
}
#endif
if (color >= 0x8000) {
#ifdef DEBUG_COLOR
- print_error("Use of color index from current palette, but index is not defined as being set!\n");
+ fprintf(stderr, "Use of color index from current palette, but index is not defined as being set!\n");
#endif
}
*red = (double)((color >> 8) & 0xf) / 15.0;
#endif
/* now use that color info parse again (hopefully it does not contain a "pre-defined palette" again and again! */
if (nesting++ == 8) {
- print_error("Color lookup from pre-defined palette is nesting too much, please fix!\n");
+ print_info("Color lookup from pre-defined palette is nesting too much, please fix!\n");
return;
}
goto again;
static void store_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y, int32_t z)
{
if ((vertex & 3)) {
- print_error("Vertex %d is not a multiple of four!\n", vertex);
+ print_info("Vertex %d is not a multiple of four!\n", vertex);
return;
}
/* create new vertices item, if there was no vertex before, or if the vertex has different offet */
}
vertex -= 0x200;
} else {
- print_error("Vertex %d exceeds maximum vertex number, please fix!\n", vertex);
+ print_info("Vertex %d exceeds maximum vertex number, please fix!\n", vertex);
return;
}
vertex >>= 2;
static void store_interior_coord(const char __attribute__((unused)) *what, uint32_t vertex, int32_t x, int32_t y1, int32_t y2, int32_t y3, int32_t y4, int32_t z)
{
if ((vertex & 3)) {
- print_error("Vertex is not a multiple of four!\n");
+ print_info("Vertex is not a multiple of four!\n");
return;
}
if (vertex >= MAX_INTERIOR_VERTEX) {
- print_error("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_INTERIOR_VERTEX);
+ print_info("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_INTERIOR_VERTEX);
return;
}
if (!render_item || render_item->type != RENDER_ITEM_VERTICES_INTERIOR)
table = REG_A[0];
count = REG_D[5] + 1;
if (count > MAX_INTERSTARS) {
- print_error("Expecting maximum of %d stars here, plese fix!\n", MAX_INTERSTARS);
+ print_info("Expecting maximum of %d stars here, plese fix!\n", MAX_INTERSTARS);
return;
}
for (i = 0; i < count; i++) {
case STOP_AT_POLY_BUILDING_INTERIOR1to4:
/* before we come here, we must already passed the break points above, so we know the level to be rendered */
if (interior_level12 == 0) {
- print_error("Interior level is not set, please fix!\n");
+ print_info("Interior level is not set, please fix!\n");
break;
}
poly_building_interior1to4(interior_level12);
case STOP_AT_POLY_BUILDING_INTERIOR5to6:
/* before we come here, we must already passed the break points above, so we know the level to be rendered */
if (interior_level12 == 0) {
- print_error("Interior level is not set, please fix!\n");
+ print_info("Interior level is not set, please fix!\n");
break;
}
poly_building_interior5to6(interior_level12, interior_level34);
render_item_t *ri = NULL;
if ((vertex & 3)) {
- print_error("Vertex %d is not a multiple of four!\n", vertex);
+ print_info("Vertex %d is not a multiple of four!\n", vertex);
return -1;
}
if (vertex < 0x100) {
if (!render_item_vertices_0) {
- print_error("Vertices item for vertex %d not yet set!\n", vertex);
+ print_info("Vertices item for vertex %d not yet set!\n", vertex);
return -1;
}
ri = render_item_vertices_0;
} else
if (vertex < 0x200) {
if (!render_item_vertices_1) {
- print_error("Vertices item for vertex %d not yet set!\n", vertex);
+ print_info("Vertices item for vertex %d not yet set!\n", vertex);
return -1;
}
ri = render_item_vertices_1;
} else
if (vertex < 0x300) {
if (!render_item_vertices_2) {
- print_error("Vertices item for vertex %d not yet set!\n", vertex);
+ print_info("Vertices item for vertex %d not yet set!\n", vertex);
return -1;
}
ri = render_item_vertices_2;
vertex -= 0x200;
} else {
- print_error("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_VERTEX);
+ print_info("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_VERTEX);
return -1;
}
vertex >>= 2;
static int use_interior_coord(const char __attribute__((unused)) *what, uint32_t vertex, int level, double *x, double *y, double *z)
{
if ((vertex & 3)) {
- print_error("Vertex is not a multiple of four!\n");
+ print_info("Vertex is not a multiple of four!\n");
return -1;
}
if (vertex >= MAX_INTERIOR_VERTEX) {
- print_error("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_VERTEX);
+ print_info("Vertex %d exceeds maximum vertex number %d!\n", vertex, MAX_VERTEX);
return -1;
}
if (level < 1 || level > 4) {
- print_error("Level %d is out of range (1..4)!\n", level);
+ print_info("Level %d is out of range (1..4)!\n", level);
return -1;
}
if (!render_item_vertices_interior) {
- print_error("Vertices item for interior verticies not yet set!\n");
+ print_info("Vertices item for interior verticies not yet set!\n");
return -1;
}
vertex >>= 2;
break;
}
default:
- print_error("Unknown type, please fix!\n");
+ print_info("Unknown render item type, please fix!\n");
}
}