From b7c1af4c35555d552f01b0a74f7e627b5ab3e411 Mon Sep 17 00:00:00 2001 From: eukos Date: Mon, 7 Sep 2015 22:00:45 +0200 Subject: [PATCH] Optimizations and cleanup --- Makefile | 64 +++++++++++----------- engine/host.c | 82 +++++++++++----------------- engine/host_cmd.c | 6 +-- engine/keys.c | 133 +++------------------------------------------- renderer/r_main.c | 14 +---- 5 files changed, 76 insertions(+), 223 deletions(-) diff --git a/Makefile b/Makefile index 484ca0b..a64fd9f 100644 --- a/Makefile +++ b/Makefile @@ -372,49 +372,49 @@ $(BUILDDIR)/cvar.o : $(MOUNT_DIR)/cvar.c $(DO_CC) $(BUILDDIR)/draw.o : $(MOUNT_DIR)/draw.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_edge.o : $(MOUNT_DIR)/../renderer/d_edge.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_fill.o : $(MOUNT_DIR)/../renderer/d_fill.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_init.o : $(MOUNT_DIR)/../renderer/d_init.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_modech.o : $(MOUNT_DIR)/../renderer/d_modech.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_part.o : $(MOUNT_DIR)/../renderer/d_part.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_polyse.o : $(MOUNT_DIR)/../renderer/d_polyse.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_scan.o : $(MOUNT_DIR)/../renderer/d_scan.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_sky.o : $(MOUNT_DIR)/../renderer/d_sky.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_sprite.o : $(MOUNT_DIR)/../renderer/d_sprite.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_surf.o : $(MOUNT_DIR)/../renderer/d_surf.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_vars.o : $(MOUNT_DIR)/../renderer/d_vars.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/d_zpoint.o : $(MOUNT_DIR)/../renderer/d_zpoint.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/host.o : $(MOUNT_DIR)/host.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/host_cmd.o : $(MOUNT_DIR)/host_cmd.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/keys.o : $(MOUNT_DIR)/keys.c $(DO_CC) @@ -423,13 +423,13 @@ $(BUILDDIR)/menu.o : $(MOUNT_DIR)/menu.c $(DO_CC) $(BUILDDIR)/mathlib.o : $(MOUNT_DIR)/mathlib.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/model.o : $(MOUNT_DIR)/model.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/model_common.o :$(MOUNT_DIR)/model_common.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/net_dgrm.o : $(MOUNT_DIR)/../network/net_dgrm.c $(DO_CC) @@ -462,46 +462,46 @@ $(BUILDDIR)/pr_exec.o : $(MOUNT_DIR)/pr_exec.c $(DO_CC) $(BUILDDIR)/r_aclip.o : $(MOUNT_DIR)/../renderer/r_aclip.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_alias.o : $(MOUNT_DIR)/../renderer/r_alias.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_bsp.o : $(MOUNT_DIR)/../renderer/r_bsp.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_light.o : $(MOUNT_DIR)/../renderer/r_light.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_draw.o : $(MOUNT_DIR)/../renderer/r_draw.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_efrag.o : $(MOUNT_DIR)/../renderer/r_efrag.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_edge.o : $(MOUNT_DIR)/../renderer/r_edge.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_misc.o : $(MOUNT_DIR)/../renderer/r_misc.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_main.o : $(MOUNT_DIR)/../renderer/r_main.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_sky.o : $(MOUNT_DIR)/../renderer/r_sky.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_sprite.o : $(MOUNT_DIR)/../renderer/r_sprite.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_surf.o : $(MOUNT_DIR)/../renderer/r_surf.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_part.o : $(MOUNT_DIR)/../renderer/r_part.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/r_vars.o : $(MOUNT_DIR)/../renderer/r_vars.c - $(DO_CC) + $(DO_CC) -O2 $(BUILDDIR)/screen.o : $(MOUNT_DIR)/screen.c $(DO_CC) diff --git a/engine/host.c b/engine/host.c index 67ea65b..63c95a0 100644 --- a/engine/host.c +++ b/engine/host.c @@ -985,15 +985,15 @@ void Host_InitVCR (quakeparms_t *parms) if (COM_CheckParm("-playback")) { if (com_argc != 2) - Sys_Error("No other parameters allowed with -playback\n"); + Sys_Error("[ERROR] No other parameters allowed with -playback\n"); Sys_FileOpenRead("engine.vcr", &vcrFile); if (vcrFile == -1) - Sys_Error("playback file not found\n"); + Sys_Error("[ERROR] Playback file not found\n"); Sys_FileRead (vcrFile, &i, sizeof(int)); if (i != VCR_SIGNATURE) - Sys_Error("Invalid signature in vcr file\n"); + Sys_Error("[ERROR] Invalid signature in vcr file\n"); Sys_FileRead (vcrFile, &com_argc, sizeof(int)); com_argv = malloc(com_argc * sizeof(char *)); @@ -1036,20 +1036,14 @@ void Host_InitVCR (quakeparms_t *parms) } - -// 2001-09-18 New cvar system by Maddes (Init) start void COM_Init_Cvars (); void Con_Init_Cvars (); -//TW void Key_Init_Cvars (); void Mod_Init_Cvars(); void Chase_Init_Cvars (); void SCR_Init_Cvars (); void VID_Init_Cvars(); void V_Init_Cvars(); -//TW void M_Init_Cvars (); void R_Init_Cvars (); -void R_Presets (); -//TW void Sbar_Init_Cvars (); void CL_Init_Cvars (); void S_Init_Cvars (); void IN_Init_Cvars (); @@ -1113,10 +1107,10 @@ void Bot_Init (void); #endif void ColormapForceLoad (void) { - loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes + loadedfile_t *fileinfo; fileinfo = COM_LoadHunkFile ("gfx/colormap.lmp"); if (!fileinfo) - Sys_Error ("Couldn't load gfx/colormap.lmp"); + Sys_Error ("[ERROR] Couldn't load gfx/colormap.lmp"); host_colormap = fileinfo->data; } @@ -1128,14 +1122,14 @@ int translate_spr; byte colorthis; void Palette_Init (void) { - loadedfile_t *fileinfo; // 2001-09-12 Returning information about loaded file by Maddes + loadedfile_t *fileinfo; overbrights = 1; #ifdef EGAHACK fileinfo = COM_LoadHunkFile ("gfx/palette.lmp"); if (!fileinfo) - Sys_Error ("Couldn't load gfx/palette.lmp"); + Sys_Error ("[ERROR] Couldn't load gfx/palette.lmp"); host_basepal = fileinfo->data; host_origpal = fileinfo->data; host_otherpal = fileinfo->data; @@ -1146,7 +1140,7 @@ void Palette_Init (void) fileinfo = COM_LoadHunkFile ("gfx/palette.lmp"); if (!fileinfo) - Sys_Error ("Couldn't load gfx/palette.lmp"); + Sys_Error ("[ERROR] Couldn't load gfx/palette.lmp"); host_basepal = fileinfo->data; host_otherpal = fileinfo->data; @@ -1162,7 +1156,7 @@ void Palette_Init (void) fileinfo = COM_LoadHunkFile ("gfx/colormap.lmp"); if (!fileinfo) - Sys_Error ("Couldnf't load gfx/colormap.lmp"); + Sys_Error ("[ERROR] Couldnf't load gfx/colormap.lmp"); host_colormap = fileinfo->data; fileinfo = COM_LoadHunkFile ("gfx/colormap.lmp"); @@ -1249,29 +1243,27 @@ void Host_Init (quakeparms_t *parms) com_argc = parms->argc; com_argv = parms->argv; + printf ("======= Launching Engine ========\n\n"); Memory_Init (parms->membase, parms->memsize); + Cvar_Init (); Cbuf_Init (); Cmd_Init (); - - COM_Init_Cvars (); // initialize all filesystem related variables - Con_Init_Cvars (); // initialize all console related cvars -//TW Key_Init_Cvars (); // initialize all key related cvars - Mod_Init_Cvars(); // initialize all model related cvars - Chase_Init_Cvars (); // initialize all chase camera related cvars - SCR_Init_Cvars (); // initialize all screen(?) related cvars - VID_Init_Cvars(); // initialize all video related cvars - V_Init_Cvars(); // initialize all view related cvars -//TW M_Init_Cvars (); // initialize all menu related cvars - R_Init_Cvars (); // initialize all rendering system related cvars -//TW Sbar_Init_Cvars (); // initialize all statusbar related cvars - CL_Init_Cvars (); // initialize all cl_* related cvars - S_Init_Cvars (); // initialize all sound system related cvars - IN_Init_Cvars (); // initialize all input related cvars - NET_Init_Cvars (); // initialize all net related cvars - Host_InitLocal_Cvars (); // initialize all local host related cvars - PR_Init_Cvars(); // initialize all pr_* related cvars - NVS_Init_Cvars (); // 2000-04-30 NVS COMMON by Maddes + COM_Init_Cvars (); // initialize all filesystem related variables + Con_Init_Cvars (); // initialize all console related cvars + Mod_Init_Cvars(); // initialize all model related cvars + Chase_Init_Cvars (); // initialize all chase camera related cvars + SCR_Init_Cvars (); // initialize all screen(?) related cvars + VID_Init_Cvars(); // initialize all video related cvars + V_Init_Cvars(); // initialize all view related cvars + R_Init_Cvars (); // initialize all rendering system related cvars + CL_Init_Cvars (); // initialize all cl_* related cvars + S_Init_Cvars (); // initialize all sound system related cvars + IN_Init_Cvars (); // initialize all input related cvars + NET_Init_Cvars (); // initialize all net related cvars + Host_InitLocal_Cvars (); // initialize all local host related cvars + PR_Init_Cvars(); // initialize all pr_* related cvars + NVS_Init_Cvars (); // 2000-04-30 NVS COMMON by Maddes NVS_Init_Server_Cvars (); NVS_Init_Client_Cvars (); @@ -1287,12 +1279,12 @@ void Host_Init (quakeparms_t *parms) M_Init (); PR_Init (); Mod_Init (); -#ifndef BENCH NET_Init (); -#endif + SV_Init (); + #ifdef GLOBOT - Bot_Init (); + Bot_Init (); #endif NVS_Init (); NVS_Init_Server (); @@ -1318,11 +1310,7 @@ void Host_Init (quakeparms_t *parms) SCR_Init (); R_Init (); #ifndef _WIN32 - // on Win32, sound initialization has to come before video initialization, so we - // can put up a popup if the sound hardware is in use S_Init (); -#else - #endif @@ -1332,22 +1320,18 @@ void Host_Init (quakeparms_t *parms) CL_Init (); #if defined(_WIN32) || defined(DOSQUAKE) // on non dos/win32, mouse comes before video for security reasons - IN_Init (); + IN_Init (); #endif } -// Cbuf_InsertText ("exec default.cfg\n"); -// Cbuf_InsertText ("exec config.cfg\n"); Cbuf_InsertText ("exec ngunix.rc\n"); - Cbuf_InsertText ("exec quake.rc\n"); Hunk_AllocName (0, "-HOST_HUNKLEVEL-"); host_hunklevel = Hunk_LowMark (); - R_Presets(); host_initialized = true; - Sys_Printf ("\n\n========Game Initialized=========\n\n"); + Sys_Printf ("\n\n======= Game Initialized ========\n\n"); } @@ -1365,16 +1349,14 @@ void Host_Shutdown(void) if (isdown) { - printf ("recursive shutdown\n"); + printf ("[HOST] Recursive shutdown\n"); return; } isdown = true; // keep Con_Printf from trying to update the screen scr_disabled_for_loading = true; -#ifndef BENCH Host_WriteConfiguration (); -#endif Music_Shutdown (); NET_Shutdown (); S_Shutdown(); diff --git a/engine/host_cmd.c b/engine/host_cmd.c index 419505a..2dc6f75 100644 --- a/engine/host_cmd.c +++ b/engine/host_cmd.c @@ -188,7 +188,7 @@ void Host_Status_f (void) print ("================\n"); print ("Host: %s\n", hostname->string); // 2001-09-18 New cvar system by Maddes - print ("Version: %s\n", VERSION); // 2001-10-25 QIP version in the console background by Maddes + print ("Version: %4.2f\n", VERSION); // 2001-10-25 QIP version in the console background by Maddes if (tcpipAvailable) print ("TCP/IP: %s\n", my_tcpip_address); if (ipxAvailable) @@ -1377,12 +1377,12 @@ void Host_Version_f (void) if (cmd_source == src_command) { print = Con_Printf; - print ("[INFO] Version: %s\n", VERSION); + print ("[INFO] Version: %4.2f\n", VERSION); } else { print = SV_ClientPrintf; - print ("[INFO] Server version: %s\n", VERSION); + print ("[INFO] Server version: %4.2f\n", VERSION); } print ("[INFO] Exe: "__TIME__" "__DATE__"\n"); diff --git a/engine/keys.c b/engine/keys.c index 836cd51..873bdda 100644 --- a/engine/keys.c +++ b/engine/keys.c @@ -615,14 +615,14 @@ void Key_Unbind_f (void) if (Cmd_Argc() != 2) { - Con_Printf ("unbind : remove commands from a key\n"); + Con_Printf ("[CMD] unbind : remove commands from a key\n"); return; } b = Key_StringToKeynum (Cmd_Argv(1)); if (b==-1) { - Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + Con_Printf ("[INPUT] \"%s\" isn't a valid key\n", Cmd_Argv(1)); return; } @@ -653,22 +653,22 @@ void Key_Bind_f (void) if (c != 2 && c != 3) { - Con_Printf ("bind [command] : attach a command to a key\n"); + Con_Printf ("[CMD] bind [command] : attach a command to a key\n"); return; } b = Key_StringToKeynum (Cmd_Argv(1)); if (b==-1) { - Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); + Con_Printf ("[INPUT] \"%s\" isn't a valid key\n", Cmd_Argv(1)); return; } if (c == 2) { if (keybindings[b]) - Con_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b] ); + Con_Printf ("[INPUT] \"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b] ); else - Con_Printf ("\"%s\" is not bound\n", Cmd_Argv(1) ); + Con_Printf ("[INPUT] \"%s\" is not bound\n", Cmd_Argv(1) ); return; } @@ -684,120 +684,6 @@ void Key_Bind_f (void) Key_SetBinding (b, cmd); } - - -/* -=================== -Key_SetBinding2 -=================== -*/ -void Key_SetBinding2 (int keynum, char *binding) -{ - char *new; - int l; - - if (keynum == -1) - return; - -// free old bindings - if (keybindings[keynum]) - { - Z_Free (mainzone, keybindings[keynum]); // 2001-09-20 Enhanced zone handling by Maddes - keybindings[keynum] = NULL; - } - -// allocate memory for new binding - l = strlen (binding); - new = Z_Malloc (mainzone, l+1); // 2001-09-20 Enhanced zone handling by Maddes - strcpy (new, binding); - new[l] = 0; - keybindings[keynum] = new; -} - -/* -=================== -Key_Unbind2_f -=================== -*/ -void Key_Unbind2_f (void) -{ - int b; - - if (Cmd_Argc() != 2) - { - Con_Printf ("unbind : remove commands from a key\n"); - return; - } - - b = Key_StringToKeynum (Cmd_Argv(1)); - if (b==-1) - { - Con_Printf ("\"%s\" isn't a valid key\n", Cmd_Argv(1)); - return; - } - - Key_SetBinding (b, ""); -} - -void Key_Unbindall2_f (void) -{ - int i; - - for (i=0 ; i<256 ; i++) - if (keybindings[i]) - Key_SetBinding (i, ""); -} - - - -/* -=================== -Key_Bind2_f -leilei - splitscreen hack -Binds a key for the second client in a splitscreen environment -(for separate keyboards or joypads) -=================== -*/ -void Key_Bind2_f (void) -{ - int i, c, b; - char cmd[1024]; - - c = Cmd_Argc(); - // the messages are wittier, just because we're not done. - if (c != 2 && c != 3) - { - Con_Printf ("bind2 [command] : attach a command to a key for the second player. which is highly experimental, should not be taken seriously, and other warnings here.\n"); - return; - } - b = Key_StringToKeynum (Cmd_Argv(1)); - if (b==-1) - { - Con_Printf ("\"%s\" isn't a valid key for the second player. Too bad. Try again. :(\n", Cmd_Argv(1)); - return; - } - - if (c == 2) - { - if (keybindings[b]) - Con_Printf ("\"%s\" = \"%s\"\n", Cmd_Argv(1), keybindings[b] ); - else - Con_Printf ("\"%s\" is not bound, so bind it!!!\n", Cmd_Argv(1) ); - return; - } - -// copy the rest of the command line - cmd[0] = 0; // start out with a null string - for (i=2 ; i< c ; i++) - { - if (i > 2) - strcat (cmd, " "); - strcat (cmd, Cmd_Argv(i)); - } - - Key_SetBinding2 (b, cmd); -} - /* ============ Key_WriteBindings @@ -897,11 +783,6 @@ void Key_Init (void) Cmd_AddCommand ("bind",Key_Bind_f); Cmd_AddCommand ("unbind",Key_Unbind_f); Cmd_AddCommand ("unbindall",Key_Unbindall_f); - - // leilei - splitscreen hack - Cmd_AddCommand ("bind2",Key_Bind2_f); - Cmd_AddCommand ("unbind2",Key_Unbind2_f); - } /* @@ -939,7 +820,7 @@ void Key_Event (int key, qboolean down) } if (key >= 200 && !keybindings[key]) - Con_Printf ("%s is unbound, hit F4 to set.\n", Key_KeynumToString (key) ); + Con_Printf ("[INPUT] %s is unbound\n", Key_KeynumToString (key) ); } if (key == K_SHIFT) diff --git a/renderer/r_main.c b/renderer/r_main.c index a3a8bbe..e471a19 100644 --- a/renderer/r_main.c +++ b/renderer/r_main.c @@ -389,17 +389,6 @@ if (COM_CheckParm("-old640400")) D_Init (); } - -void R_Presets (void) -{ - if (COM_CheckParm ("-glsuck")){ -// Cvar_SetValue (r_overbrightBits, 0); -// Cvar_SetValue (r_fullbrights, 0); -// Cvar_SetValue (r_alphashift, 1); -// Cvar_SetValue (r_filter, 1); - } - -}; /* =============== R_NewMap @@ -469,8 +458,9 @@ void R_NewMap (void) r_dowarpold = false; r_viewchanged = false; #ifdef PASSAGES -CreatePassages (); + CreatePassages (); #endif + #ifdef INTERPOL7 R_FinalizeAliasVerts (); #endif