From a79a6e75633c38c64c7f0460f01216bf80703ad3 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Sat, 21 Mar 2020 19:07:45 +0300 Subject: [PATCH] move error.c into system layer --- src/error.c | 81 -------------------------------------------------- src/menu.c | 2 ++ src/player.c | 9 ++++-- src/sdl/main.c | 62 +++++++++++++++++++++++++++++++------- 4 files changed, 59 insertions(+), 95 deletions(-) delete mode 100644 src/error.c diff --git a/src/error.c b/src/error.c deleted file mode 100644 index 0ba3d3b..0000000 --- a/src/error.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) Prikol Software 1996-1997 - Copyright (C) Aleksey Volynskov 1996-1997 - Copyright (C) 2011 - - This file is part of the Doom2D:Rembo project. - - Doom2D:Rembo is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 as - published by the Free Software Foundation. - - Doom2D:Rembo is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see or - write to the Free Software Foundation, Inc., - 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "glob.h" -#include -#include -#include -#include -#include "sound.h" -#include "render.h" -#include "memory.h" -#include "error.h" -#include "config.h" -#include "music.h" - -void logo (const char *s, ...) { - va_list ap; - va_start(ap, s); - vprintf(s, ap); - va_end(ap); - fflush(stdout); -} - -void logo_gas (int cur, int all) { - // stub -} - -static void close_all (void) { - S_done(); - S_donemusic(); - M_shutdown(); - R_done(); -} - -void ERR_failinit (char *s, ...) { - va_list ap; - //close_all(); - va_start(ap, s); - vprintf(s, ap); - va_end(ap); - puts(""); - exit(1); -} - -void ERR_fatal (char *s,...) { - va_list ap; - close_all(); - puts("\nКРИТИЧЕСКАЯ ОШИБКА:"); - va_start(ap, s); - vprintf(s, ap); - va_end(ap); - puts(""); - exit(2); -} - -void ERR_quit (void) { - puts("Спасибо за то, что вы играли в Операцию \"Смятка\"!"); - //F_loadres(F_getresid("ENDOOM"),p,0,4000); - close_all(); - CFG_save(); - exit(0); -} diff --git a/src/menu.c b/src/menu.c index 3d797fc..5a59b87 100644 --- a/src/menu.c +++ b/src/menu.c @@ -602,4 +602,6 @@ void GM_init (void) { msnd4=Z_getsnd("SWTCHX"); msnd5=Z_getsnd("SUDI"); msnd6=Z_getsnd("TUDI"); + F_loadmus("MENU"); + S_startmusic(0); } diff --git a/src/player.c b/src/player.c index 4ade170..ecb8b9e 100644 --- a/src/player.c +++ b/src/player.c @@ -297,9 +297,12 @@ int PL_isdead (player_t *p) { } void PL_init (void) { - p_immortal=0; - PL_JUMP=10;PL_RUN=8; - aitime=0; + pl1.id = -1; + pl2.id = -2; + p_immortal = 0; + PL_JUMP = 10; + PL_RUN = 8; + aitime = 0; } void PL_alloc(void) { diff --git a/src/sdl/main.c b/src/sdl/main.c index 3aaad80..ef757fc 100644 --- a/src/sdl/main.c +++ b/src/sdl/main.c @@ -21,25 +21,69 @@ */ #include -#include // srand +#include +#include +#include // srand exit #include // strcasecmp #include "input.h" #include "my.h" // fexists #include "player.h" // pl1 pl2 -#include "menu.h" // GM_init G_keyf +#include "menu.h" // G_keyf #include "error.h" // logo #include "files.h" // F_startup F_addwad F_initwads F_allocres -#include "config.h" // CFG_args CFG_load +#include "config.h" // CFG_args CFG_load CFG_save #include "memory.h" // M_startup -#include "game.h" // G_Init G_act +#include "game.h" // G_init G_act #include "sound.h" // S_init S_done #include "music.h" // S_initmusic S_updatemusic S_donemusic #include "render.h" // R_init R_draw R_done static int quit = 0; +void logo (const char *s, ...) { + va_list ap; + va_start(ap, s); + vprintf(s, ap); + va_end(ap); + fflush(stdout); +} + +void logo_gas (int cur, int all) { + // stub +} + +void ERR_failinit (char *s, ...) { + va_list ap; + va_start(ap, s); + vprintf(s, ap); + va_end(ap); + puts(""); + exit(1); +} + +void ERR_fatal (char *s, ...) { + va_list ap; + R_done(); + S_done(); + S_donemusic(); + M_shutdown(); + SDL_Quit(); + puts("\nКРИТИЧЕСКАЯ ОШИБКА:"); + va_start(ap, s); + vprintf(s, ap); + va_end(ap); + puts(""); + exit(1); +} + +void ERR_quit (void) { + puts("Спасибо за то, что вы играли в Операцию \"Смятка\"!"); + //F_loadres(F_getresid("ENDOOM"),p,0,4000); + quit = 1; +} + static int sdl_to_key (int code) { switch (code) { case SDLK_0: return KEY_0; @@ -179,8 +223,6 @@ int SDL_main (int argc, char *argv[]) { return 1; } SDL_WM_SetCaption("Doom 2D v1.351", "Doom 2D"); - pl1.id = -1; // TODO move to generic code - pl2.id = -2; // TODO move to generic code // Player 1 defaults pl1.ku = KEY_KP_8; pl1.kd = KEY_KP_5; @@ -218,13 +260,10 @@ int SDL_main (int argc, char *argv[]) { F_initwads(); M_startup(); F_allocres(); - G_init(); S_init(); S_initmusic(); R_init(); - GM_init(); // TODO move to game - F_loadmus("MENU"); // TODO move to menu - S_startmusic(0); // TODO move to menu + G_init(); ticks = SDL_GetTicks(); while (!quit) { poll_events(&G_keyf); @@ -236,9 +275,10 @@ int SDL_main (int argc, char *argv[]) { } R_draw(); } + CFG_save(); R_done(); - S_donemusic(); S_done(); + S_donemusic(); M_shutdown(); SDL_Quit(); return 0; -- 2.29.2