1 /*! \mainpage xuni is a 2D game written with the SDL and released under the
2 GNU General Public License (GPL). See the file COPYING for licensing
5 xuni stands for "Explore the Universe". It's entirely coincidental that
6 shifting one of the letters in "xuni" spells UNIX, and that reversing the
7 letters and adding another letter spells Linux. "xuni" is pronounced
8 "zoo-nee" in the author's opinion. But "ecks-you-nee" or
9 "ecks-you-en-eye" or other variations work as well.
11 xuni was written from the ground up without incorporating any code from my
12 numerous previous SDL projects. It uses SDL_image, SDL_gfx, and SDL_ttf
13 (my first project to do so) in addition to the SDL.
35 static const char *get_ctime(void);
36 static void log_printf(const char *format
, ...);
37 static void print_message(const char *type
, const char *message
,
38 const char *file
, int line
);
42 int STDCALL
WinMain(HINSTANCE hInst
, HINSTANCE hPrev
, LPSTR lpCmd
, int nShow
) {
44 int main(int argc
, char *argv
[]) {
51 load_settings(&smode
, &font
, &theme
, &gui
);
55 reload_fonts(&font
, &smode
);
58 resize_theme(&theme
, &smode
);
60 main_loop(&smode
, &font
, &theme
, &gui
);
62 write_settings(&smode
, &font
, &theme
, &gui
);
71 char *duplicate_string(const char *str
, size_t len
) {
72 char *p
= malloc(len
+ 1);
77 static const char *get_ctime(void) {
83 /*! Calls vfprintf() for stderr and the file LOG_FILE with the same data.
84 @param format Format string, including optional format specifiers
85 @param ... Variables matching format specifiers
87 static void log_printf(const char *format
, ...) {
88 FILE *log
= fopen(LOG_FILE
, "at");
91 va_start(arg
, format
);
92 vfprintf(stderr
, format
, arg
);
96 va_start(arg
, format
);
97 vfprintf(log
, format
, arg
);
104 static void print_message(const char *type
, const char *message
,
105 const char *file
, int line
) {
107 const char *sdlerror
= SDL_GetError(), *t
= get_ctime();
109 log_printf("xuni: %s from %s:%i at %s %s\n SDL: %s\n",
110 type
, file
, line
, t
, message
, sdlerror
);
113 void print_warning(const char *message
, const char *file
, int line
) {
114 print_message("Warning", message
, file
, line
);
117 void settings_error(const char *message
, const char *sfile
, int sline
) {
118 const char *t
= get_ctime();
120 log_printf("xuni: Error in settings file %s:%i at %s %s\n",
121 sfile
, sline
, t
, message
);
124 void fatal_error(const char *message
, const char *file
, int line
) {
125 print_message("Fatal error", message
, file
, line
);