From 5f05ce9df0205d5408fdabe91b33ba2d57008800 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 7 Jun 2022 12:46:27 +0200 Subject: [PATCH 01/48] (snd_dma.c) Remove unnecessary console commands --- common/snd_dma.c | 93 ++++-------------------------------------------- 1 file changed, 6 insertions(+), 87 deletions(-) diff --git a/common/snd_dma.c b/common/snd_dma.c index 972d930a..cd8965a7 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -42,7 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* FIXME - reorder to remove forward decls? */ static void S_Play(void); static void S_PlayVol(void); -static void S_SoundList(void); static void S_StopAllSoundsC(void); /* @@ -85,39 +84,12 @@ static int sound_started = 0; cvar_t bgmvolume = { "bgmvolume", "1", true }; cvar_t sfxvolume = { "volume", "0.7", true }; -static cvar_t nosound = { "nosound", "0" }; static cvar_t precache = { "precache", "1" }; static cvar_t ambient_level = { "ambient_level", "0.3" }; static cvar_t ambient_fade = { "ambient_fade", "100" }; static cvar_t snd_noextraupdate = { "snd_noextraupdate", "0" }; static cvar_t _snd_mixahead = { "_snd_mixahead", "0.1", true }; -/* - * User-setable variables - * - * Fake dma is a synchronous faking of the DMA progress used for isolating - * performance in the renderer. - */ - -static qboolean fakedma = false; - -static void S_SoundInfo_f(void) -{ - if (!sound_started || !shm) { - Con_Printf("sound system not started\n"); - return; - } - - Con_Printf("%5d channels (%s)\n", "stereo"); - Con_Printf("%5d samples\n", shm->samples); - Con_Printf("%5d samplepos\n", shm->samplepos); - Con_Printf("%5d samplebits\n", shm->samplebits); - Con_Printf("%5d submission_chunk\n", shm->submission_chunk); - Con_Printf("%5d speed\n", shm->speed); - Con_Printf("%p dma buffer\n", shm->buffer); - Con_Printf("%5d total_channels\n", total_channels); -} - static void SND_Callback_sfxvolume (cvar_t *var) { SND_InitScaletable (); @@ -135,15 +107,10 @@ S_Startup(void) if (!snd_initialized) return; - if (!fakedma) + if (!SNDDMA_Init(&sn)) { - int rc = SNDDMA_Init(&sn); - if (!rc) - { - Con_Printf("%s: SNDDMA_Init failed.\n", __func__); - sound_started = 0; - return; - } + sound_started = 0; + return; } sound_started = 1; } @@ -159,18 +126,10 @@ S_Init(void) { Con_Printf("\nSound Initialization\n"); - if (COM_CheckParm("-nosound")) - return; - if (COM_CheckParm("-simsound")) - fakedma = true; - Cmd_AddCommand("play", S_Play); Cmd_AddCommand("playvol", S_PlayVol); Cmd_AddCommand("stopsound", S_StopAllSoundsC); - Cmd_AddCommand("soundlist", S_SoundList); - Cmd_AddCommand("soundinfo", S_SoundInfo_f); - Cvar_RegisterVariable(&nosound); Cvar_RegisterVariable(&sfxvolume); Cvar_RegisterVariable(&precache); Cvar_RegisterVariable(&bgmvolume); @@ -188,19 +147,7 @@ S_Init(void) SND_InitScaletable(); known_sfx = (sfx_t*)Hunk_AllocName(MAX_SFX * sizeof(sfx_t), "sfx_t"); - num_sfx = 0; - - /* create a piece of DMA memory */ - if (fakedma) { - shm = (volatile dma_t*)(void *)Hunk_AllocName(sizeof(*shm), "shm"); - shm->samplebits = 16; - shm->speed = 44100; - shm->channels = 2; - shm->samples = 32768; - shm->samplepos = 0; - shm->submission_chunk = 1; - shm->buffer = (unsigned char *volatile)Hunk_AllocName(1 << 16, "shmbuf"); - } + num_sfx = 0; if (sound_started) Con_Printf("Sound sampling rate: %i\n", shm->speed); @@ -232,8 +179,7 @@ S_Shutdown(void) shm = 0; sound_started = 0; - if (!fakedma) - SNDDMA_Shutdown(); + SNDDMA_Shutdown(); } /* @@ -296,7 +242,7 @@ S_PrecacheSound(const char *name) { sfx_t *sfx; - if (!sound_started || nosound.value) + if (!sound_started) return NULL; sfx = S_FindName(name); @@ -421,8 +367,6 @@ S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, return; if (!sfx) return; - if (nosound.value) - return; vol = fvol * 255; @@ -889,35 +833,10 @@ static void S_PlayVol(void) } } -static void S_SoundList(void) -{ - sfx_t *sfx; - int i, size; - int total = 0; - - for (sfx = known_sfx, i = 0; i < num_sfx; i++, sfx++) - { - sfxcache_t *sc = (sfxcache_t*)Cache_Check(&sfx->cache); - if (!sc) - continue; - size = sc->length * sc->width * (sc->stereo + 1); - total += size; - if (sc->loopstart >= 0) - Con_Printf("L"); - else - Con_Printf(" "); - Con_Printf("(%2db) %6i : %s\n", sc->width * 8, size, sfx->name); - } - Con_Printf("Total resident: %i\n", total); -} - - void S_LocalSound(const char *sound) { sfx_t *sfx; - if (nosound.value) - return; if (!sound_started) return; From 8685a8d0120599757c915a356fb202a07900e230 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 7 Jun 2022 23:33:33 +0200 Subject: [PATCH 02/48] * Get rid of various console commands that will never be used for the libretro port: - cl_shownet - developer - entities - mcache - host_framerate - host_speeds - maplist - d_subdiv16 - hunk * Get rid of PARANOID ifdefs - never used and speed-sapping according to own internal comments * Keys - get rid of console autocompletion - will never be used * Get rid of useless window_visible - libretro port doesn't need to have a concept of this * Get rid of useless onscreen logging functionality like R_TimeRefresh, R_TimeGraph, R_ZGraph, etc. * Get rid of Con_DPrintf - only ever used when developer switch is set, which will never be the case for the libretro port * Get rid of debuglog --- QW/client/cl_ents.c | 11 +-- QW/client/cl_main.c | 36 -------- QW/client/cl_parse.c | 38 +-------- QW/client/cl_pred.c | 1 - QW/client/client.h | 1 - QW/client/quakedef.h | 3 - QW/client/skin.c | 1 - QW/common/net_wins.c | 9 +- QW/common/pmove.c | 1 - QW/common/pmovetst.c | 8 -- QW/server/qwsvdef.h | 4 - QW/server/sv_init.c | 3 - QW/server/sv_main.c | 50 ++--------- QW/server/sv_send.c | 26 ------ QW/server/sv_user.c | 11 +-- QW/server/sys_unix.c | 37 --------- common/bgmusic.c | 3 - common/cd_common.c | 39 +-------- common/cd_linux.c | 67 +++++---------- common/cl_main.c | 51 +----------- common/cl_parse.c | 89 +------------------- common/client.h | 1 - common/cmd.c | 4 +- common/common.c | 103 ++--------------------- common/common.h | 2 - common/console.c | 192 ------------------------------------------- common/console.h | 2 - common/cvar.c | 11 --- common/d_init.c | 2 - common/draw.c | 12 +-- common/drawhulls.c | 2 - common/host.c | 58 ++----------- common/host.h | 1 - common/keys.c | 190 ++---------------------------------------- common/libretro.c | 11 --- common/mathlib.c | 13 --- common/model.c | 16 ---- common/model.h | 1 - common/net_dgrm.c | 22 +---- common/net_main.c | 3 - common/net_wins.c | 4 +- common/pr_cmds.c | 5 +- common/pr_edict.c | 3 - common/pr_exec.c | 12 --- common/quakedef.h | 2 - common/r_alias.c | 20 ++--- common/r_local.h | 9 -- common/r_main.c | 33 -------- common/r_misc.c | 115 -------------------------- common/render.h | 5 -- common/snd_codec.c | 11 +-- common/snd_dma.c | 8 +- common/snd_flac.c | 7 +- common/snd_mem.c | 2 - common/snd_mikmod.c | 6 -- common/snd_modplug.c | 3 - common/snd_mp3.c | 20 +---- common/snd_mpg123.c | 2 +- common/snd_umx.c | 14 +--- common/sv_main.c | 19 +---- common/sv_phys.c | 6 -- common/sv_user.c | 2 - common/sys.h | 11 --- common/world.c | 9 -- common/zone.c | 131 ----------------------------- common/zone.h | 2 - 66 files changed, 95 insertions(+), 1501 deletions(-) diff --git a/QW/client/cl_ents.c b/QW/client/cl_ents.c index 4299a166..1e13fd7b 100644 --- a/QW/client/cl_ents.c +++ b/QW/client/cl_ents.c @@ -231,8 +231,6 @@ FlushEntityPacket(void) int word; entity_state_t olde, newe; - Con_DPrintf("FlushEntityPacket\n"); - memset(&olde, 0, sizeof(olde)); cl.validsequence = 0; // can't render a frame @@ -274,12 +272,9 @@ CL_ParsePacketEntities(qboolean delta) cl.frames[newpacket].invalid = false; if (delta) { - from = MSG_ReadByte(); + from = MSG_ReadByte(); oldpacket = cl.frames[newpacket].delta_sequence; - - if ((from & UPDATE_MASK) != (oldpacket & UPDATE_MASK)) - Con_DPrintf("WARNING: from mismatch\n"); } else oldpacket = -1; @@ -851,13 +846,11 @@ CL_LinkPlayers(void) if (msec <= 0 || (!cl_predict_players.value && !cl_predict_players2.value)) { VectorCopy(state->origin, ent->origin); -//Con_DPrintf ("nopredict\n"); } else { // predict players movement if (msec > 255) msec = 255; state->command.msec = msec; -//Con_DPrintf ("predict: %i\n", msec); oldphysent = pmove.numphysent; CL_SetSolidPlayers(j); @@ -971,13 +964,11 @@ CL_SetUpPlayerPrediction(qboolean dopred) (!cl_predict_players.value && !cl_predict_players2.value) || !dopred) { VectorCopy(state->origin, pplayer->origin); - //Con_DPrintf ("nopredict\n"); } else { // predict players movement if (msec > 255) msec = 255; state->command.msec = msec; - //Con_DPrintf ("predict: %i\n", msec); CL_PredictUsercmd(state, &exact, &state->command, false); VectorCopy(exact.origin, pplayer->origin); diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index a29c1a8f..0efa84a7 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -75,8 +75,6 @@ cvar_t rcon_address = { "rcon_address", "" }; cvar_t cl_timeout = { "cl_timeout", "60" }; -cvar_t cl_shownet = { "cl_shownet", "0" }; // can be 0, 1, or 2 - cvar_t cl_sbar = { "cl_sbar", "0", true }; cvar_t cl_hudswap = { "cl_hudswap", "0", true }; cvar_t cl_maxfps = { "cl_maxfps", "0", true }; @@ -150,9 +148,6 @@ byte *host_colormap; netadr_t master_adr; // address of the master server -cvar_t host_speeds = { "host_speeds", "0" }; // set for running times -cvar_t developer = { "developer", "0" }; - int fps_count; static jmp_buf host_abort; @@ -372,7 +367,6 @@ CL_ClearState(void) S_StopAllSounds(true); - Con_DPrintf("Clearing memory\n"); D_FlushCaches(); Mod_ClearAll(); if (host_hunklevel) // FIXME: check this... @@ -806,7 +800,6 @@ CL_ConnectionlessPacket(void) c = MSG_ReadByte(); if (!cls.demoplayback) Con_Printf("%s: ", NET_AdrToString(net_from)); -// Con_DPrintf ("%s", net_message.data + 5); if (c == S2C_CONNECTION) { Con_Printf("connection\n"); if (cls.state >= ca_connected) { @@ -935,8 +928,6 @@ CL_ReadPackets(void) // if (!cls.demoplayback && !NET_CompareAdr(net_from, cls.netchan.remote_address)) { - Con_DPrintf("%s:sequenced packet without connection\n", - NET_AdrToString(net_from)); continue; } if (!Netchan_Process(&cls.netchan)) @@ -1062,7 +1053,6 @@ CL_Init(void) // // register our commands // - Cvar_RegisterVariable(&host_speeds); Cvar_RegisterVariable(&cl_warncmd); Cvar_RegisterVariable(&cl_upspeed); Cvar_RegisterVariable(&cl_forwardspeed); @@ -1072,7 +1062,6 @@ CL_Init(void) Cvar_RegisterVariable(&cl_yawspeed); Cvar_RegisterVariable(&cl_pitchspeed); Cvar_RegisterVariable(&cl_anglespeedkey); - Cvar_RegisterVariable(&cl_shownet); Cvar_RegisterVariable(&cl_sbar); Cvar_RegisterVariable(&cl_hudswap); Cvar_RegisterVariable(&cl_maxfps); @@ -1113,10 +1102,6 @@ CL_Init(void) Cvar_RegisterVariable(&msg); Cvar_RegisterVariable(&noaim); - Cvar_RegisterVariable(&developer); - if (COM_CheckParm("-developer")) - Cvar_SetValue("developer", 1); - Cmd_AddCommand("version", CL_Version_f); Cmd_AddCommand("changing", CL_Changing_f); @@ -1152,8 +1137,6 @@ CL_Init(void) Cmd_AddCommand("nextul", CL_NextUpload); Cmd_AddCommand("stopul", CL_StopUpload); - Cmd_AddCommand("mcache", Mod_Print); - // // forward to server commands // @@ -1274,8 +1257,6 @@ Runs all active servers void Host_Frame(float time) { - static double time1 = 0; - static double time2 = 0; float fps; /* something bad happened, or the server disconnected */ @@ -1330,15 +1311,9 @@ Host_Frame(float time) CL_EmitEntities(); // update video - if (host_speeds.value) - time1 = Sys_DoubleTime(); - SCR_UpdateScreen(); CL_RunParticles(); - if (host_speeds.value) - time2 = Sys_DoubleTime(); - /* update audio */ if (cls.state == ca_active) { S_Update(r_origin, vpn, vright, vup); @@ -1348,17 +1323,6 @@ Host_Frame(float time) CDAudio_Update(); - if (host_speeds.value) { - static double time3 = 0; - int pass1 = (time1 - time3) * 1000; - double time4 = Sys_DoubleTime(); - int pass2 = (time2 - time1) * 1000; - int pass3 = (time4 - time2) * 1000; - time3 = time4; - Con_Printf("%3i tot %3i server %3i gfx %3i snd\n", - pass1 + pass2 + pass3, pass1, pass2, pass3); - } - host_framecount++; fps_count++; } diff --git a/QW/client/cl_parse.c b/QW/client/cl_parse.c index e63df51a..9520528f 100644 --- a/QW/client/cl_parse.c +++ b/QW/client/cl_parse.c @@ -339,7 +339,7 @@ CL_RequestNextDownload(void) break; case dl_none: default: - Con_DPrintf("Unknown download type.\n"); + break; } } @@ -473,8 +473,6 @@ CL_NextUpload(void) MSG_WriteByte(&cls.netchan.message, percent); SZ_Write(&cls.netchan.message, buffer, r); - Con_DPrintf("UPLOAD: %6d: %d written\n", upload_pos - r, r); - if (upload_pos != upload_size) return; @@ -495,8 +493,6 @@ CL_StartUpload(byte *data, int size) if (upload_data) free(upload_data); - Con_DPrintf("Upload starting of %d...\n", size); - upload_data = malloc(size); memcpy(upload_data, data, size); upload_size = size; @@ -543,14 +539,11 @@ CL_ParseServerData(void) qboolean cflag = false; int protover; - Con_DPrintf("Serverdata packet received.\n"); -// -// wipe the client_state_t struct -// + // wipe the client_state_t struct CL_ClearState(); -// parse protocol version number -// allow 2.2 and 2.29 demos to play + // parse protocol version number + // allow 2.2 and 2.29 demos to play protover = MSG_ReadLong(); if (protover != PROTOCOL_VERSION && !(cls.demoplayback @@ -1012,8 +1005,6 @@ CL_SetInfo(void) snprintf(key, sizeof(key), "%s", MSG_ReadString()); snprintf(value, sizeof(value), "%s", MSG_ReadString()); - Con_DPrintf("SETINFO %s: %s=%s\n", player->name, key, value); - Info_SetValueForKey(player->userinfo, key, value, MAX_INFO_STRING); CL_ProcessUserInfo(slot, player); @@ -1033,8 +1024,6 @@ CL_ServerInfo(void) snprintf(key, sizeof(key), "%s", MSG_ReadString()); snprintf(value, sizeof(value), "%s", MSG_ReadString()); - Con_DPrintf("SERVERINFO: %s=%s\n", key, value); - Info_SetValueForKey(cl.serverinfo, key, value, MAX_SERVERINFO_STRING); } @@ -1094,13 +1083,6 @@ CL_MuzzleFlash(void) dl->color = dl_colors[DLIGHT_FLASH]; } - -#define SHOWNET(x) \ - do { \ - if(cl_shownet.value == 2) \ - Con_Printf ("%3i:%s\n", msg_readcount - 1, x); \ - } while (0) - /* ===================== CL_ParseServerMessage @@ -1118,15 +1100,6 @@ CL_ParseServerMessage(void) cl.last_servermessage = realtime; CL_ClearProjectiles(); -// -// if recording demos, copy the message out -// - if (cl_shownet.value == 1) - Con_Printf("%i ", net_message.cursize); - else if (cl_shownet.value == 2) - Con_Printf("------------------\n"); - - CL_ParseClientdata(); // @@ -1140,12 +1113,9 @@ CL_ParseServerMessage(void) if (cmd == -1) { msg_readcount++; // so the EOM showner has the right value - SHOWNET("END OF MESSAGE"); break; } - SHOWNET(svc_strings[cmd]); - // other commands switch (cmd) { case svc_nop: diff --git a/QW/client/cl_pred.c b/QW/client/cl_pred.c index 81cfcc85..2f5f75a6 100644 --- a/QW/client/cl_pred.c +++ b/QW/client/cl_pred.c @@ -66,7 +66,6 @@ CL_NudgePosition(void) return; } } - Con_DPrintf("CL_NudgePosition: stuck\n"); } /* diff --git a/QW/client/client.h b/QW/client/client.h index 9f196419..5d9e74bf 100644 --- a/QW/client/client.h +++ b/QW/client/client.h @@ -310,7 +310,6 @@ extern cvar_t cl_pitchspeed; extern cvar_t cl_anglespeedkey; -extern cvar_t cl_shownet; extern cvar_t cl_sbar; extern cvar_t cl_hudswap; diff --git a/QW/client/quakedef.h b/QW/client/quakedef.h index 8e2a1270..f1fd7850 100644 --- a/QW/client/quakedef.h +++ b/QW/client/quakedef.h @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // quakedef.h -- primary header for client -//define PARANOID // speed sapping error checking - #include #include #include @@ -62,7 +60,6 @@ extern qboolean noclip_anglehack; extern quakeparms_t host_parms; extern cvar_t sys_nostdout; -extern cvar_t developer; extern cvar_t password; diff --git a/QW/client/skin.c b/QW/client/skin.c index fba23174..a6b99e9c 100644 --- a/QW/client/skin.c +++ b/QW/client/skin.c @@ -226,7 +226,6 @@ Skin_NextDownload(void) if (cls.state != ca_active) { // get next signon phase MSG_WriteByte(&cls.netchan.message, clc_stringcmd); MSG_WriteStringf(&cls.netchan.message, "begin %i", cl.servercount); - Cache_Report(); // print remaining memory } } diff --git a/QW/common/net_wins.c b/QW/common/net_wins.c index 10daff1f..94cf7d06 100644 --- a/QW/common/net_wins.c +++ b/QW/common/net_wins.c @@ -151,13 +151,10 @@ NET_GetPacket(void) if (err == WSAEWOULDBLOCK) return false; - if (err == WSAECONNRESET) { + if (err == WSAECONNRESET) /* This has happened to me a few times, but I don't know how to reproduce it yet... */ - Con_DPrintf("Warning: Connection reset by peer %s in %s\n", - NET_AdrToString(net_from), __func__); return false; - } if (err == WSAEMSGSIZE) { Con_Printf("Warning: Oversize packet from %s\n", NET_AdrToString(net_from)); @@ -195,9 +192,7 @@ NET_SendPacket(int length, void *data, netadr_t to) return; #ifndef SERVERONLY - if (err == WSAEADDRNOTAVAIL) - Con_DPrintf("%s Warning: %i\n", __func__, err); - else + if (err != WSAEADDRNOTAVAIL) #endif Con_Printf("%s ERROR: %i\n", __func__, err); } diff --git a/QW/common/pmove.c b/QW/common/pmove.c index a0064c3b..5482930f 100644 --- a/QW/common/pmove.c +++ b/QW/common/pmove.c @@ -742,7 +742,6 @@ NudgePosition(void) } } VectorCopy(base, pmove.origin); -// Con_DPrintf ("NudgePosition: stuck\n"); } /* diff --git a/QW/common/pmovetst.c b/QW/common/pmovetst.c index a7a60b9e..6a45458d 100644 --- a/QW/common/pmovetst.c +++ b/QW/common/pmovetst.c @@ -250,13 +250,6 @@ PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, if (!PM_RecursiveHullCheck(hull, child, p1f, midf, p1, mid, trace)) return false; -#ifdef PARANOID - if (PM_HullPointContents(pm_hullmodel, child, mid) == CONTENTS_SOLID) { - Con_Printf("mid PointInHullSolid\n"); - return false; - } -#endif - child = node->children[side ^ 1]; if (PM_HullPointContents(hull, child, mid) != CONTENTS_SOLID) /* go past the node */ @@ -282,7 +275,6 @@ PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, if (frac < 0) { trace->fraction = midf; VectorCopy(mid, trace->endpos); - Con_DPrintf("backup past 0\n"); return false; } midf = p1f + (p2f - p1f) * frac; diff --git a/QW/server/qwsvdef.h b/QW/server/qwsvdef.h index 31107a7b..d47592d1 100644 --- a/QW/server/qwsvdef.h +++ b/QW/server/qwsvdef.h @@ -23,8 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // quakedef.h -- primary header for server -//define PARANOID // speed sapping error checking - #include #include #include @@ -57,8 +55,6 @@ typedef struct { // extern quakeparms_t host_parms; -extern cvar_t developer; - extern qboolean host_initialized; // true if into command execution extern double host_frametime; extern double realtime; // not bounded in any way, changed at diff --git a/QW/server/sv_init.c b/QW/server/sv_init.c index 2fc4a3fd..d4566aff 100644 --- a/QW/server/sv_init.c +++ b/QW/server/sv_init.c @@ -276,8 +276,6 @@ SV_SpawnServer(const char *server) edict_t *ent; int i; - Con_DPrintf("SpawnServer: %s\n", server); - SV_SaveSpawnparms(); svs.spawncount++; // any partially connected client will be @@ -397,5 +395,4 @@ SV_SpawnServer(const char *server) sv.signon_buffer_size[sv.num_signon_buffers - 1] = sv.signon.cursize; Info_SetValueForKey(svs.info, "map", sv.name, MAX_SERVERINFO_STRING); - Con_DPrintf("Server spawned.\n"); } diff --git a/QW/server/sv_main.c b/QW/server/sv_main.c index bb88c9f6..1b265537 100644 --- a/QW/server/sv_main.c +++ b/QW/server/sv_main.c @@ -51,8 +51,6 @@ client_t *host_client; // current client cvar_t sv_mintic = { "sv_mintic", "0.03" }; // bound the size of the cvar_t sv_maxtic = { "sv_maxtic", "0.1" }; // physics time tic -cvar_t developer = { "developer", "0" }; // show extra messages - static cvar_t timeout = { "timeout", "65" }; // seconds without any message static cvar_t zombietime = { "zombietime", "2" }; // seconds to sink messages // after disconnect @@ -396,9 +394,7 @@ SV_CheckLog static void SV_CheckLog(void) { - sizebuf_t *sz; - - sz = &svs.log[svs.logsequence & 1]; + sizebuf_t *sz = &svs.log[svs.logsequence & 1]; // bump sequence if almost full, or ten minutes have passed and // there is something still sitting there @@ -442,9 +438,6 @@ SVC_Log(void) return; } - Con_DPrintf("sending log %i to %s\n", svs.logsequence - 1, - NET_AdrToString(net_from)); - sprintf(data, "stdlog %i\n", svs.logsequence - 1); strcat(data, (char *)svs.log_buf[((svs.logsequence - 1) & 1)]); @@ -715,8 +708,6 @@ SVC_DirectConnect(void) if (newcl->spectator) Con_Printf("Spectator %s connected\n", newcl->name); - else - Con_DPrintf("Client %s connected\n", newcl->name); newcl->sendinfo = true; } @@ -1119,10 +1110,8 @@ SV_ReadPackets(void) continue; if (cl->netchan.qport != qport) continue; - if (cl->netchan.remote_address.port != net_from.port) { - Con_DPrintf("SV_ReadPackets: fixing up a translated port\n"); + if (cl->netchan.remote_address.port != net_from.port) cl->netchan.remote_address.port = net_from.port; - } if (Netchan_Process(&cl->netchan)) { /* this is a valid, sequenced packet, so process it */ svs.stats.packets++; @@ -1186,26 +1175,6 @@ SV_CheckTimeouts(void) } } -/* -=================== -SV_GetConsoleCommands - -Add them exactly as if they had been typed at the console -=================== -*/ -static void -SV_GetConsoleCommands(void) -{ - char *cmd; - - while (1) { - cmd = Sys_ConsoleInput(); - if (!cmd) - break; - Cbuf_AddText("%s", cmd); - } -} - /* =================== SV_CheckVars @@ -1262,20 +1231,17 @@ SV_Frame(float time) // check timeouts SV_CheckTimeouts(); -// toggle the log buffer if full + // toggle the log buffer if full SV_CheckLog(); -// move autonomous things around if enough time has passed + // move autonomous things around if enough time has passed if (!sv.paused) SV_Physics(); -// get packets + // get packets SV_ReadPackets(); -// check for commands typed to the host - SV_GetConsoleCommands(); - -// process console commands + // process console commands Cbuf_Execute(); SV_CheckVars(); @@ -1361,10 +1327,6 @@ SV_InitLocal(void) Cvar_RegisterVariable(&pausable); - Cvar_RegisterVariable(&developer); - if (COM_CheckParm("-developer")) - Cvar_SetValue("developer", 1); - Cmd_AddCommand("addip", SV_AddIP_f); Cmd_AddCommand("removeip", SV_RemoveIP_f); Cmd_AddCommand("listip", SV_ListIP_f); diff --git a/QW/server/sv_send.c b/QW/server/sv_send.c index c8841e25..702c2205 100644 --- a/QW/server/sv_send.c +++ b/QW/server/sv_send.c @@ -125,29 +125,6 @@ Con_Printf(const char *fmt, ...) fprintf(sv_logfile, "%s", msg); } -/* -================ -Con_DPrintf - -A Con_Printf that only shows up if the "developer" cvar is set -================ -*/ -void -Con_DPrintf(const char *fmt, ...) -{ - va_list argptr; - char msg[MAX_PRINTMSG]; - - if (!developer.value) - return; - - va_start(argptr, fmt); - vsnprintf(msg, sizeof(msg), fmt, argptr); - va_end(argptr); - - Con_Printf("%s", msg); -} - /* ============================================================================= @@ -707,9 +684,6 @@ SV_SendClientMessages(void) if (c->netchan.message.cursize + c->backbuf_size[0] < c->netchan.message.maxsize) { - Con_DPrintf("%s: backbuf %d bytes\n", - c->name, c->backbuf_size[0]); - // it'll fit SZ_Write(&c->netchan.message, c->backbuf_data[0], c->backbuf_size[0]); diff --git a/QW/server/sv_user.c b/QW/server/sv_user.c index a51024d4..01274e3d 100644 --- a/QW/server/sv_user.c +++ b/QW/server/sv_user.c @@ -246,8 +246,6 @@ SV_PreSpawn_f(void) // should be three numbers following containing checksums check = atoi(Cmd_Argv(3)); -// Con_DPrintf("Client check = %d\n", check); - if (sv_mapcheck.value && check != sv.worldmodel->checksum && check != sv.worldmodel->checksum2) { SV_ClientPrintf(host_client, PRINT_HIGH, @@ -603,8 +601,6 @@ SV_NextUpload(void) fwrite(net_message.data + msg_readcount, 1, size, host_client->upload); msg_readcount += size; - Con_DPrintf("UPLOAD: %d received\n", size); - if (percent != 100) { ClientReliableWrite_Begin(host_client, svc_stufftext, 8); ClientReliableWrite_String(host_client, "nextul\n"); @@ -1548,13 +1544,8 @@ SV_ExecuteClientMessage(client_t *cl) MSG_GetReadCount() - checksumIndex - 1, seq_hash); - if (calculatedChecksum != checksum) { - Con_DPrintf - ("Failed command checksum for %s(%d) (%d != %d)\n", - cl->name, cl->netchan.incoming_sequence, checksum, - calculatedChecksum); + if (calculatedChecksum != checksum) return; - } if (!sv.paused) { SV_PreRunCmd(); diff --git a/QW/server/sys_unix.c b/QW/server/sys_unix.c index 6e5d5e5b..64296700 100644 --- a/QW/server/sys_unix.c +++ b/QW/server/sys_unix.c @@ -164,37 +164,6 @@ Sys_Quit(void) static int do_stdin = 1; -/* -================ -Sys_ConsoleInput - -Checks for a complete line of text typed in at the console, then forwards -it to the host command processor -================ -*/ -char * -Sys_ConsoleInput(void) -{ - static char text[256]; - int len; - - if (!stdin_ready || !do_stdin) - return NULL; // the select didn't say it was ready - stdin_ready = false; - - len = read(0, text, sizeof(text)); - if (len == 0) { - // end of file - do_stdin = 0; - return NULL; - } - if (len < 1) - return NULL; - text[len - 1] = 0; // rip off the /n and terminate - - return text; -} - /* ============= Sys_Init @@ -240,12 +209,6 @@ main(int argc, const char *argv[]) parms.basedir = stringify(QBASEDIR); -/* - if (Sys_FileTime ("id1/pak0.pak") != -1) - else - parms.basedir = "/raid/quake/v2"; -*/ - SV_Init(&parms); // run one frame immediately for first heartbeat diff --git a/common/bgmusic.c b/common/bgmusic.c index 58012e77..e2fdb96a 100644 --- a/common/bgmusic.c +++ b/common/bgmusic.c @@ -239,10 +239,7 @@ void BGM_Play (const char *filename) return; if (!filename || !*filename) - { - Con_DPrintf("null music file name\n"); return; - } ext = COM_FileExtension(filename); if (! *ext) /* try all things */ diff --git a/common/cd_common.c b/common/cd_common.c index 6e11985c..450424b2 100644 --- a/common/cd_common.c +++ b/common/cd_common.c @@ -47,8 +47,6 @@ static byte maxTrack; static byte playTrack; static float cdvolume; -static void CDAudio_SetVolume_f(struct cvar_s *var); - static void CDAudio_Eject(void) { @@ -76,39 +74,6 @@ CDAudio_GetAudioDiskInfo(void) return err; } -static void -CDAudio_SetVolume_f(struct cvar_s *var) -{ - qboolean changed = false; - - /* Clamp the volume 0.0 - 1.0 */ - if (var->value > 1.0) { - var->value = 1.0; - changed = true; - } else if (var->value < 0.0) { - var->value = 0.0; - changed = true; - } - - if (cdvolume != var->value) - { - int ret = CDDrv_SetVolume(var->value * 255.0); - if (ret >= 0) - cdvolume = (float)ret / 255.0; - if (var->value != cdvolume) { - var->value = cdvolume; - changed = true; - } - } - - /* - * If the volume we set is not the one originally passed in, we need to set - * the cvar again, so the .string member is updated to match - */ - if (changed) - Cvar_SetValue("bgmvolume", var->value); -} - void CDAudio_Stop(void) { @@ -164,10 +129,8 @@ CDAudio_Play(byte track, qboolean looping) return -1; } track = remap[track]; - if (track < 1 || track > maxTrack) { - Con_DPrintf("CDAudio: Bad track number %u.\n", track); + if (track < 1 || track > maxTrack) return -1; - } if (!CDDrv_IsAudioTrack(track)) { Con_Printf("CDAudio: track %i is not audio\n", track); return -1; diff --git a/common/cd_linux.c b/common/cd_linux.c index 7cceee8b..335aab4e 100644 --- a/common/cd_linux.c +++ b/common/cd_linux.c @@ -52,16 +52,14 @@ static struct cdrom_volctrl drv_vol; void CDDrv_Eject(void) { - if (ioctl(cdfile, CDROMEJECT) == -1) - Con_DPrintf("ioctl cdromeject failed\n"); + if (ioctl(cdfile, CDROMEJECT) == -1) { /* failed */ } } void CDDrv_CloseDoor(void) { - if (ioctl(cdfile, CDROMCLOSETRAY) == -1) - Con_DPrintf("ioctl cdromclosetray failed\n"); + if (ioctl(cdfile, CDROMCLOSETRAY) == -1) { /* failed */ } } int @@ -69,15 +67,11 @@ CDDrv_GetMaxTrack(byte *maxTrack) { struct cdrom_tochdr tochdr; - if (ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1) { - Con_DPrintf("ioctl cdromreadtochdr failed\n"); + if (ioctl(cdfile, CDROMREADTOCHDR, &tochdr) == -1) return -1; - } - if (tochdr.cdth_trk0 < 1) { - Con_DPrintf("CDAudio: no music tracks\n"); + if (tochdr.cdth_trk0 < 1) return -1; - } *maxTrack = tochdr.cdth_trk1; @@ -88,18 +82,15 @@ CDDrv_GetMaxTrack(byte *maxTrack) int CDDrv_IsAudioTrack(byte track) { - int ret = 1; struct cdrom_tocentry entry; - entry.cdte_track = track; + entry.cdte_track = track; entry.cdte_format = CDROM_MSF; - if (ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1) { - ret = 0; - Con_DPrintf("ioctl cdromreadtocentry failed\n"); - } else if (entry.cdte_ctrl == CDROM_DATA_TRACK) - ret = 0; - - return ret; + if (ioctl(cdfile, CDROMREADTOCENTRY, &entry) == -1) + return 0; + else if (entry.cdte_ctrl == CDROM_DATA_TRACK) + return 0; + return 1; } int @@ -112,13 +103,10 @@ CDDrv_PlayTrack(byte track) ti.cdti_ind0 = 1; ti.cdti_ind1 = 99; - if (ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1) { - Con_DPrintf("ioctl cdromplaytrkind failed\n"); + if (ioctl(cdfile, CDROMPLAYTRKIND, &ti) == -1) return 1; - } - if (ioctl(cdfile, CDROMRESUME) == -1) - Con_DPrintf("ioctl cdromresume failed\n"); + if (ioctl(cdfile, CDROMRESUME) == -1) { } return 0; } @@ -127,23 +115,20 @@ CDDrv_PlayTrack(byte track) void CDDrv_Stop(void) { - if (ioctl(cdfile, CDROMSTOP) == -1) - Con_DPrintf("ioctl cdromstop failed (%d)\n", errno); + if (ioctl(cdfile, CDROMSTOP) == -1) { } } void CDDrv_Pause(void) { - if (ioctl(cdfile, CDROMPAUSE) == -1) - Con_DPrintf("ioctl cdrompause failed\n"); + if (ioctl(cdfile, CDROMPAUSE) == -1) { } } void CDDrv_Resume(byte track) { - if (ioctl(cdfile, CDROMRESUME) == -1) - Con_DPrintf("ioctl cdromresume failed\n"); + if (ioctl(cdfile, CDROMRESUME) == -1) { } } int @@ -151,10 +136,8 @@ CDDrv_SetVolume(byte volume) { drv_vol.channel0 = drv_vol.channel2 = drv_vol.channel1 = drv_vol.channel3 = volume; - if (ioctl(cdfile, CDROMVOLCTRL, &drv_vol) == -1 ) { - Con_DPrintf("ioctl CDROMVOLCTRL failed\n"); + if (ioctl(cdfile, CDROMVOLCTRL, &drv_vol) == -1 ) return -1; - } return volume; } @@ -162,18 +145,13 @@ CDDrv_SetVolume(byte volume) int CDDrv_IsPlaying(byte track) { - int err, ret = 1; struct cdrom_subchnl subchnl; - subchnl.cdsc_format = CDROM_MSF; - err = ioctl(cdfile, CDROMSUBCHNL, &subchnl); - if (err == -1) - Con_DPrintf("ioctl cdromsubchnl failed\n"); + if (ioctl(cdfile, CDROMSUBCHNL, &subchnl) == -1) { } else if (subchnl.cdsc_audiostatus != CDROM_AUDIO_PLAY && subchnl.cdsc_audiostatus != CDROM_AUDIO_PAUSED) - ret = 0; - - return ret; + return 0; + return 1; } int @@ -194,8 +172,8 @@ CDDrv_InitDevice(void) } /* get drive's current volume */ - if (ioctl(cdfile, CDROMVOLREAD, &drv_vol_saved) == -1) { - Con_DPrintf("ioctl CDROMVOLREAD failed\n"); + if (ioctl(cdfile, CDROMVOLREAD, &drv_vol_saved) == -1) + { drv_vol_saved.channel0 = drv_vol_saved.channel2 = drv_vol_saved.channel1 = drv_vol_saved.channel3 = 255.0; } @@ -210,8 +188,7 @@ void CDDrv_CloseDevice(void) { /* Restore the saved volume setting */ - if (ioctl(cdfile, CDROMVOLCTRL, &drv_vol_saved) == -1) - Con_DPrintf("ioctl CDROMVOLCTRL failed\n"); + if (ioctl(cdfile, CDROMVOLCTRL, &drv_vol_saved) == -1) { } close(cdfile); cdfile = -1; diff --git a/common/cl_main.c b/common/cl_main.c index 8a7ff222..9cc3e8b1 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -45,7 +45,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. cvar_t cl_name = { "_cl_name", "player", true }; cvar_t cl_color = { "_cl_color", "0", true }; -cvar_t cl_shownet = { "cl_shownet", "0" }; // can be 0, 1, or 2 cvar_t cl_nolerp = { "cl_nolerp", "0" }; cvar_t lookspring = { "lookspring", "0", true }; @@ -165,7 +164,6 @@ void CL_Disconnect(void) if (cls.demorecording) CL_Stop_f(); - Con_DPrintf("Sending clc_disconnect\n"); SZ_Clear(&cls.message); MSG_WriteByte(&cls.message, clc_disconnect); NET_SendUnreliableMessage(cls.netcon, &cls.message); @@ -213,8 +211,6 @@ void CL_EstablishConnection(const char *host) if (!cls.netcon) Host_Error("CL_Connect: connect failed"); - Con_DPrintf("CL_EstablishConnection: connected to %s\n", host); - cls.demonum = -1; // not in the demo loop now cls.state = ca_connected; cls.signon = 0; // need all the signon messages before playing @@ -229,8 +225,6 @@ An svc_signonnum has been received, perform a client side setup */ void CL_SignonReply(void) { - Con_DPrintf("CL_SignonReply: %i\n", cls.signon); - switch (cls.signon) { case 1: @@ -254,7 +248,6 @@ void CL_SignonReply(void) case 3: MSG_WriteByte(&cls.message, clc_stringcmd); MSG_WriteString(&cls.message, "begin"); - Cache_Report(); // print remaining memory // FIXME - this the right place for it? cls.state = ca_firstupdate; @@ -301,32 +294,6 @@ void CL_NextDemo(void) cls.demonum++; } -/* -============== -CL_PrintEntities_f -============== -*/ -void CL_PrintEntities_f(void) -{ - const entity_t *ent; - int i; - - for (i = 0, ent = cl_entities; i < cl.num_entities; i++, ent++) - { - Con_Printf("%3i:", i); - if (!ent->model) - { - Con_Printf("EMPTY\n"); - continue; - } - Con_Printf("%s:%2i (%5.1f,%5.1f,%5.1f) [%5.1f %5.1f %5.1f]\n", - ent->model->name, ent->frame, ent->origin[0], - ent->origin[1], ent->origin[2], ent->angles[0], - ent->angles[1], ent->angles[2]); - } -} - - float dl_colors[4][4] = { { 0.2, 0.1, 0.05, 0.7 }, /* FLASH */ { 0.05, 0.05, 0.3, 0.7 }, /* BLUE */ @@ -393,12 +360,8 @@ void CL_DecayLights(void) { int i; - dlight_t *dl; - float time; - - time = cl.time - cl.oldtime; - - dl = cl_dlights; + float time = cl.time - cl.oldtime; + dlight_t *dl = cl_dlights; for (i = 0; i < MAX_DLIGHTS; i++, dl++) { if (dl->die < cl.time || !dl->radius) @@ -683,9 +646,6 @@ int CL_ReadFromServer(void) CL_ParseServerMessage(); } while (ret && cls.state >= ca_connected); - if (cl_shownet.value) - Con_Printf("\n"); - CL_RelinkEntities(); CL_UpdateTEnts(); @@ -728,10 +688,7 @@ void CL_SendCmd(void) return; /* no message at all */ if (!NET_CanSendMessage(cls.netcon)) - { - Con_DPrintf("CL_WriteToServer: can't send\n"); return; - } if (NET_SendMessage(cls.netcon, &cls.message) == -1) Host_Error("CL_WriteToServer: lost server connection"); @@ -762,7 +719,6 @@ void CL_Init(void) Cvar_RegisterVariable(&cl_yawspeed); Cvar_RegisterVariable(&cl_pitchspeed); Cvar_RegisterVariable(&cl_anglespeedkey); - Cvar_RegisterVariable(&cl_shownet); Cvar_RegisterVariable(&cl_nolerp); Cvar_RegisterVariable(&lookspring); Cvar_RegisterVariable(&lookstrafe); @@ -773,7 +729,6 @@ void CL_Init(void) Cvar_RegisterVariable(&m_forward); Cvar_RegisterVariable(&m_side); - Cmd_AddCommand("entities", CL_PrintEntities_f); Cmd_AddCommand("disconnect", CL_Disconnect_f); Cmd_AddCommand("record", CL_Record_f); Cmd_AddCommand("stop", CL_Stop_f); @@ -781,6 +736,4 @@ void CL_Init(void) Cmd_SetCompletion("playdemo", CL_Demo_Arg_f); Cmd_AddCommand("timedemo", CL_TimeDemo_f); Cmd_SetCompletion("timedemo", CL_Demo_Arg_f); - - Cmd_AddCommand("mcache", Mod_Print); } diff --git a/common/cl_parse.c b/common/cl_parse.c index 458b2145..cdc9ccfb 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -35,66 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "bgmusic.h" #include "sys.h" -static const char *svc_strings[] = { - "svc_bad", - "svc_nop", - "svc_disconnect", - "svc_updatestat", - "svc_version", // [long] server version - "svc_setview", // [short] entity number - "svc_sound", // - "svc_time", // [float] server time - "svc_print", // [string] null terminated string - "svc_stufftext", // [string] stuffed into client's console buffer - // the string should be \n terminated - "svc_setangle", // [vec3] set the view angle to this absolute value - - "svc_serverinfo", // [long] version - // [string] signon string - // [string]..[0]model cache [string]...[0]sounds cache - // [string]..[0]item cache - "svc_lightstyle", // [byte] [string] - "svc_updatename", // [byte] [string] - "svc_updatefrags", // [byte] [short] - "svc_clientdata", // - "svc_stopsound", // - "svc_updatecolors", // [byte] [byte] - "svc_particle", // [vec3] - "svc_damage", // [byte] impact [byte] blood [vec3] from - - "svc_spawnstatic", - "OBSOLETE svc_spawnbinary", - "svc_spawnbaseline", - - "svc_temp_entity", // - "svc_setpause", - "svc_signonnum", - "svc_centerprint", - "svc_killedmonster", - "svc_foundsecret", - "svc_spawnstaticsound", - "svc_intermission", - "svc_finale", // [string] music [string] text - "svc_cdtrack", // [byte] track [byte] looptrack - "svc_sellscreen", - "svc_cutscene", - "", // 35 - "", // 36 - "svc_fitz_skybox", - "", // 38 - "", // 39 - "svc_fitz_bf", - "svc_fitz_fog", - "svc_fitz_spawnbaseline2", - "svc_fitz_spawnstatic2", - "svc_fitz_spawnstaticsound2", - "", // 45 - "", // 46 - "", // 47 - "", // 48 - "", // 49 -}; - //============================================================================= /* @@ -214,7 +154,7 @@ CL_KeepaliveMessage(void) if (cls.demoplayback) return; -// read messages from server, should just be nops + // read messages from server, should just be nops old = net_message; memcpy(olddata, net_message.data, net_message.cursize); @@ -237,13 +177,13 @@ CL_KeepaliveMessage(void) net_message = old; memcpy(net_message.data, olddata, net_message.cursize); -// check time + // check time time = Sys_DoubleTime(); if (time - lastmsg < 5) return; lastmsg = time; -// write out a nop + // write out a nop Con_Printf("--> client to server keepalive\n"); MSG_WriteByte(&cls.message, clc_nop); @@ -270,8 +210,6 @@ CL_ParseServerInfo(void) for (i = 0; i < MAX_SOUNDS; i++) sound_precache[i] = malloc(sizeof(char*) * MAX_QPATH); - Con_DPrintf("Serverinfo packet received.\n"); - /* wipe the client_state_t struct */ CL_ClearState(); @@ -927,15 +865,6 @@ CL_ParseFitzStaticSound2(void) S_StaticSound(cl.sound_precache[sound_num], org, vol, atten); } -/* helper function (was a macro, hence the CAPS) */ -static void -SHOWNET(const char *msg) -{ - if (cl_shownet.value == 2) - Con_Printf("%3i:%s\n", msg_readcount - 1, msg); -} - - /* ===================== CL_ParseServerMessage @@ -949,14 +878,6 @@ CL_ParseServerMessage(void) unsigned int bits; byte colors; - // - // if recording demos, copy the message out - // - if (cl_shownet.value == 1) - Con_Printf("%i ", net_message.cursize); - else if (cl_shownet.value == 2) - Con_Printf("------------------\n"); - cl.onground = false; // unless the server says otherwise // parse the message MSG_BeginReading(); @@ -971,18 +892,14 @@ CL_ParseServerMessage(void) cmd = MSG_ReadByte(); if (cmd == -1) { - SHOWNET("END OF MESSAGE"); return; // end of message } // if the high bit of the command byte is set, it is a fast update if (cmd & 128) { - SHOWNET("fast update"); CL_ParseUpdate(cmd & 127); continue; } - SHOWNET(svc_strings[cmd]); - // other commands switch (cmd) { case svc_nop: diff --git a/common/client.h b/common/client.h index 233aa82c..1f3b96fe 100644 --- a/common/client.h +++ b/common/client.h @@ -240,7 +240,6 @@ extern cvar_t cl_anglespeedkey; extern cvar_t cl_autofire; -extern cvar_t cl_shownet; extern cvar_t cl_nolerp; extern cvar_t cl_pitchdriftspeed; diff --git a/common/cmd.c b/common/cmd.c index ce857eb5..786612b8 100644 --- a/common/cmd.c +++ b/common/cmd.c @@ -325,7 +325,7 @@ Cmd_Exec_f(void) Con_Printf("couldn't exec %s\n", Cmd_Argv(1)); return; } - if (cl_warncmd.value || developer.value) + if (cl_warncmd.value) Con_Printf("execing %s\n", Cmd_Argv(1)); Cbuf_InsertText(f); @@ -789,7 +789,7 @@ Cmd_ExecuteString(const char *text) } // check cvars - if (!Cvar_Command() && (cl_warncmd.value || developer.value)) + if (!Cvar_Command() && cl_warncmd.value) Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0)); } diff --git a/common/common.c b/common/common.c index 9525072a..38ced5c0 100644 --- a/common/common.c +++ b/common/common.c @@ -87,7 +87,6 @@ static int static_registered = 1; // only for startup check, then set qboolean msg_suppress_1 = 0; static void COM_InitFilesystem(void); -static void COM_Path_f(void); static void *SZ_GetSpace(sizebuf_t *buf, int length); // if a packfile directory differs from this, it is assumed to be hacked @@ -744,9 +743,6 @@ static void *SZ_GetSpace(sizebuf_t *buf, int length) __func__, buf->cursize + length, buf->maxsize); if (length > buf->maxsize) Sys_Error("%s: %d is > full buffer size", __func__, length); - if (developer.value) - /* Con_Printf may be redirected */ - Sys_Printf("%s: overflow\n", __func__); SZ_Clear(buf); buf->overflowed = true; } @@ -842,8 +838,8 @@ void COM_FileBase(const char *in, char *out, size_t buflen) const char *dot; int copylen; - in = COM_SkipPath(in); - dot = strrchr(in, '.'); + in = COM_SkipPath(in); + dot = strrchr(in, '.'); copylen = dot ? dot - in : strlen(in); if (copylen < 2) { @@ -1110,8 +1106,6 @@ void COM_Init(void) #ifdef NQ_HACK Cvar_RegisterVariable(&cmdline); #endif - Cmd_AddCommand("path", COM_Path_f); - COM_InitFilesystem(); COM_CheckRegistered(); } @@ -1128,16 +1122,12 @@ varargs versions of all text functions. char *va(const char *format, ...) { va_list argptr; - int len; char *buf = COM_GetStrBuf(); va_start(argptr, format); - len = vsnprintf(buf, COM_STRBUF_LEN, format, argptr); + vsnprintf(buf, COM_STRBUF_LEN, format, argptr); va_end(argptr); - if (len > COM_STRBUF_LEN - 1) - Con_DPrintf("%s: overflow (string truncated)\n", __func__); - return buf; } @@ -1228,31 +1218,6 @@ static int COM_FileOpenRead(const char *path, RFILE **hndl) return -1; } -/* -============ -COM_Path_f - -============ -*/ -static void COM_Path_f(void) -{ - searchpath_t *s; - - Con_Printf("Current search path:\n"); - for (s = com_searchpaths; s; s = s->next) - { -#ifdef QW_HACK - if (s == com_base_searchpaths) - Con_Printf("----------\n"); -#endif - if (s->pack) - Con_Printf("%s (%i files)\n", s->pack->filename, - s->pack->numfiles); - else - Con_Printf("%s\n", s->filename); - } -} - /* ============ COM_WriteFile @@ -1623,13 +1588,9 @@ void COM_LoadCacheFile(const char *path, struct cache_user_s *cu) void *COM_LoadStackFile(const char *path, void *buffer, int bufsize, unsigned long *length) { - byte *buf; - - loadbuf = (byte *)buffer; + loadbuf = (byte *)buffer; loadsize = bufsize; - buf = (byte*)COM_LoadFile(path, 4, length); - - return buf; + return (byte*)COM_LoadFile(path, 4, length); } /* @@ -2010,22 +1971,12 @@ static const char *Info_ReadKey(const char *infostring, char *buffer, int buflen pkey = infostring; infostring = Info_ReadString(infostring, buffer, buflen); - /* If we aren't at a separator, then the key was too long */ - if (*buffer && *infostring != '\\') - Con_DPrintf("WARNING: No separator after info key (%s)\n", pkey); - return infostring; } static const char *Info_ReadValue(const char *infostring, char *buffer, int buflen) { - infostring = Info_ReadString(infostring, buffer, buflen); - - /* If we aren't at a separator, then the value was too long */ - if (*infostring && *infostring != '\\') - Con_DPrintf("WARNING: info value too long? (%s)\n", buffer); - - return infostring; + return Info_ReadString(infostring, buffer, buflen); } /* @@ -2046,7 +1997,7 @@ char *Info_ValueForKey(const char *infostring, const char *key) char *buf; buffer_index = (buffer_index + 1) & 3; - buf = buffers[buffer_index]; + buf = buffers[buffer_index]; while (1) { @@ -2313,46 +2264,6 @@ byte COM_BlockSequenceCRCByte(const byte *base, int length, int sequence) return crc; } - -// char *date = "Oct 24 1996"; -static const char *date = __DATE__; -static const char *mon[12] = - { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", - "Nov", "Dec" -}; -static char mond[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; - -// returns days since Oct 24 1996 -int build_number(void) -{ - int m = 0; - int d = 0; - int y = 0; - static int b = 0; - - if (b != 0) - return b; - - for (m = 0; m < 11; m++) - { - if (strncasecmp(&date[0], mon[m], 3) == 0) - break; - d += mond[m]; - } - - d += atoi(&date[4]) - 1; - - y = atoi(&date[7]) - 1900; - - b = d + (int)((y - 1) * 365.25); - - if (((y % 4) == 0) && m > 1) - b += 1; - - b -= 35778; // Dec 16 1998 - - return b; -} #endif /* QW_HACK */ /* The following FS_*() stdio replacements are necessary if one is diff --git a/common/common.h b/common/common.h index 3d6806b1..b47139cb 100644 --- a/common/common.h +++ b/common/common.h @@ -288,8 +288,6 @@ byte COM_BlockSequenceCheckByte(const byte *base, int length, int sequence, unsigned mapchecksum); byte COM_BlockSequenceCRCByte(const byte *base, int length, int sequence); -int build_number(void); - extern char gamedirfile[]; #endif diff --git a/common/console.c b/common/console.c index f98706d1..7aeae8bc 100644 --- a/common/console.c +++ b/common/console.c @@ -62,8 +62,6 @@ static cvar_t con_notifytime = { "con_notifytime", "3" }; //seconds static float con_times[NUM_CON_TIMES]; // realtime time the line was generated // for transparent notify lines -static qboolean debuglog; - qboolean con_initialized; /* @@ -320,10 +318,6 @@ void Con_Printf(const char *fmt, ...) /* also echo to debugging console */ Sys_Printf("%s", msg); // also echo to debugging console - /* log all messages to file */ - if (debuglog) - Sys_DebugLog(va("%s/qconsole.log", com_savedir), "%s", msg); - if (!con_initialized) return; @@ -362,38 +356,6 @@ void Con_Printf(const char *fmt, ...) } } -/* -================ -Con_DPrintf - -A Con_Printf that only shows up if the "developer" cvar is set -================ -*/ -void -Con_DPrintf(const char *fmt, ...) -{ - va_list argptr; - char msg[MAX_PRINTMSG]; - - if (!developer.value) { - if (debuglog) { - strcpy(msg, "DEBUG: "); - va_start(argptr, fmt); - vsnprintf(msg + 7, sizeof(msg) - 7, fmt, argptr); - va_end(argptr); - Sys_DebugLog(va("%s/qconsole.log", com_savedir), "%s", msg); - } - return; - } - - va_start(argptr, fmt); - vsnprintf(msg, sizeof(msg), fmt, argptr); - va_end(argptr); - - Con_Printf("%s", msg); -} - - /* ============================================================================== @@ -628,157 +590,6 @@ void Con_DrawConsole(int lines) Con_DrawInput(); } - -/* -================== -Con_NotifyBox -================== -*/ -void -Con_NotifyBox(char *text) -{ - double t1, t2; - -// during startup for sound / cd warnings - Con_Printf - ("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n"); - - Con_Printf("%s", text); - - Con_Printf("Press a key.\n"); - Con_Printf - ("\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\37\n"); - - key_count = -2; // wait for a key down and up - key_dest = key_console; - - do - { - t1 = Sys_DoubleTime(); - SCR_UpdateScreen(); - Sys_SendKeyEvents(); - t2 = Sys_DoubleTime(); - realtime += t2 - t1; // make the cursor blink - } while (key_count < 0); - - Con_Printf("\n"); - key_dest = key_game; - realtime = 0; // put the cursor back to invisible -} - - -/* -================== -Con_SafePrintf - -Okay to call even when the screen can't be updated -================== -*/ -void -Con_SafePrintf(const char *fmt, ...) -{ - va_list argptr; - char msg[MAX_PRINTMSG]; - int temp; - - va_start(argptr, fmt); - vsnprintf(msg, sizeof(msg), fmt, argptr); - va_end(argptr); - - temp = scr_disabled_for_loading; - scr_disabled_for_loading = true; - Con_Printf("%s", msg); - scr_disabled_for_loading = temp; -} - -void -Con_ShowList(const char **list, int cnt, int maxlen) -{ - const char *s; - unsigned i, j, len, cols, rows; - char *line; - - /* Lay them out in columns */ - line = (char*)Z_Malloc(Con_GetWidth() + 1); - cols = Con_GetWidth() / (maxlen + 2); - rows = cnt / cols + ((cnt % cols) ? 1 : 0); - - /* Looks better if we have a few rows before spreading out */ - if (rows < 5) { - cols = cnt / 5 + ((cnt % 5) ? 1 : 0); - rows = cnt / cols + ((cnt % cols) ? 1 : 0); - } - - for (i = 0; i < rows; ++i) { - line[0] = '\0'; - for (j = 0; j < cols; ++j) { - if (j * rows + i >= cnt) - break; - s = list[j * rows + i]; - len = strlen(s); - - strcat(line, s); - if (j < cols - 1) { - while (len < maxlen) { - strcat(line, " "); - len++; - } - strcat(line, " "); - } - } - Con_Printf("%s\n", line); - } - Z_Free(line); -} - -static const char **showtree_list; -static unsigned showtree_idx; - -static void -Con_ShowTree_Populate(struct rb_node *n) -{ - if (n) { - Con_ShowTree_Populate(n->rb_left); - showtree_list[showtree_idx++] = stree_entry(n)->string; - Con_ShowTree_Populate(n->rb_right); - } -} - -void -Con_ShowTree(struct stree_root *root) -{ - /* FIXME - cheating with malloc */ - showtree_list = (const char**)malloc(root->entries * sizeof(char *)); - if (showtree_list) { - showtree_idx = 0; - Con_ShowTree_Populate(root->root.rb_node); - Con_ShowList(showtree_list, root->entries, root->maxlen); - free(showtree_list); - } -} - - -void -Con_Maplist_f() -{ - struct stree_root st_root; - const char *pfx = NULL; - - st_root.entries = 0; - st_root.maxlen = 0; - st_root.minlen = -1; - //st_root.root = NULL; - st_root.stack = NULL; - - if (Cmd_Argc() == 2) - pfx = Cmd_Argv(1); - - STree_AllocInit(); - COM_ScanDir(&st_root, "maps", pfx, ".bsp", true); - Con_ShowTree(&st_root); -} - - /* ================ Con_Init @@ -787,8 +598,6 @@ Con_Init void Con_Init(void) { - debuglog = COM_CheckParm("-condebug"); - con_main.text = (char*)Hunk_AllocName(CON_TEXTSIZE, "conmain"); con = &con_main; @@ -804,7 +613,6 @@ Con_Init(void) Cmd_AddCommand("messagemode", Con_MessageMode_f); Cmd_AddCommand("messagemode2", Con_MessageMode2_f); Cmd_AddCommand("clear", Con_Clear_f); - Cmd_AddCommand("maplist", Con_Maplist_f); con_initialized = true; } diff --git a/common/console.h b/common/console.h index 021991eb..dae53081 100644 --- a/common/console.h +++ b/common/console.h @@ -49,8 +49,6 @@ void Con_Init(void); void Con_DrawConsole(int lines); void Con_Print(const char *txt); void Con_Printf(const char *fmt, ...); -void Con_DPrintf(const char *fmt, ...); -void Con_SafePrintf(const char *fmt, ...); void Con_Clear_f(void); void Con_DrawNotify(void); void Con_ClearNotify(void); diff --git a/common/cvar.c b/common/cvar.c index 969f8cee..afd6b3ca 100644 --- a/common/cvar.c +++ b/common/cvar.c @@ -207,12 +207,6 @@ Cvar_Set(const char *var_name, const char *value) changed = strcmp(var->string, value); - /* Check for developer-only cvar */ - if (changed && (var->flags & CVAR_DEVELOPER) && !developer.value) { - Con_Printf("%s is settable only in developer mode.\n", var_name); - return; - } - #ifdef SERVERONLY if (var->info) { Info_SetValueForKey(svs.info, var_name, value, MAX_SERVERINFO_STRING); @@ -284,7 +278,6 @@ Adds a freestanding variable to the variable list. void Cvar_RegisterVariable(cvar_t *variable) { char value[512]; // FIXME - magic numbers... - float old_developer; /* first check to see if it has allready been defined */ if (Cvar_FindVar(variable->name)) @@ -313,13 +306,9 @@ void Cvar_RegisterVariable(cvar_t *variable) /* * FIXME (BARF) - readonly cvars need to be initialised - * developer 1 allows set */ /* set it through the function to be consistant */ - old_developer = developer.value; - developer.value = 1; Cvar_Set(variable->name, value); - developer.value = old_developer; } /* diff --git a/common/d_init.c b/common/d_init.c index 7182ab21..4ebf34f2 100644 --- a/common/d_init.c +++ b/common/d_init.c @@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define NUM_MIPS 4 -static cvar_t d_subdiv16 = { "d_subdiv16", "1" }; static cvar_t d_mipcap = { "d_mipcap", "0" }; static cvar_t d_mipscale = { "d_mipscale", "1", true }; @@ -50,7 +49,6 @@ D_Init(void) r_skydirect = 1; - Cvar_RegisterVariable(&d_subdiv16); Cvar_RegisterVariable(&d_mipcap); Cvar_RegisterVariable(&d_mipscale); Cvar_RegisterVariable(&dither_filter); diff --git a/common/draw.c b/common/draw.c index bcc755ee..d43b4a70 100644 --- a/common/draw.c +++ b/common/draw.c @@ -173,18 +173,10 @@ Draw_Character(int x, int y, int num) if (y <= -8) return; - /* - * FIXME - this was #ifdef PARANOID and Sys_Error instead of Con_DPrintf - * - seems to be affected by "-conwidth ..." - */ - if (y > vid.height - 8 || x < 0 || x > vid.width - 8) { - //Con_DPrintf("%s: (%i, %i)\n", __func__, x, y); + if (y > vid.height - 8 || x < 0 || x > vid.width - 8) return; - } - if (num < 0 || num > 255) { - //Con_DPrintf("%s: char %i\n", __func__, num); + if (num < 0 || num > 255) return; - } row = num >> 4; col = num & 15; diff --git a/common/drawhulls.c b/common/drawhulls.c index 9905d4a0..78471929 100644 --- a/common/drawhulls.c +++ b/common/drawhulls.c @@ -668,8 +668,6 @@ static void make_hull_windings(hull_t *hull) { struct list_node head = LIST_HEAD_INIT(head); - Con_DPrintf("%i clipnodes...\n", hull->lastclipnode - hull->firstclipnode); - /* * FIXME(s): * - Make sure a map is loaded diff --git a/common/host.c b/common/host.c index a280fd9b..baaede4c 100644 --- a/common/host.c +++ b/common/host.c @@ -83,9 +83,6 @@ static jmp_buf host_abort; byte *host_basepal; byte *host_colormap; -cvar_t host_framerate = { "host_framerate", "0" }; // set for slow motion -cvar_t host_speeds = { "host_speeds", "0" }; // set for running times - cvar_t serverprofile = { "serverprofile", "0" }; cvar_t fraglimit = { "fraglimit", "0", false, true }; @@ -95,8 +92,6 @@ cvar_t teamplay = { "teamplay", "0", false, true }; cvar_t samelevel = { "samelevel", "0" }; cvar_t noexit = { "noexit", "0", false, true }; -cvar_t developer = { "developer", "0" }; - cvar_t skill = { "skill", "1" }; // 0 - 3 cvar_t deathmatch = { "deathmatch", "0" }; // 0, 1, or 2 cvar_t coop = { "coop", "0" }; // 0 or 1 @@ -120,7 +115,6 @@ Host_EndGame(const char *message, ...) va_start(argptr, message); vsnprintf(string, sizeof(string), message, argptr); va_end(argptr); - Con_DPrintf("%s: %s\n", __func__, string); if (sv.active) Host_ShutdownServer(false); @@ -233,9 +227,6 @@ Host_InitLocal(void) { Host_InitCommands(); - Cvar_RegisterVariable(&host_framerate); - Cvar_RegisterVariable(&host_speeds); - Cvar_RegisterVariable(&serverprofile); Cvar_RegisterVariable(&fraglimit); @@ -251,10 +242,6 @@ Host_InitLocal(void) Cvar_RegisterVariable(&temp1); - Cvar_RegisterVariable(&developer); - if (COM_CheckParm("-developer")) - Cvar_SetValue("developer", 1); - Host_FindMaxClients(); host_time = 1.0; // so a think at time 0 won't get called @@ -434,11 +421,11 @@ Host_ShutdownServer(qboolean crash) sv.active = false; -// stop all client sounds immediately + // stop all client sounds immediately if (cls.state >= ca_connected) CL_Disconnect(); -// flush any pending messages - like the score!!! + // flush any pending messages - like the score!!! start = Sys_DoubleTime(); do { count = 0; @@ -459,8 +446,8 @@ Host_ShutdownServer(qboolean crash) break; } while (count); -// make sure all the clients know we're disconnecting - buf.data = message; + // make sure all the clients know we're disconnecting + buf.data = message; buf.maxsize = 4; buf.cursize = 0; MSG_WriteByte(&buf, svc_disconnect); @@ -493,7 +480,6 @@ not reinitialize anything. void Host_ClearMemory(void) { - Con_DPrintf("Clearing memory\n"); D_FlushCaches(); Mod_ClearAll(); if (host_hunklevel) @@ -520,17 +506,10 @@ Host_FilterTime(float time) { realtime += time; - /* allow high framerate, warn about it in core options - if (!cls.timedemo && realtime - oldrealtime < 1.0 / 72.0) - return false; // framerate is too high - */ - host_frametime = realtime - oldrealtime; oldrealtime = realtime; - if (host_framerate.value > 0) - host_frametime = host_framerate.value; - else { // don't allow really long or short frames + { // don't allow really long or short frames if (host_frametime > 0.1) host_frametime = 0.1; if (host_frametime < 0.001) @@ -540,28 +519,6 @@ Host_FilterTime(float time) return true; } - -/* -=================== -Host_GetConsoleCommands - -Add them exactly as if they had been typed at the console -=================== -*/ -void -Host_GetConsoleCommands(void) -{ - char *cmd; - - while (1) { - cmd = Sys_ConsoleInput(); - if (!cmd) - break; - Cbuf_AddText("%s", cmd); - } -} - - /* ================== Host_ServerFrame @@ -691,9 +648,6 @@ _Host_Frame(float time) // //------------------- - /* check for commands typed to the host */ - Host_GetConsoleCommands(); - if (sv.active) Host_ServerFrame(); @@ -824,7 +778,7 @@ Host_Init(quakeparms_t *parms) S_Init(); CDAudio_Init(); - BGM_Init(); + BGM_Init(); Sbar_Init(); CL_Init(); diff --git a/common/host.h b/common/host.h index ffc14707..e9444544 100644 --- a/common/host.h +++ b/common/host.h @@ -29,7 +29,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern quakeparms_t host_parms; extern cvar_t sys_nostdout; -extern cvar_t developer; extern qboolean host_initialized; // true if into command execution extern double host_frametime; diff --git a/common/keys.c b/common/keys.c index c619816c..63a524b8 100644 --- a/common/keys.c +++ b/common/keys.c @@ -194,38 +194,12 @@ keyname_t keynames[] = { ============================================================================== */ -/* - * Given a command buffer, return a pointer to the start of the current - * command string. Only simple for now (i.e. search backwards for a command - * delimiter), but proper parsing of quotation, etc needed later... - */ -static char * -GetCommandPos(char *buf) -{ - char *pos; - - pos = strrchr(buf, ';'); - if (pos) { - pos++; - while (*pos == ' ') - pos++; - } else - pos = buf; - - if (*pos == '\\' || *pos == '/') - pos++; - - return pos; -} - static qboolean CheckForCommand(void) { char cmd[128]; - char *s; int i; - - s = key_lines[edit_line] + 1; // skip the ] + char *s = key_lines[edit_line] + 1; // skip the ] for (i = 0; i < sizeof(cmd) - 1; i++) if (s[i] <= ' ') @@ -237,111 +211,6 @@ CheckForCommand(void) return Cmd_Exists(cmd) || Cvar_FindVar(cmd) || Cmd_Alias_Exists(cmd); } - -void -CompleteCommand(void) -{ - const char *cmd, *completion; - char *s, *newcmd; - int len; - - s = GetCommandPos(key_lines[edit_line] + 1); - cmd = Cmd_CommandComplete(s); - if (cmd) { - key_linepos = s - key_lines[edit_line]; - if (s == key_lines[edit_line] + 1) { - *s++ = '/'; - key_linepos++; - } - strcpy(s, cmd); - key_linepos += strlen(cmd); - key_lines[edit_line][key_linepos] = 0; - Z_Free(cmd); - } else { - /* Try argument completion? */ - cmd = strchr(s, ' '); - if (cmd) { - len = cmd - s; - newcmd = (char*)Z_Malloc(len + 1); - strncpy(newcmd, s, len); - newcmd[len] = 0; - - completion = NULL; - if (Cmd_Exists(newcmd)) { - s += len; - while (*s == ' ') - s++; - completion = Cmd_ArgComplete(newcmd, s); - } else if (Cvar_FindVar(newcmd)) { - s += len; - while (*s == ' ') - s++; - completion = Cvar_ArgComplete(newcmd, s); - } - if (completion) { - key_linepos = s - key_lines[edit_line]; - strcpy(s, completion); - key_linepos += strlen(completion); - Z_Free(completion); - } - Z_Free(newcmd); - } - } -} - -static void -ShowCompletions(void) -{ - const char *s; - struct stree_root *root; - unsigned int len; - - s = GetCommandPos(key_lines[edit_line] + 1); - - root = Cmd_CommandCompletions(s); - if (root && root->entries) { - Con_Printf("%s\n", key_lines[edit_line]); - //Con_Printf("%u possible completions:\n", root->entries); - Con_ShowTree(root); - Z_Free(root); - } else { - char *cmd = (char*)strchr(s, ' '); - if (cmd) { - len = cmd - s; - cmd = (char*)Z_Malloc(len + 1); - strncpy(cmd, s, len); - cmd[len] = 0; - - if (Cmd_Exists(cmd)) { - struct stree_root *root; - - s += len; - while (*s == ' ') - s++; - root = Cmd_ArgCompletions(cmd, s); - if (root && root->entries) { - Con_Printf("%s\n", key_lines[edit_line]); - Con_ShowTree(root); - Z_Free(root); - } - } else if (Cvar_FindVar(cmd)) { - struct stree_root *root; - - s += len; - while (*s == ' ') - s++; - root = Cvar_ArgCompletions(cmd, s); - if (root && root->entries) { - Con_Printf("%s\n", key_lines[edit_line]); - Con_ShowTree(root); - Z_Free(root); - } - } - Z_Free(cmd); - } - } -} - static void EnterCommand(const char *buf) { @@ -373,12 +242,6 @@ Interactive line editing and console scrollback void Key_Console(int key) { - /* detect double presses of tab key */ - static qboolean tab_once = false; - - if (key != K_TAB) - tab_once = false; - if (key == K_ENTER) { EnterCommand(key_lines[edit_line] + 1); @@ -393,18 +256,6 @@ Key_Console(int key) return; } - if (key == K_TAB) { // command completion - if (tab_once) { - /* double tab */ - ShowCompletions(); - tab_once = false; - return; - } - tab_once = true; - CompleteCommand(); - return; - } - if (key == K_BACKSPACE || key == K_LEFTARROW) { if (key_linepos > 1) key_linepos--; @@ -462,35 +313,6 @@ Key_Console(int key) return; } -#if 0 - if ((key == 'V' || key == 'v') && GetKeyState(VK_CONTROL) < 0) { - if (OpenClipboard(NULL)) { - th = GetClipboardData(CF_TEXT); - if (th) { - clipText = GlobalLock(th); - if (clipText) { - textCopied = malloc(GlobalSize(th) + 1); - strcpy(textCopied, clipText); - /* Substitutes a NULL for every token */ - strtok(textCopied, "\n\r\b"); - i = strlen(textCopied); - if (i + key_linepos >= MAXCMDLINE) - i = MAXCMDLINE - key_linepos; - if (i > 0) { - textCopied[i] = 0; - strcat(key_lines[edit_line], textCopied); - key_linepos += i;; - } - free(textCopied); - } - GlobalUnlock(th); - } - CloseClipboard(); - return; - } - } -#endif - if (key < 32 || key > 127) return; // non printable @@ -677,11 +499,10 @@ Key_Bind_f void Key_Bind_f(void) { - int i, argc, keynum, len; + int i, keynum, len; char cmd[1024]; - // FIXME - allow arguments bound with the commands? - argc = Cmd_Argc(); + int argc = Cmd_Argc(); if (argc != 2 && argc != 3) { Con_Printf("bind [command] : attach a command to a key\n"); return; @@ -833,10 +654,9 @@ Key_Event(knum_t key, qboolean down) key_lastpress = key; key_count++; - if (key_count <= 0) { + if (key_count <= 0) return; // just catching keys for Con_NotifyBox - } -// update auto-repeat status + // update auto-repeat status if (down) { key_repeats[key]++; if (key != K_BACKSPACE diff --git a/common/libretro.c b/common/libretro.c index e690d8ce..83f25f96 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -457,17 +457,6 @@ void IN_Accumulate(void) {} -char * Sys_ConsoleInput(void) -{ - return NULL; -} - -qboolean -window_visible(void) -{ - return true; -} - void Sys_HighFPPrecision(void) { } diff --git a/common/mathlib.c b/common/mathlib.c index 7872d91d..c1b2ba14 100644 --- a/common/mathlib.c +++ b/common/mathlib.c @@ -273,11 +273,6 @@ BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const mplane_t *p) if (dist2 < p->dist) sides |= PSIDE_BACK; -#ifdef PARANOID - if (sides == 0) - Sys_Error("%s: sides == 0", __func__); -#endif - return sides; } @@ -521,17 +516,9 @@ FloorDivMod(double numer, double denom, int *quotient, int *rem) int q, r; double x; -#ifndef PARANOID if (denom <= 0.0) Sys_Error("%s: bad denominator %lf", __func__, denom); -#if 0 - if ((floor(numer) != numer) || (floor(denom) != denom)) - Sys_Error ("%s: non-integer numer or denom %f %f", __func__ - numer, denom); -#endif -#endif - if (numer >= 0.0) { x = floor(numer / denom); diff --git a/common/model.c b/common/model.c index 4dd1cb8d..c1eac3a6 100644 --- a/common/model.c +++ b/common/model.c @@ -2009,22 +2009,6 @@ void *Mod_Extradata(model_t *mod) return mod->cache.data; } -/* -================ -Mod_Print -================ -*/ -void Mod_Print(void) -{ - int i; - model_t *mod; - - Con_Printf("Cached models:\n"); - for (i = 0, mod = mod_known; i < mod_numknown; i++, mod++) - Con_Printf("%*p : %s\n", (int)sizeof(void *) * 2 + 2, - mod->cache.data, mod->name); -} - /* ================== Mod_TouchModel diff --git a/common/model.h b/common/model.h index 30bc1208..8dfa5041 100644 --- a/common/model.h +++ b/common/model.h @@ -450,7 +450,6 @@ void Mod_ClearAll(void); model_t *Mod_ForName(const char *name, qboolean crash); void *Mod_Extradata(model_t *mod); // handles caching void Mod_TouchModel(char *name); -void Mod_Print(void); /* * PVS/PHS information diff --git a/common/net_dgrm.c b/common/net_dgrm.c index da22c892..90d36862 100644 --- a/common/net_dgrm.c +++ b/common/net_dgrm.c @@ -271,14 +271,8 @@ Datagram_GetMessage(qsocket_t *sock) return -1; } - if (NET_AddrCompare(&readaddr, &sock->addr) != 0) { -#ifdef DEBUG - Con_DPrintf("Forged packet received\n"); - Con_DPrintf("Expected: %s\n", StrAddr(&sock->addr)); - Con_DPrintf("Received: %s\n", StrAddr(&readaddr)); -#endif + if (NET_AddrCompare(&readaddr, &sock->addr) != 0) continue; - } if (length < NET_HEADERSIZE) { shortPacketCount++; @@ -297,14 +291,12 @@ Datagram_GetMessage(qsocket_t *sock) if (flags & NETFLAG_UNRELIABLE) { if (sequence < sock->unreliableReceiveSequence) { - Con_DPrintf("Got a stale datagram\n"); ret = 0; break; } if (sequence != sock->unreliableReceiveSequence) { count = sequence - sock->unreliableReceiveSequence; droppedDatagrams += count; - Con_DPrintf("Dropped %u datagram(s)\n", count); } sock->unreliableReceiveSequence = sequence + 1; @@ -318,18 +310,12 @@ Datagram_GetMessage(qsocket_t *sock) } if (flags & NETFLAG_ACK) { - if (sequence != (sock->sendSequence - 1)) { - Con_DPrintf("Stale ACK received\n"); + if (sequence != (sock->sendSequence - 1)) continue; - } - if (sequence == sock->ackSequence) { + if (sequence == sock->ackSequence) sock->ackSequence++; - if (sock->ackSequence != sock->sendSequence) - Con_DPrintf("ack sequencing error\n"); - } else { - Con_DPrintf("Duplicate ACK received\n"); + else continue; - } sock->sendMessageLength -= sock->mtu; if (sock->sendMessageLength > 0) { memmove(sock->sendMessage, sock->sendMessage + sock->mtu, diff --git a/common/net_main.c b/common/net_main.c index bea4526e..e7f77a6f 100644 --- a/common/net_main.c +++ b/common/net_main.c @@ -811,9 +811,6 @@ NET_Init(void) if (num_inited == 0 && cls.state == ca_dedicated) Sys_Error("Network not available!"); - - if (*my_tcpip_address) - Con_DPrintf("TCP/IP address %s\n", my_tcpip_address); } /* diff --git a/common/net_wins.c b/common/net_wins.c index 75e2b432..b7001728 100644 --- a/common/net_wins.c +++ b/common/net_wins.c @@ -113,10 +113,8 @@ WINS_Init(void) if (!winsock_initialized) { err = WSAStartup(MAKEWORD(1,1), &winsockdata); - if (err) { - Con_SafePrintf("Winsock initialization failed.\n"); + if (err) return -1; - } } winsock_initialized++; diff --git a/common/pr_cmds.c b/common/pr_cmds.c index 1f4fc7bb..a25e9cf8 100644 --- a/common/pr_cmds.c +++ b/common/pr_cmds.c @@ -64,10 +64,8 @@ PF_VarString(int first) arglen = strlen(arg); strncat(out, arg, buflen); buflen -= arglen; - if (buflen < 0) { - Con_DPrintf("%s: overflow (string truncated)\n", __func__); + if (buflen < 0) break; - } } return out; } @@ -1026,7 +1024,6 @@ PF_dprint static void PF_dprint(void) { - Con_DPrintf("%s", PF_VarString(0)); } static char pr_string_temp[128]; diff --git a/common/pr_edict.c b/common/pr_edict.c index 201c99b0..21001ced 100644 --- a/common/pr_edict.c +++ b/common/pr_edict.c @@ -1025,8 +1025,6 @@ ED_LoadFromFile(const char *data) SV_FlushSignon(); #endif } - - Con_DPrintf("%i entities inhibited\n", inhibit); } @@ -1058,7 +1056,6 @@ PR_LoadProgs(void) #endif if (!progs) SV_Error("%s: couldn't load progs.dat", __func__); - Con_DPrintf("Programs occupy %iK.\n", com_filesize / 1024); #ifdef NQ_HACK pr_crc = CRC_Block((byte *)progs, com_filesize); diff --git a/common/pr_exec.c b/common/pr_exec.c index e6022c2d..2c407057 100644 --- a/common/pr_exec.c +++ b/common/pr_exec.c @@ -414,9 +414,6 @@ PR_ExecuteProgram(func_t fnum) if (!--runaway) PR_RunError("runaway loop error"); - if (runaway <= 50000 && !(runaway % 5000)) - Con_DPrintf("%s: progs execution running away (%i left)\n", - __func__, runaway); pr_xfunction->profile++; pr_xstatement = s; @@ -579,9 +576,6 @@ PR_ExecuteProgram(func_t fnum) case OP_ADDRESS: ed = PROG_TO_EDICT(a->edict); -#ifdef PARANOID - NUM_FOR_EDICT(ed); // make sure it's in range -#endif if (ed == (edict_t *)sv.edicts && sv.state == ss_active) PR_RunError("assignment to world entity"); c->_int = (byte *)((int *)&ed->v + b->_int) - (byte *)sv.edicts; @@ -593,18 +587,12 @@ PR_ExecuteProgram(func_t fnum) case OP_LOAD_S: case OP_LOAD_FNC: ed = PROG_TO_EDICT(a->edict); -#ifdef PARANOID - NUM_FOR_EDICT(ed); // make sure it's in range -#endif a = (eval_t *)((int *)&ed->v + b->_int); c->_int = a->_int; break; case OP_LOAD_V: ed = PROG_TO_EDICT(a->edict); -#ifdef PARANOID - NUM_FOR_EDICT(ed); // make sure it's in range -#endif a = (eval_t *)((int *)&ed->v + b->_int); c->vector[0] = a->vector[0]; c->vector[1] = a->vector[1]; diff --git a/common/quakedef.h b/common/quakedef.h index 51090b73..c085681b 100644 --- a/common/quakedef.h +++ b/common/quakedef.h @@ -41,8 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define __func__ __FUNCTION__ #endif -//define PARANOID // speed sapping error checking - // !!! if this is changed, it must be changed in d_ifacea.h too !!! #define CACHE_SIZE 32 // used to align key data structures #define CACHE_PAD_ARRAY(elements, type) \ diff --git a/common/r_alias.c b/common/r_alias.c index b34737ab..e7ad61ad 100644 --- a/common/r_alias.c +++ b/common/r_alias.c @@ -200,10 +200,8 @@ qboolean R_AliasCheckBBox(entity_t *e) // construct the base bounding box for this frame frame = e->frame; // TODO: don't repeat this check when drawing? - if ((frame >= pahdr->numframes) || (frame < 0)) { - Con_DPrintf("No such frame %d %s\n", frame, pmodel->name); + if ((frame >= pahdr->numframes) || (frame < 0)) frame = 0; - } pframedesc = &pahdr->frames[frame]; @@ -662,21 +660,18 @@ static void R_AliasSetupSkin(const entity_t *e, aliashdr_t *pahdr) uintptr_t frame; int numframes, skinbytes; maliasskindesc_t *pskindesc; - byte *pdata; + byte *pdata = NULL; int skinnum = e->skinnum; if ((skinnum >= pahdr->numskins) || (skinnum < 0)) - { - Con_DPrintf("%s: no such skin # %d\n", __func__, skinnum); skinnum = 0; - } - pskindesc = ((maliasskindesc_t *)((byte *)pahdr + pahdr->skindesc)); - pskindesc += skinnum; + pskindesc = ((maliasskindesc_t *)((byte *)pahdr + pahdr->skindesc)); + pskindesc += skinnum; a_skinwidth = pahdr->skinwidth; - frame = pskindesc->firstframe; - numframes = pskindesc->numframes; + frame = pskindesc->firstframe; + numframes = pskindesc->numframes; if (numframes > 1) { @@ -789,10 +784,7 @@ R_AliasSetupFrame(entity_t *e, aliashdr_t *pahdr) int frame = e->frame; if ((frame >= pahdr->numframes) || (frame < 0)) - { - Con_DPrintf("%s: no such frame %d\n", __func__, frame); frame = 0; - } pose = pahdr->frames[frame].firstpose; numposes = pahdr->frames[frame].numposes; diff --git a/common/r_local.h b/common/r_local.h index 96118883..0ae2b214 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -59,7 +59,6 @@ typedef struct { //=========================================================================== extern cvar_t r_draworder; -extern cvar_t r_speeds; extern cvar_t r_graphheight; extern cvar_t r_clearcolor; extern cvar_t r_waterwarp; @@ -226,9 +225,6 @@ void R_Alias_clip_bottom(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out) void R_Alias_clip_left(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); void R_Alias_clip_right(finalvert_t *pfv0, finalvert_t *pfv1, finalvert_t *out); -extern float r_time1; -extern float dp_time1, dp_time2, db_time1, db_time2, rw_time1, rw_time2; -extern float se_time1, se_time2, de_time1, de_time2, dv_time1, dv_time2; extern int r_maxsurfsseen, r_maxedgesseen; extern cshift_t cshift_water; extern qboolean r_dowarpold, r_viewchanged; @@ -240,11 +236,6 @@ extern mnode_t *r_pefragtopnode; extern int r_clipflags; void R_StoreEfrags(efrag_t **ppefrag); -void R_TimeRefresh_f(void); -void R_TimeGraph(void); -void R_PrintAliasStats(void); -void R_PrintTimes(void); -void R_PrintDSpeeds(void); void R_AnimateLight(void); int R_LightPoint(vec3_t p); void R_SetupFrame(void); diff --git a/common/r_main.c b/common/r_main.c index a852c1a5..005e15ff 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -31,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "view.h" void *colormap; -float r_time1; int r_numallocatededges; qboolean r_recursiveaffinetriangles = true; @@ -104,7 +103,6 @@ float r_aliastransition, r_resfudge; int d_lightstylevalue[256]; // 8.8 fraction of base light value cvar_t r_draworder = { "r_draworder", "0" }; -cvar_t r_speeds = { "r_speeds", "0" }; cvar_t r_graphheight = { "r_graphheight", "15" }; cvar_t r_clearcolor = { "r_clearcolor", "2" }; cvar_t r_waterwarp = { "r_waterwarp", "1" }; @@ -119,17 +117,7 @@ cvar_t r_lockfrustum = { "r_lockfrustum", "0" }; cvar_t r_fullbright = { "r_fullbright", "0" }; -#ifdef QW_HACK -cvar_t r_netgraph = { "r_netgraph", "0" }; -static cvar_t r_zgraph = { "r_zgraph", "0" }; -#endif - -static cvar_t r_timegraph = { "r_timegraph", "0" }; -static cvar_t r_aliasstats = { "r_polymodelstats", "0" }; -static cvar_t r_dspeeds = { "r_dspeeds", "0" }; -static cvar_t r_reportsurfout = { "r_reportsurfout", "0" }; static cvar_t r_maxsurfs = { "r_maxsurfs", "0" }; -static cvar_t r_reportedgeout = { "r_reportedgeout", "0" }; static cvar_t r_maxedges = { "r_maxedges", "0" }; static cvar_t r_aliastransbase = { "r_aliastransbase", "200" }; static cvar_t r_aliastransadj = { "r_aliastransadj", "100" }; @@ -203,11 +191,9 @@ R_Init(void) R_InitTurb(); - Cmd_AddCommand("timerefresh", R_TimeRefresh_f); Cmd_AddCommand("pointfile", R_ReadPointFile_f); Cvar_RegisterVariable(&r_draworder); - Cvar_RegisterVariable(&r_speeds); Cvar_RegisterVariable(&r_graphheight); Cvar_RegisterVariable(&r_clearcolor); Cvar_RegisterVariable(&r_waterwarp); @@ -225,21 +211,11 @@ R_Init(void) Cvar_RegisterVariable(&r_fullbright); - Cvar_RegisterVariable(&r_timegraph); - Cvar_RegisterVariable(&r_aliasstats); - Cvar_RegisterVariable(&r_dspeeds); - Cvar_RegisterVariable(&r_reportsurfout); Cvar_RegisterVariable(&r_maxsurfs); - Cvar_RegisterVariable(&r_reportedgeout); Cvar_RegisterVariable(&r_maxedges); Cvar_RegisterVariable(&r_aliastransbase); Cvar_RegisterVariable(&r_aliastransadj); -#ifdef QW_HACK - Cvar_RegisterVariable(&r_netgraph); - Cvar_RegisterVariable(&r_zgraph); -#endif - Cvar_SetValue("r_maxedges", (float)NUMSTACKEDGES); Cvar_SetValue("r_maxsurfs", (float)NUMSTACKSURFACES); @@ -1074,15 +1050,6 @@ R_RenderView_(void) V_SetContentsColor(r_viewleaf->contents); - if (r_aliasstats.value) - R_PrintAliasStats(); - - if (r_reportsurfout.value && r_outofsurfaces) - Con_Printf("Short %d surfaces\n", r_outofsurfaces); - - if (r_reportedgeout.value && r_outofedges) - Con_Printf("Short roughly %d edges\n", r_outofedges * 2 / 3); - // back to high floating-point precision Sys_HighFPPrecision(); } diff --git a/common/r_misc.c b/common/r_misc.c index 73ff6cf7..b3038f9c 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -68,17 +68,6 @@ Show(void) VID_Update(&vr); } -/* -==================== -R_TimeRefresh_f - -For program optimization -==================== -*/ -void -R_TimeRefresh_f(void) -{ } - /* ================ R_LineGraph @@ -120,111 +109,7 @@ R_LineGraph(int x, int y, int h) dest[0] = color; } -/* -============== -R_TimeGraph - -Performance monitoring tool -============== -*/ #define MAX_TIMINGS 256 -void -R_TimeGraph(void) -{ -} - -#ifdef QW_HACK -/* -============== -R_NetGraph -============== -*/ -void -R_NetGraph(void) -{ - int a, x, y, y2, w, i; - int lost; - char st[80]; - - if (vid.width - 16 <= NET_TIMINGS) - w = vid.width - 16; - else - w = NET_TIMINGS; - - x = -((vid.width - 320) >> 1); - y = vid.height - sb_lines - 24 - (int)r_graphheight.value * 2 - 2; - - M_DrawTextBox(x, y, (w + 7) / 8, - ((int)r_graphheight.value * 2 + 7) / 8 + 1); - y2 = y + 8; - y = vid.height - sb_lines - 8 - 2; - - x = 8; - lost = CL_CalcNet(); - for (a = NET_TIMINGS - w; a < w; a++) { - i = (cls.netchan.outgoing_sequence - a) & NET_TIMINGSMASK; - R_LineGraph(x + w - 1 - a, y, packet_latency[i]); - } - sprintf(st, "%3i%% packet loss", lost); - Draw_String(8, y2, st); -} - -/* -============== -R_ZGraph -============== -*/ -void -R_ZGraph(void) -{ - int a, x, w, i; - static int height[256]; - - if (r_refdef.vrect.width <= 256) - w = r_refdef.vrect.width; - else - w = 256; - - height[r_framecount & 255] = ((int)r_origin[2]) & 31; - - x = 0; - for (a = 0; a < w; a++) { - i = (r_framecount - a) & 255; - R_LineGraph(x + w - 1 - a, r_refdef.vrect.height - 2, height[i]); - } -} -#endif - -/* -============= -R_PrintTimes -============= -*/ -void -R_PrintTimes(void) -{ -} - -/* -============= -R_PrintDSpeeds -============= -*/ -void -R_PrintDSpeeds(void) -{ -} - -/* -============= -R_PrintAliasStats -============= -*/ -void -R_PrintAliasStats(void) -{ - Con_Printf("%3i polygon model drawn\n", r_amodels_drawn); -} void WarpPalette(void) diff --git a/common/render.h b/common/render.h index 3997577f..3ee3927f 100644 --- a/common/render.h +++ b/common/render.h @@ -169,11 +169,6 @@ void R_RemoveEfrags(entity_t *ent); void R_NewMap(void); -#ifdef QW_HACK -void R_NetGraph(void); -void R_ZGraph(void); -#endif - void R_ParseParticleEffect(void); void R_RunParticleEffect(vec3_t org, vec3_t dir, int color, int count); void R_RocketTrail(vec3_t start, vec3_t end, int type); diff --git a/common/snd_codec.c b/common/snd_codec.c index 0277a442..09222ed6 100644 --- a/common/snd_codec.c +++ b/common/snd_codec.c @@ -278,16 +278,13 @@ int S_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer) snd_stream_t *S_CodecUtilOpen(const char *filename, snd_codec_t *codec) { - snd_stream_t *stream; - RFILE *handle; + snd_stream_t *stream = NULL; + RFILE *handle = NULL; /* Try to open the file */ - long length = (long) COM_FOpenFile(filename, &handle); - qboolean pak = file_from_pak; + long length = (long) COM_FOpenFile(filename, &handle); + qboolean pak = file_from_pak; if (length == -1) - { - Con_DPrintf("Couldn't open %s\n", filename); return NULL; - } /* Allocate a stream, Z_Malloc zeroes its content */ stream = (snd_stream_t *) Z_Malloc(sizeof(snd_stream_t)); diff --git a/common/snd_dma.c b/common/snd_dma.c index cd8965a7..75028e2c 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -689,14 +689,12 @@ static void S_Update_(void) GetSoundtime(); /* check to make sure that we haven't overshot */ - if (paintedtime < soundtime) { - /* FIXME - handle init & wrap properly and report actual overflow */ - //Con_DPrintf("%s: overflow\n", __func__); + /* FIXME - handle init & wrap properly and report actual overflow */ + if (paintedtime < soundtime) paintedtime = soundtime; - } /* mix ahead of current position */ endtime = soundtime + _snd_mixahead.value * shm->speed; - samps = shm->samples >> 1; + samps = shm->samples >> 1; if (endtime - soundtime > samps) endtime = soundtime + samps; diff --git a/common/snd_flac.c b/common/snd_flac.c index e958d2a9..e98b2f7d 100644 --- a/common/snd_flac.c +++ b/common/snd_flac.c @@ -339,12 +339,11 @@ static int S_FLAC_CodecReadStream (snd_stream_t *stream, int len, void *buffer) len -= res; buf += res; ff->pos += res; - } else if (res < 0) { /* error */ + } + else if (res < 0) /* error */ return -1; - } else { - Con_DPrintf ("FLAC: EOF\n"); + else break; - } } return count; } diff --git a/common/snd_mem.c b/common/snd_mem.c index d2bfc6b0..41676168 100644 --- a/common/snd_mem.c +++ b/common/snd_mem.c @@ -218,8 +218,6 @@ FindNextChunk(const char *name, const char *filename) data_p = last_chunk + 4; iff_chunk_len = GetLittleLong(); if (iff_chunk_len < 0 || iff_chunk_len > iff_end - data_p) { - Con_DPrintf("Bad \"%s\" chunk length (%d) in wav file %s\n", - name, iff_chunk_len, filename); data_p = NULL; return; } diff --git a/common/snd_mikmod.c b/common/snd_mikmod.c index 96f51ba1..4c864a7a 100644 --- a/common/snd_mikmod.c +++ b/common/snd_mikmod.c @@ -107,10 +107,7 @@ static qboolean S_MIKMOD_CodecInitialize (void) MikMod_RegisterDriver(&drv_nos); /* only need the "nosound" driver, none else */ MikMod_RegisterAllLoaders(); if (S_MIKMOD_initlib(NULL)) - { - Con_DPrintf("Could not initialize MikMod: %s\n", MikMod_strerror(MikMod_errno)); return false; - } /* this can't get set with drv_nos, but whatever, be safe: */ md_mode &= ~DMODE_SIMDMIXER; /* SIMD mixer is buggy when combined with HQMIXER */ @@ -144,7 +141,6 @@ static qboolean S_MIKMOD_CodecOpenStream (snd_stream_t *stream) priv->module = Player_LoadGeneric((MREADER *)stream->priv, 64, 0); if (!priv->module) { - Con_DPrintf("Could not load module: %s\n", MikMod_strerror(MikMod_errno)); Z_Free(stream->priv); return false; } @@ -162,8 +158,6 @@ static qboolean S_MIKMOD_CodecOpenStream (snd_stream_t *stream) stream->info.bits = (md_mode & DMODE_16BITS)? 16: 8; stream->info.width = stream->info.bits / 8; stream->info.channels = (md_mode & DMODE_STEREO)? 2 : 1; -/* Con_DPrintf("Playing %s (%d chn)\n", priv->module->songname, priv->module->numchn);*/ - return true; } diff --git a/common/snd_modplug.c b/common/snd_modplug.c index b9775f0b..b089349d 100644 --- a/common/snd_modplug.c +++ b/common/snd_modplug.c @@ -74,10 +74,7 @@ static qboolean S_MODPLUG_CodecOpenStream (snd_stream_t *stream) stream->priv = ModPlug_Load(moddata, len); Hunk_FreeToLowMark(mark); /* free original file data */ if (!stream->priv) - { - Con_DPrintf("Could not load module %s\n", stream->name); return false; - } ModPlug_Seek((ModPlugFile*)stream->priv, 0); #if 0 diff --git a/common/snd_mp3.c b/common/snd_mp3.c index c500eb91..edf6aa03 100644 --- a/common/snd_mp3.c +++ b/common/snd_mp3.c @@ -342,12 +342,9 @@ static int mp3_decode(snd_stream_t *stream, byte *buf, int len) /* check whether input buffer needs a refill */ if (p->Stream.error == MAD_ERROR_BUFLEN) { + /* check feof() ?? */ if (mp3_inputdata(stream) == -1) - { - /* check feof() ?? */ - Con_DPrintf("mp3 EOF\n"); break; - } } if (mad_frame_decode(&p->Frame, &p->Stream)) @@ -424,11 +421,7 @@ static int mp3_madseek(snd_stream_t *stream, unsigned long offset) bytes_read = FS_fread(p->mp3_buffer + leftover, (size_t) 1, MP3_BUFFER_SIZE - leftover, &stream->fh); if (bytes_read <= 0) - { - Con_DPrintf("seek failure. unexpected EOF (frames=%lu leftover=%lu)\n", - (unsigned long)p->FrameCount, (unsigned long)leftover); break; - } for ( ; !depadded && padding < bytes_read && !p->mp3_buffer[padding]; ++padding) ; depadded = true; @@ -445,10 +438,7 @@ static int mp3_madseek(snd_stream_t *stream, unsigned long offset) if (p->Stream.error == MAD_ERROR_BUFLEN) break; /* Normal behaviour; get some more data from the file */ if (!MAD_RECOVERABLE(p->Stream.error)) - { - Con_DPrintf("unrecoverable MAD error\n"); break; - } if (p->Stream.error == MAD_ERROR_LOSTSYNC) { unsigned long available = (p->Stream.bufend - p->Stream.this_frame); @@ -462,14 +452,6 @@ static int mp3_madseek(snd_stream_t *stream, unsigned long offset) } mad_stream_skip(&p->Stream, qmin(tagsize, available)); } - else - { - Con_DPrintf("MAD lost sync\n"); - } - } - else - { - Con_DPrintf("recoverable MAD error\n"); } continue; } diff --git a/common/snd_mpg123.c b/common/snd_mpg123.c index 2b5fb935..35d8555f 100644 --- a/common/snd_mpg123.c +++ b/common/snd_mpg123.c @@ -185,7 +185,7 @@ static int S_MP3_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer) switch (res) { case MPG123_DONE: - Con_DPrintf("mp3 EOF\n"); + /* fall-through */ case MPG123_OK: return (int)bytes_read; } diff --git a/common/snd_umx.c b/common/snd_umx.c index d85d9af6..151a1df1 100644 --- a/common/snd_umx.c +++ b/common/snd_umx.c @@ -290,19 +290,15 @@ static int32_t probe_header (void *header) } hdr = (struct upkg_hdr *) header; - if (hdr->tag != UPKG_HDR_TAG) { - Con_DPrintf("Unknown header tag 0x%x\n", hdr->tag); + if (hdr->tag != UPKG_HDR_TAG) return -1; - } if (hdr->name_count < 0 || hdr->name_offset < 0 || hdr->export_count < 0 || hdr->export_offset < 0 || hdr->import_count < 0 || - hdr->import_offset < 0 ) { - Con_DPrintf("Negative values in header\n"); + hdr->import_offset < 0 ) return -1; - } switch (hdr->file_version) { case 35: case 37: /* Unreal beta - */ @@ -320,7 +316,6 @@ static int32_t probe_header (void *header) return 0; } - Con_DPrintf("Unknown upkg version %d\n", hdr->file_version); return -1; } @@ -351,12 +346,9 @@ static qboolean S_UMX_CodecOpenStream (snd_stream_t *stream) int32_t ofs = 0, size = 0; type = process_upkg(&stream->fh, &ofs, &size); - if (type < 0) { - Con_DPrintf("%s: unrecognized umx\n", stream->name); + if (type < 0) return false; - } - Con_DPrintf("%s: %s data @ 0x%x, %d bytes\n", stream->name, mustype[type], ofs, size); /* hack the fshandle_t start pos and length members so * that only the relevant data is accessed from now on */ stream->fh.start += ofs; diff --git a/common/sv_main.c b/common/sv_main.c index e967a525..4c573be1 100644 --- a/common/sv_main.c +++ b/common/sv_main.c @@ -397,21 +397,13 @@ once for a player each game, not once for each level change. */ void SV_ConnectClient(int clientnum) { - edict_t *ent; - int edictnum; - struct qsocket_s *netconnection; int i; float spawn_parms[NUM_SPAWN_PARMS]; - client_t *client = svs.clients + clientnum; - - Con_DPrintf("Client %s connected\n", client->netconnection->address); - - edictnum = clientnum + 1; - - ent = EDICT_NUM(edictnum); - + client_t *client = svs.clients + clientnum; + int edictnum = clientnum + 1; + edict_t *ent = EDICT_NUM(edictnum); // set up the client_t - netconnection = client->netconnection; + struct qsocket_s *netconnection = client->netconnection; if (sv.loadgame) memcpy(spawn_parms, client->spawn_parms, sizeof(spawn_parms)); @@ -1221,7 +1213,6 @@ void SV_SpawnServer(char *server) Cvar_Set("hostname", "UNNAMED"); scr_centertime_off = 0; - Con_DPrintf("SpawnServer: %s\n", server); svs.changelevel_issued = false; // now safe to issue another // @@ -1351,6 +1342,4 @@ void SV_SpawnServer(char *server) i++, host_client++) if (host_client->active) SV_SendServerinfo(host_client); - - Con_DPrintf("Server spawned.\n"); } diff --git a/common/sv_phys.c b/common/sv_phys.c index b0eedb5b..bf94b639 100644 --- a/common/sv_phys.c +++ b/common/sv_phys.c @@ -674,7 +674,6 @@ SV_CheckStuck(edict_t *ent) VectorCopy(ent->v.oldorigin, ent->v.origin); if (!SV_TestEntityPosition(ent)) { - Con_DPrintf("Unstuck.\n"); SV_LinkEdict(ent, true); return; } @@ -688,14 +687,12 @@ SV_CheckStuck(edict_t *ent) ent->v.origin[2] = org[2] + z; if (!SV_TestEntityPosition(ent)) { - Con_DPrintf("Unstuck.\n"); SV_LinkEdict(ent, true); return; } } VectorCopy(org, ent->v.origin); - Con_DPrintf("player is stuck.\n"); } @@ -841,10 +838,7 @@ SV_TryUnstick(edict_t *ent, vec3_t oldvel) if ( fabs(oldorg[1] - ent->v.origin[1]) > 4 || fabs(oldorg[0] - ent->v.origin[0]) > 4) - { - //Con_DPrintf ("unstuck!\n"); return clip; - } /* go back to the original pos and try again */ VectorCopy(oldorg, ent->v.origin); diff --git a/common/sv_user.c b/common/sv_user.c index d9dc13cb..5539c56e 100644 --- a/common/sv_user.c +++ b/common/sv_user.c @@ -649,8 +649,6 @@ qboolean SV_ReadClientMessage(void) #endif if (ret == 1) Cmd_ExecuteString(s, src_client); - else - Con_DPrintf("%s tried to %s\n", host_client->name, s); break; case clc_disconnect: diff --git a/common/sys.h b/common/sys.h index e9f92a08..428f338b 100644 --- a/common/sys.h +++ b/common/sys.h @@ -24,17 +24,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include "qtypes.h" -// FIXME - QW/server doesn't want this much stuff... - // sys.h -- non-portable functions -// FIXME - don't want win only stuff in header -// minimized could be useful on other systems anyway... -#ifdef _WIN32 -//extern qboolean Minimized; -extern qboolean window_visible(void); -#endif - // // file IO // @@ -63,8 +54,6 @@ void Sys_Quit(void); double Sys_DoubleTime(void); -char *Sys_ConsoleInput(void); - // called to yield for a little bit so as // not to hog cpu when paused or debugging diff --git a/common/world.c b/common/world.c index 4f9084cc..09e69b07 100644 --- a/common/world.c +++ b/common/world.c @@ -799,13 +799,6 @@ qboolean SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, if (!SV_RecursiveHullCheck(hull, node->children[side], p1f, midf, p1, mid, trace)) return false; -#ifdef PARANOID - if (SV_HullPointContents(sv_hullmodel, mid, node->children[side]) == CONTENTS_SOLID) { - Con_Printf("mid PointInHullSolid\n"); - return false; - } -#endif - if (SV_HullPointContents(hull, node->children[side ^ 1], mid) != CONTENTS_SOLID) /* go past the node */ return SV_RecursiveHullCheck(hull, node->children[side ^ 1], midf, p2f, mid, p2, trace); @@ -842,7 +835,6 @@ qboolean SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, { trace->fraction = midf; VectorCopy (mid, trace->endpos); - Con_DPrintf ("backup past 0\n"); return false; } midf = p1f + (p2f - p1f)*frac; @@ -859,7 +851,6 @@ qboolean SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, if (frac < 0) { trace->fraction = midf; VectorCopy(mid, trace->endpos); - Con_DPrintf("backup past 0\n"); return false; } midf = p1f + (p2f - p1f) * frac; diff --git a/common/zone.c b/common/zone.c index 5e900b41..cf6bc598 100644 --- a/common/zone.c +++ b/common/zone.c @@ -347,102 +347,6 @@ void Hunk_Check(void) } } - -/* - * ============== - * Hunk_Print - * - * If "all" is specified, every single allocation is printed. - * Otherwise, allocations with the same name will be totaled up before - * printing. - * ============== - */ -static void Hunk_Print(qboolean all) -{ - hunk_t *h, *next, *endlow, *starthigh, *endhigh; - int count, sum, pwidth; - int totalblocks; - char safename[HUNK_NAMELEN + 1]; /* Zero terminated copy of hunk name */ - - count = 0; - sum = 0; - totalblocks = 0; - memset(safename, 0, sizeof(safename)); - - /* Don't put in wide spaces if not printing pointers */ - pwidth = all ? (sizeof(void *) * 2 + 2) : 8; - - h = (hunk_t *)hunk_base; - endlow = (hunk_t *)(hunk_base + hunk_low_used); - starthigh = (hunk_t *)(hunk_base + hunk_size - hunk_high_used); - endhigh = (hunk_t *)(hunk_base + hunk_size); - - Con_Printf("%*s :%10i total hunk size\n", pwidth, "", hunk_size); - Con_Printf("-------------------------\n"); - - while (1) { - /* skip to the high hunk if done with low hunk */ - if (h == endlow) - { - Con_Printf("-------------------------\n"); - Con_Printf("%*s :%10i REMAINING\n", pwidth, "", - hunk_size - hunk_low_used - hunk_high_used); - Con_Printf("-------------------------\n"); - h = starthigh; - } - - /* if totally done, break */ - if (h == endhigh) - break; - - /* run consistancy checks */ - if (h->sentinal != HUNK_SENTINAL) - Sys_Error("%s: trashed sentinal", __func__); - if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size) - Sys_Error("%s: bad size", __func__); - - next = (hunk_t *)((byte *)h + h->size); - count++; - totalblocks++; - sum += h->size; - - /* print the single block */ - memcpy(safename, h->name, HUNK_NAMELEN); - if (all) - Con_Printf("%*p :%10i %-*s\n", pwidth, h, h->size, - HUNK_NAMELEN, safename); - - /* print the total */ - if (next == endlow || next == endhigh || - strncmp(h->name, next->name, HUNK_NAMELEN)) - { - if (!all) - Con_Printf("%*s :%10i %-*s (TOTAL)\n", pwidth, "", sum, - HUNK_NAMELEN, safename); - count = 0; - sum = 0; - } - h = next; - } - Con_Printf("-------------------------\n"); - Con_Printf("%8i total blocks\n", totalblocks); -} - -static void Hunk_f(void) -{ - if (Cmd_Argc() == 2) { - if (!strcmp(Cmd_Argv(1), "print")) { - Hunk_Print(false); - return; - } - if (!strcmp(Cmd_Argv(1), "printall")) { - Hunk_Print(true); - return; - } - } - Con_Printf("Usage: hunk print|printall\n"); -} - /* * =================== * Hunk_AllocName @@ -452,10 +356,6 @@ void * Hunk_AllocName(int size, const char *name) { hunk_t *h; -#ifdef PARANOID - Hunk_Check(); -#endif - if (size < 0) Sys_Error("%s: bad size: %i", __func__, size); @@ -546,10 +446,6 @@ void *Hunk_HighAllocName(int size, const char *name) hunk_tempactive = false; } -#ifdef PARANOID - Hunk_Check(); -#endif - size = sizeof(hunk_t) + ((size + 15) & ~15); if (hunk_size - hunk_low_used - hunk_high_used < size) @@ -875,32 +771,6 @@ static void Cache_Print(void) } } -/* - * ============ - * Cache_Report - * ============ - */ -void Cache_Report(void) -{ - Con_DPrintf("%4.1f megabyte data cache\n", - (hunk_size - hunk_high_used - - hunk_low_used) / (float)(1024 * 1024)); -} - - -/* FIXME - Unused? */ -#if 0 -/* - * ============ - * Cache_Compact - * ============ - */ -static void -Cache_Compact(void) -{ -} -#endif - /* * ============ * Cache_Init @@ -1059,6 +929,5 @@ void Memory_Init(void *buf, int size) /* Needs to be added after the zone init... */ Cmd_AddCommand("flush", Cache_Flush); - Cmd_AddCommand("hunk", Hunk_f); Cmd_AddCommand("cache", Cache_f); } diff --git a/common/zone.h b/common/zone.h index aaf0975d..80dc7738 100644 --- a/common/zone.h +++ b/common/zone.h @@ -141,6 +141,4 @@ void *Cache_AllocPadded(cache_user_t *c, int pad, int size, const char *name); void Cache_Free(cache_user_t *c); -void Cache_Report(void); - #endif /* ZONE_H */ From c1fbd4c3bae09b5a613a80db91ac556f00b59dac Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 7 Jun 2022 23:47:08 +0200 Subject: [PATCH 03/48] r_pixbytes is always going to be 1 for the libretro core, get rid of alternate r_pixbytes codepaths - less conditionals, less code --- common/d_iface.h | 1 - common/d_init.c | 1 - common/draw.c | 245 +++++------------------------------------- common/model.h | 6 -- common/r_alias.c | 17 +-- common/r_main.c | 1 - common/r_sprite.c | 22 +--- common/r_surf.c | 6 +- common/sprite_model.c | 2 +- 9 files changed, 33 insertions(+), 268 deletions(-) diff --git a/common/d_iface.h b/common/d_iface.h index 51eb1c89..7c192a8b 100644 --- a/common/d_iface.h +++ b/common/d_iface.h @@ -109,7 +109,6 @@ extern qboolean r_recursiveaffinetriangles; // true if a driver wants to use extern float r_aliasuvscale; // scale-up factor for screen u and v // on Alias vertices passed to driver -extern int r_pixbytes; extern qboolean r_dowarp; extern affinetridesc_t r_affinetridesc; diff --git a/common/d_init.c b/common/d_init.c index 4ebf34f2..992f1011 100644 --- a/common/d_init.c +++ b/common/d_init.c @@ -54,7 +54,6 @@ D_Init(void) Cvar_RegisterVariable(&dither_filter); r_recursiveaffinetriangles = true; - r_pixbytes = 1; r_aliasuvscale = 1.0; } diff --git a/common/draw.c b/common/draw.c index d43b4a70..168227b7 100644 --- a/common/draw.c +++ b/common/draw.c @@ -189,7 +189,7 @@ Draw_Character(int x, int y, int num) } else drawline = 8; - if (r_pixbytes == 1) { + { dest = vid.conbuffer + y * vid.conrowbytes + x; while (drawline--) { @@ -212,32 +212,6 @@ Draw_Character(int x, int y, int num) source += 128; dest += vid.conrowbytes; } - } else { - // FIXME: pre-expand to native format? - pusdest = (unsigned short *) - ((byte *)vid.conbuffer + y * vid.conrowbytes + (x << 1)); - - while (drawline--) { - if (source[0]) - pusdest[0] = d_8to16table[source[0]]; - if (source[1]) - pusdest[1] = d_8to16table[source[1]]; - if (source[2]) - pusdest[2] = d_8to16table[source[2]]; - if (source[3]) - pusdest[3] = d_8to16table[source[3]]; - if (source[4]) - pusdest[4] = d_8to16table[source[4]]; - if (source[5]) - pusdest[5] = d_8to16table[source[5]]; - if (source[6]) - pusdest[6] = d_8to16table[source[6]]; - if (source[7]) - pusdest[7] = d_8to16table[source[7]]; - - source += 128; - pusdest += vid.conrowbytes / 2; - } } } @@ -276,18 +250,8 @@ Draw_Alt_String(int x, int y, char *str) static void Draw_Pixel(int x, int y, byte color) { - if (r_pixbytes == 1) - { - uint8_t *dest = vid.conbuffer + y * vid.conrowbytes + x; - *dest = color; - } - else - { - // FIXME: pre-expand to native format? - uint16_t *pusdest = (uint16_t*) - ((uint8_t*)vid.conbuffer + y * vid.conrowbytes + (x << 1)); - *pusdest = d_8to16table[color]; - } + uint8_t *dest = vid.conbuffer + y * vid.conrowbytes + x; + *dest = color; } void @@ -333,7 +297,6 @@ void Draw_Pic(int x, int y, const qpic_t *pic) source = pic->data; - if (r_pixbytes == 1) { uint8_t *dest = vid.buffer + y * vid.rowbytes + x; @@ -344,20 +307,6 @@ void Draw_Pic(int x, int y, const qpic_t *pic) source += pic->width; } } - else - { - // FIXME: pretranslate at load time? - uint16_t *pusdest = (uint16_t*)vid.buffer + y * (vid.rowbytes / 2) + x; - - for (v = 0; v < pic->height; v++) - { - for (u = 0; u < pic->width; u++) - pusdest[u] = d_8to16table[source[u]]; - - pusdest += vid.rowbytes / 2; - source += pic->width; - } - } } @@ -378,7 +327,6 @@ void Draw_SubPic(int x, int y, const qpic_t *pic, int srcx, int srcy, int width, source = pic->data + srcy * pic->width + srcx; - if (r_pixbytes == 1) { uint8_t *dest = vid.buffer + y * vid.rowbytes + x; @@ -389,20 +337,6 @@ void Draw_SubPic(int x, int y, const qpic_t *pic, int srcx, int srcy, int width, source += pic->width; } } - else - { - // FIXME: pretranslate at load time? - uint16_t *pusdest = (uint16_t*)vid.buffer + y * (vid.rowbytes / 2) + x; - - for (v = 0; v < height; v++) - { - for (u = srcx; u < (srcx + width); u++) - pusdest[u] = d_8to16table[source[u]]; - - pusdest += vid.rowbytes / 2; - source += pic->width; - } - } } @@ -425,7 +359,7 @@ void Draw_TransPic(int x, int y, const qpic_t *pic) source = pic->data; - if (r_pixbytes == 1) { + { dest = vid.buffer + y * vid.rowbytes + x; if (pic->width & 7) { // general @@ -461,22 +395,6 @@ void Draw_TransPic(int x, int y, const qpic_t *pic) source += pic->width; } } - } else { - // FIXME: pretranslate at load time? - pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes / 2) + x; - - for (v = 0; v < pic->height; v++) { - for (u = 0; u < pic->width; u++) { - tbyte = source[u]; - - if (tbyte != TRANSPARENT_COLOR) { - pusdest[u] = d_8to16table[tbyte]; - } - } - - pusdest += vid.rowbytes / 2; - source += pic->width; - } } } @@ -500,7 +418,7 @@ void Draw_TransPicTranslate(int x, int y, const qpic_t *pic, byte *translation) source = pic->data; - if (r_pixbytes == 1) { + { dest = vid.buffer + y * vid.rowbytes + x; if (pic->width & 7) { // general @@ -536,22 +454,6 @@ void Draw_TransPicTranslate(int x, int y, const qpic_t *pic, byte *translation) source += pic->width; } } - } else { - // FIXME: pretranslate at load time? - pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes / 2) + x; - - for (v = 0; v < pic->height; v++) { - for (u = 0; u < pic->width; u++) { - tbyte = source[u]; - - if (tbyte != TRANSPARENT_COLOR) { - pusdest[u] = d_8to16table[tbyte]; - } - } - - pusdest += vid.rowbytes / 2; - source += pic->width; - } } } @@ -562,18 +464,14 @@ void Draw_TransPicTranslate(int x, int y, const qpic_t *pic, byte *translation) static void Draw_ScaledCharToConback(const qpic_t *conback, int num, byte *dest) { - int row, col; - byte *source, *src; - int drawlines, drawwidth; - int x, y, fstep, f; - - drawlines = conback->height * CHAR_HEIGHT / 200; - drawwidth = conback->width * CHAR_WIDTH / 320; - - row = num >> 4; - col = num & 15; - source = draw_chars + (row << 10) + (col << 3); - fstep = 320 * 0x10000 / conback->width; + byte *src; + int x, y, f; + int drawlines = conback->height * CHAR_HEIGHT / 200; + int drawwidth = conback->width * CHAR_WIDTH / 320; + int row = num >> 4; + int col = num & 15; + byte *source = draw_chars + (row << 10) + (col << 3); + int fstep = 320 * 0x10000 / conback->width; for (y = 0; y < drawlines; y++, dest += conback->width) { src = source + (y * CHAR_HEIGHT / drawlines) * 128; @@ -597,14 +495,11 @@ Draw_ScaledCharToConback(const qpic_t *conback, int num, byte *dest) static void Draw_ConbackString(qpic_t *cb, const char *str) { - int len, row, col, x; - byte *dest; - - len = strlen(str); - row = cb->height - ((CHAR_HEIGHT + 6) * cb->height / 200); - col = cb->width - ((11 + CHAR_WIDTH * len) * cb->width / 320); - - dest = cb->data + cb->width * row + col; + int x; + int len = strlen(str); + int row = cb->height - ((CHAR_HEIGHT + 6) * cb->height / 200); + int col = cb->width - ((11 + CHAR_WIDTH * len) * cb->width / 320); + byte *dest = cb->data + cb->width * row + col; for (x = 0; x < len; x++) Draw_ScaledCharToConback(cb, str[x], dest + (x * CHAR_WIDTH * cb->width / 320)); @@ -625,15 +520,13 @@ Draw_ConsoleBackground(int lines) byte *dest; unsigned short *pusdest; int f, fstep; - qpic_t *conback; - - conback = Draw_CachePic("gfx/conback.lmp"); + qpic_t *conback = Draw_CachePic("gfx/conback.lmp"); /* hack the version number directly into the pic */ Draw_ConbackString(conback, stringify(TYR_VERSION)); /* draw the pic */ - if (r_pixbytes == 1) { + { dest = vid.conbuffer; for (y = 0; y < lines; y++, dest += vid.conrowbytes) { @@ -656,27 +549,6 @@ Draw_ConsoleBackground(int lines) } } } - } else { - pusdest = (unsigned short *)vid.conbuffer; - - for (y = 0; y < lines; y++, pusdest += vid.conrowbytes / 2) { - // FIXME: pre-expand to native format? - // FIXME: does the endian switching go away in production? - v = (vid.conheight - lines + y) * conback->height / vid.conheight; - src = conback->data + v * conback->width; - f = 0; - fstep = conback->width * 0x10000 / vid.conwidth; - for (x = 0; x < vid.conwidth; x += 4) { - pusdest[x] = d_8to16table[src[f >> 16]]; - f += fstep; - pusdest[x + 1] = d_8to16table[src[f >> 16]]; - f += fstep; - pusdest[x + 2] = d_8to16table[src[f >> 16]]; - f += fstep; - pusdest[x + 3] = d_8to16table[src[f >> 16]]; - f += fstep; - } - } } } @@ -690,13 +562,10 @@ static void R_DrawRect8(vrect_t *prect, int rowbytes, const byte *psrc, int transparent) { byte t; - int i, j, srcdelta, destdelta; - byte *pdest; - - pdest = vid.buffer + (prect->y * vid.rowbytes) + prect->x; - - srcdelta = rowbytes - prect->width; - destdelta = vid.rowbytes - prect->width; + int i, j; + byte *pdest = vid.buffer + (prect->y * vid.rowbytes) + prect->x; + int srcdelta = rowbytes - prect->width; + int destdelta = vid.rowbytes - prect->width; if (transparent) { for (i = 0; i < prect->height; i++) { @@ -722,57 +591,6 @@ R_DrawRect8(vrect_t *prect, int rowbytes, const byte *psrc, int transparent) } } - -/* -============== -R_DrawRect16 -============== -*/ -static void -R_DrawRect16(vrect_t *prect, int rowbytes, const byte *psrc, int transparent) -{ - byte t; - int i, j, srcdelta, destdelta; - unsigned short *pdest; - -// FIXME: would it be better to pre-expand native-format versions? - - pdest = (unsigned short *)vid.buffer; - pdest += prect->y * (vid.rowbytes / 2) + prect->x; - - srcdelta = rowbytes - prect->width; - destdelta = (vid.rowbytes / 2) - prect->width; - - if (transparent) { - for (i = 0; i < prect->height; i++) { - for (j = 0; j < prect->width; j++) { - t = *psrc; - if (t != TRANSPARENT_COLOR) { - *pdest = d_8to16table[t]; - } - - psrc++; - pdest++; - } - - psrc += srcdelta; - pdest += destdelta; - } - } else { - for (i = 0; i < prect->height; i++) { - for (j = 0; j < prect->width; j++) { - *pdest = d_8to16table[*psrc]; - psrc++; - pdest++; - } - - psrc += srcdelta; - pdest += destdelta; - } - } -} - - /* ============= Draw_TileClear @@ -829,11 +647,7 @@ Draw_TileClear(int x, int y, int w, int h) psrc = r_rectdesc.ptexbytes + (tileoffsety * r_rectdesc.rowbytes) + tileoffsetx; - if (r_pixbytes == 1) { - R_DrawRect8(&vr, r_rectdesc.rowbytes, psrc, 0); - } else { - R_DrawRect16(&vr, r_rectdesc.rowbytes, psrc, 0); - } + R_DrawRect8(&vr, r_rectdesc.rowbytes, psrc, 0); vr.x += vr.width; width -= vr.width; @@ -867,18 +681,11 @@ Draw_Fill(int x, int y, int w, int h, int c) return; } - if (r_pixbytes == 1) { + { dest = vid.buffer + y * vid.rowbytes + x; for (v = 0; v < h; v++, dest += vid.rowbytes) for (u = 0; u < w; u++) dest[u] = c; - } else { - uc = d_8to16table[c]; - - pusdest = (unsigned short *)vid.buffer + y * (vid.rowbytes / 2) + x; - for (v = 0; v < h; v++, pusdest += vid.rowbytes / 2) - for (u = 0; u < w; u++) - pusdest[u] = uc; } } diff --git a/common/model.h b/common/model.h index 8dfa5041..41ef3674 100644 --- a/common/model.h +++ b/common/model.h @@ -246,12 +246,6 @@ typedef struct mspriteframe_s { byte rdata[1]; /* Renderer data, variable sized */ } mspriteframe_t; -/* - * Renderer provides this function to specify the amount of space it needs for - * a sprite frame with given pixel count - */ -int R_SpriteDataSize(int numpixels); - /* * Renderer provides this function to translate and store the raw sprite data * from the model file as needed. diff --git a/common/r_alias.c b/common/r_alias.c index e7ad61ad..07ec0c7d 100644 --- a/common/r_alias.c +++ b/common/r_alias.c @@ -102,20 +102,11 @@ SW_LoadSkinData(const char *modelname, aliashdr_t *ahdr, int skinnum, byte *ret, *out; skinsize = ahdr->skinwidth * ahdr->skinheight; - ret = out = (byte*)Hunk_Alloc(skinnum * skinsize * r_pixbytes); + ret = out = (byte*)Hunk_Alloc(skinnum * skinsize); for (i = 0; i < skinnum; i++) { - if (r_pixbytes == 1) { - memcpy(out, skindata[i], skinsize); - } else if (r_pixbytes == 2) { - unsigned short *skin16 = (unsigned short *)out; - for (j = 0; j < skinsize; j++) - skin16[j] = d_8to16table[skindata[i][j]]; - } else { - Sys_Error("%s: driver set invalid r_pixbytes: %d", __func__, - r_pixbytes); - } - out += skinsize * r_pixbytes; + memcpy(out, skindata[i], skinsize); + out += skinsize; } return ret; @@ -679,7 +670,7 @@ static void R_AliasSetupSkin(const entity_t *e, aliashdr_t *pahdr) frame += Mod_FindInterval(intervals, numframes, cl.time + e->syncbase); } - skinbytes = pahdr->skinwidth * pahdr->skinheight * r_pixbytes; + skinbytes = pahdr->skinwidth * pahdr->skinheight; pdata = (byte *)pahdr + pahdr->skindata; pdata += frame * skinbytes; diff --git a/common/r_main.c b/common/r_main.c index 005e15ff..07827f30 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -35,7 +35,6 @@ int r_numallocatededges; qboolean r_recursiveaffinetriangles = true; -int r_pixbytes = 1; float r_aliasuvscale = 1.0; int r_outofsurfaces; int r_outofedges; diff --git a/common/r_sprite.c b/common/r_sprite.c index 22c97853..b76fb05f 100644 --- a/common/r_sprite.c +++ b/common/r_sprite.c @@ -31,33 +31,13 @@ static int sprite_width, sprite_height; spritedesc_t r_spritedesc; -int -R_SpriteDataSize(int pixels) -{ - return pixels * r_pixbytes; -} - void R_SpriteDataStore(mspriteframe_t *frame, const char *modelname, int framenum, byte *pixels) { int i; int size = frame->width * frame->height; - if (r_pixbytes == 1) - { - memcpy(&frame->rdata[0], pixels, size); - } - else if (r_pixbytes == 2) - { - unsigned short *pixout = (unsigned short *)&frame->rdata[0]; - for (i = 0; i < size; i++) - pixout[i] = d_8to16table[pixels[i]]; - } - else - { - Sys_Error("%s: driver set invalid r_pixbytes: %d", __func__, - r_pixbytes); - } + memcpy(&frame->rdata[0], pixels, size); } /* diff --git a/common/r_surf.c b/common/r_surf.c index 27cd5b89..e4013f5b 100644 --- a/common/r_surf.c +++ b/common/r_surf.c @@ -465,7 +465,7 @@ void R_DrawSurface(void) //============================== - if (r_pixbytes == 1) { + { if (coloredlights) pblockdrawer = surfmiptableRGB[r_drawsurf.surfmip]; // 18-bit lookups else @@ -473,10 +473,6 @@ void R_DrawSurface(void) // TODO: only needs to be set when there is a display settings change horzblockstep = blocksize; - } else { - pblockdrawer = R_DrawSurfaceBlock16; - // TODO: only needs to be set when there is a display settings change - horzblockstep = blocksize << 1; } smax = mt->width >> r_drawsurf.surfmip; diff --git a/common/sprite_model.c b/common/sprite_model.c index 11f8a547..f00e2a3b 100644 --- a/common/sprite_model.c +++ b/common/sprite_model.c @@ -48,7 +48,7 @@ static void * Mod_LoadSpriteFrame(void *pin, mspriteframe_t **ppframe, const cha int height = (pinframe->height); #endif int numpixels = width * height; - int size = sizeof(mspriteframe_t) + R_SpriteDataSize(numpixels); + int size = sizeof(mspriteframe_t) + numpixels; mspriteframe_t *pspriteframe = (mspriteframe_t*)Hunk_AllocName(size, loadname); memset(pspriteframe, 0, size); From e0cc02b957b25c304a4f2d2cf9edfe85a67c8b45 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 7 Jun 2022 23:49:55 +0200 Subject: [PATCH 04/48] Get rid of unused msg_suppress_ --- QW/client/quakedef.h | 4 ---- common/common.c | 2 -- common/d_surf.c | 3 --- common/host.h | 3 --- 4 files changed, 12 deletions(-) diff --git a/QW/client/quakedef.h b/QW/client/quakedef.h index f1fd7850..e91a6ff6 100644 --- a/QW/client/quakedef.h +++ b/QW/client/quakedef.h @@ -86,10 +86,6 @@ void Host_ClientCommands(const char *fmt, ...) __attribute__((format(printf,1,2))); void Host_ShutdownServer(qboolean crash); -extern qboolean msg_suppress_1; // suppresses resolution and cache size console - - // output and fullscreen DIB focus gain/loss - // // Hacks - FIXME - well, "hacks" says it all really... // diff --git a/common/common.c b/common/common.c index 38ced5c0..e48f3fb6 100644 --- a/common/common.c +++ b/common/common.c @@ -84,8 +84,6 @@ static cvar_t cmdline = { "cmdline", "0", false, true }; static qboolean com_modified; // set true if using non-id files static int static_registered = 1; // only for startup check, then set -qboolean msg_suppress_1 = 0; - static void COM_InitFilesystem(void); static void *SZ_GetSpace(sizebuf_t *buf, int length); diff --git a/common/d_surf.c b/common/d_surf.c index 07bbf436..f9f50a82 100644 --- a/common/d_surf.c +++ b/common/d_surf.c @@ -89,9 +89,6 @@ D_InitCaches void D_InitCaches(void *buffer, int size) { - if (!msg_suppress_1) - Con_Printf("%ik surface cache\n", size / 1024); - sc_size = size - GUARDSIZE; sc_base = (surfcache_t *)buffer; sc_rover = sc_base; diff --git a/common/host.h b/common/host.h index e9444544..800f50dd 100644 --- a/common/host.h +++ b/common/host.h @@ -51,9 +51,6 @@ void Host_Quit_f(void); void Host_ClientCommands(const char *fmt, ...); void Host_ShutdownServer(qboolean crash); -extern qboolean msg_suppress_1; // suppresses resolution and cache size console - - // output an fullscreen DIB focus gain/loss extern int current_skill; // skill level for currently loaded level (in // case the user changes the cvar while the From fe821a7f25d98cd2bd3b2a645e12b65df48d78ba Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Tue, 7 Jun 2022 23:59:51 +0200 Subject: [PATCH 05/48] Get rid of some unused variables as a result of earlier code refactors --- common/draw.c | 10 ++----- common/r_alias.c | 66 ++++++++++++++++------------------------------- common/r_local.h | 1 - common/r_misc.c | 1 - common/r_sprite.c | 2 -- 5 files changed, 24 insertions(+), 56 deletions(-) diff --git a/common/draw.c b/common/draw.c index 168227b7..2ef61f05 100644 --- a/common/draw.c +++ b/common/draw.c @@ -164,7 +164,6 @@ Draw_Character(int x, int y, int num) { byte *dest; byte *source; - unsigned short *pusdest; int drawline; int row, col; @@ -289,7 +288,7 @@ Draw_Pic void Draw_Pic(int x, int y, const qpic_t *pic) { const byte *source; - int v, u; + int v; if (x < 0 || x + pic->width > vid.width || y < 0 || y + pic->height > vid.height) @@ -319,7 +318,7 @@ void Draw_SubPic(int x, int y, const qpic_t *pic, int srcx, int srcy, int width, int height) { const byte *source; - int v, u; + int v; if (x < 0 || x + width > vid.width || y < 0 || y + height > vid.height) @@ -349,7 +348,6 @@ void Draw_TransPic(int x, int y, const qpic_t *pic) { byte *dest, tbyte; const byte *source; - unsigned short *pusdest; int v, u; if (x < 0 || (unsigned)(x + pic->width) > vid.width || @@ -408,7 +406,6 @@ void Draw_TransPicTranslate(int x, int y, const qpic_t *pic, byte *translation) { byte *dest, tbyte; const byte *source; - unsigned short *pusdest; int v, u; if (x < 0 || (unsigned)(x + pic->width) > vid.width || @@ -518,7 +515,6 @@ Draw_ConsoleBackground(int lines) int x, y, v; const byte *src; byte *dest; - unsigned short *pusdest; int f, fstep; qpic_t *conback = Draw_CachePic("gfx/conback.lmp"); @@ -672,8 +668,6 @@ void Draw_Fill(int x, int y, int w, int h, int c) { byte *dest; - unsigned short *pusdest; - unsigned uc; int u, v; if (x < 0 || x + w > vid.width || y < 0 || y + h > vid.height) { diff --git a/common/r_alias.c b/common/r_alias.c index 07ec0c7d..656cd475 100644 --- a/common/r_alias.c +++ b/common/r_alias.c @@ -48,7 +48,6 @@ static model_t *pmodel; static vec3_t alias_forward, alias_right, alias_up; -int r_amodels_drawn; int a_skinwidth; int r_anumverts; @@ -98,10 +97,9 @@ static void * SW_LoadSkinData(const char *modelname, aliashdr_t *ahdr, int skinnum, byte **skindata) { - int i, j, skinsize; + int i; byte *ret, *out; - - skinsize = ahdr->skinwidth * ahdr->skinheight; + int skinsize = ahdr->skinwidth * ahdr->skinheight; ret = out = (byte*)Hunk_Alloc(skinnum * skinsize); for (i = 0; i < skinnum; i++) { @@ -117,14 +115,13 @@ SW_LoadMeshData(const model_t *model, aliashdr_t *hdr, const mtriangle_t *tris, const stvert_t *stverts, const trivertx_t **verts) { int i; - trivertx_t *pverts; stvert_t *pstverts; mtriangle_t *ptris; /* * Save the pose vertex data */ - pverts = (trivertx_t*)Hunk_Alloc(hdr->numposes * hdr->numverts * sizeof(*pverts)); + trivertx_t *pverts = (trivertx_t*)Hunk_Alloc(hdr->numposes * hdr->numverts * sizeof(*pverts)); hdr->posedata = (byte *)pverts - (byte *)hdr; for (i = 0; i < hdr->numposes; i++) { memcpy(pverts, verts[i], hdr->numverts * sizeof(*pverts)); @@ -176,7 +173,7 @@ qboolean R_AliasCheckBBox(entity_t *e) finalvert_t viewpts[16]; auxvert_t viewaux[16]; maliasframedesc_t *pframedesc; - qboolean zclipped, zfullyclipped; + qboolean zclipped = false, zfullyclipped = true; unsigned anyclip, allclip; int minz; @@ -214,9 +211,6 @@ qboolean R_AliasCheckBBox(entity_t *e) basepts[2][2] = basepts[3][2] = basepts[6][2] = basepts[7][2] = (float)pframedesc->bboxmax.v[2]; - zclipped = false; - zfullyclipped = true; - minz = 9999; for (i = 0; i < 8; i++) { @@ -348,13 +342,11 @@ R_AliasPreparePoints(aliashdr_t *pahdr, finalvert_t *pfinalverts, auxvert_t *pauxverts) { int i; - stvert_t *pstverts; finalvert_t *fv; auxvert_t *av; mtriangle_t *ptri; finalvert_t *pfv[3]; - - pstverts = (stvert_t *)((byte *)pahdr + SW_Aliashdr(pahdr)->stverts); + stvert_t *pstverts = (stvert_t *)((byte *)pahdr + SW_Aliashdr(pahdr)->stverts); r_anumverts = pahdr->numverts; fv = pfinalverts; av = pauxverts; @@ -603,10 +595,8 @@ R_AliasProjectFinalVert void R_AliasProjectFinalVert(finalvert_t *fv, auxvert_t *av) { - float zi; - -// project points - zi = 1.0 / av->fv[2]; + // project points + float zi = 1.0 / av->fv[2]; fv->v[5] = zi * ziscale; @@ -623,9 +613,7 @@ R_AliasPrepareUnclippedPoints static void R_AliasPrepareUnclippedPoints(aliashdr_t *pahdr, finalvert_t *pfinalverts) { - stvert_t *pstverts; - - pstverts = (stvert_t *)((byte *)pahdr + SW_Aliashdr(pahdr)->stverts); + stvert_t *pstverts = (stvert_t *)((byte *)pahdr + SW_Aliashdr(pahdr)->stverts); r_anumverts = pahdr->numverts; R_AliasTransformAndProjectFinalVerts(pfinalverts, pstverts); @@ -735,18 +723,17 @@ static trivertx_t * R_AliasBlendPoseVerts(const entity_t *e, aliashdr_t *hdr, float blend) { static trivertx_t blendverts[MAXALIASVERTS]; - trivertx_t *poseverts, *pv1, *pv2, *light; - int i, blend0, blend1; + int i; #define SHIFT 22 - blend1 = blend * (1 << SHIFT); - blend0 = (1 << SHIFT) - blend1; + int blend1 = blend * (1 << SHIFT); + int blend0 = (1 << SHIFT) - blend1; - poseverts = (trivertx_t *)((byte *)hdr + hdr->posedata); - pv1 = poseverts + e->previouspose * hdr->numverts; - pv2 = poseverts + e->currentpose * hdr->numverts; - light = (blend < 0.5f) ? pv1 : pv2; - poseverts = blendverts; + trivertx_t *poseverts = (trivertx_t *)((byte *)hdr + hdr->posedata); + trivertx_t *pv1 = poseverts + e->previouspose * hdr->numverts; + trivertx_t *pv2 = poseverts + e->currentpose * hdr->numverts; + trivertx_t *light = (blend < 0.5f) ? pv1 : pv2; + poseverts = blendverts; for (i = 0; i < hdr->numverts; i++, poseverts++, pv1++, pv2++, light++) { poseverts->v[0] = (pv1->v[0] * blend0 + pv2->v[0] * blend1) >> SHIFT; @@ -777,7 +764,7 @@ R_AliasSetupFrame(entity_t *e, aliashdr_t *pahdr) if ((frame >= pahdr->numframes) || (frame < 0)) frame = 0; - pose = pahdr->frames[frame].firstpose; + pose = pahdr->frames[frame].firstpose; numposes = pahdr->frames[frame].numposes; if (numposes > 1) { @@ -845,22 +832,13 @@ R_AliasDrawModel */ void R_AliasDrawModel(entity_t *e, alight_t *plighting) { - aliashdr_t *pahdr; - finalvert_t *pfinalverts; - finalvert_t *finalverts; - auxvert_t *pauxverts; - auxvert_t *auxverts = malloc(sizeof(auxvert_t) * MAXALIASVERTS); - - finalverts = malloc(sizeof(finalvert_t)*CACHE_PAD_ARRAY(MAXALIASVERTS, finalvert_t)); - - r_amodels_drawn++; - + auxvert_t *auxverts = (auxvert_t*)malloc(sizeof(auxvert_t) * MAXALIASVERTS); + finalvert_t *finalverts = (finalvert_t*)malloc(sizeof(finalvert_t)*CACHE_PAD_ARRAY(MAXALIASVERTS, finalvert_t)); // cache align - pfinalverts = (finalvert_t *) + finalvert_t *pfinalverts = (finalvert_t *) (((uintptr_t)&finalverts[0] + CACHE_SIZE - 1) & ~(uintptr_t)(CACHE_SIZE - 1)); - pauxverts = &auxverts[0]; - - pahdr = (aliashdr_t*)Mod_Extradata(e->model); + auxvert_t *pauxverts = &auxverts[0]; + aliashdr_t *pahdr = (aliashdr_t*)Mod_Extradata(e->model); R_AliasSetupSkin(e, pahdr); R_AliasSetUpTransform(e, pahdr, e->trivial_accept); diff --git a/common/r_local.h b/common/r_local.h index 0ae2b214..65b2f268 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -193,7 +193,6 @@ void R_ReadPointFile_f(void); void R_PushDlights (struct mnode_s *headnode); //qbism - moved from render.h -extern int r_amodels_drawn; extern edge_t *auxedges; extern int r_numallocatededges; extern edge_t *r_edges, *edge_p, *edge_max; diff --git a/common/r_misc.c b/common/r_misc.c index b3038f9c..8119aa88 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -345,7 +345,6 @@ R_SetupFrame(void) c_faceclip = 0; r_polycount = 0; r_drawnpolycount = 0; - r_amodels_drawn = 0; r_outofsurfaces = 0; r_outofedges = 0; diff --git a/common/r_sprite.c b/common/r_sprite.c index b76fb05f..8fca4811 100644 --- a/common/r_sprite.c +++ b/common/r_sprite.c @@ -34,9 +34,7 @@ spritedesc_t r_spritedesc; void R_SpriteDataStore(mspriteframe_t *frame, const char *modelname, int framenum, byte *pixels) { - int i; int size = frame->width * frame->height; - memcpy(&frame->rdata[0], pixels, size); } From 4f468cccaf4e5d40d384972979a91f49448eab27 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 00:08:13 +0200 Subject: [PATCH 06/48] Get rid of unused frontend VID_ functions in libretro.c --- QW/client/menu.c | 9 ++------- QW/client/view.c | 2 +- common/input.h | 3 --- common/libretro.c | 35 ++++------------------------------- common/menu.c | 7 +------ common/r_misc.c | 2 +- common/vid.h | 11 ----------- common/view.c | 2 +- 8 files changed, 10 insertions(+), 61 deletions(-) diff --git a/QW/client/menu.c b/QW/client/menu.c index ea287074..bc55b2b9 100644 --- a/QW/client/menu.c +++ b/QW/client/menu.c @@ -450,12 +450,7 @@ M_Options_Draw(void) if (vid_menudrawfn) M_Print(16, 144, " Video Options"); - if (!VID_IsFullScreen()) { - M_Print(16, 152, " Use Mouse"); - M_DrawCheckbox(220, 152, _windowed_mouse.value); - } - -// cursor + // cursor M_DrawCharacter(200, 32 + options_cursor * 8, 12 + ((int)(realtime * 4) & 1)); } @@ -522,7 +517,7 @@ M_Options_Key(int k) } } - if (options_cursor == 15 && VID_IsFullScreen()) { + if (options_cursor == 15) { if (k == K_UPARROW) { options_cursor--; if (!vid_menudrawfn) diff --git a/QW/client/view.c b/QW/client/view.c index 431c4c7d..1950e211 100644 --- a/QW/client/view.c +++ b/QW/client/view.c @@ -555,7 +555,7 @@ V_UpdatePalette(void) newpal += 3; } - VID_ShiftPalette(pal); + VID_SetPalette(pal); } /* diff --git a/common/input.h b/common/input.h index 0fe5a776..15775ab6 100644 --- a/common/input.h +++ b/common/input.h @@ -48,9 +48,6 @@ void IN_Commands(void); void IN_Move(usercmd_t *cmd); // add additional movement on top of the keyboard move cmd -void IN_ModeChanged(void); -// called whenever screen dimensions change - void IN_ClearStates(void); // restores all button and position states to defaults diff --git a/common/libretro.c b/common/libretro.c index 83f25f96..93b08f8a 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -1287,7 +1287,6 @@ void VID_SetPalette(unsigned char *palette) for(i = 0, j = 0; i < 256; i++, j += 3) *pal++ = MAKECOLOR(palette[j], palette[j+1], palette[j+2]); - } unsigned d_8to24table[256]; @@ -1321,12 +1320,6 @@ void VID_SetPalette2 (unsigned char *palette) } -void VID_ShiftPalette(unsigned char *palette) -{ - - VID_SetPalette(palette); -} - void VID_Init(unsigned char *palette) { /* TODO */ @@ -1392,19 +1385,6 @@ void VID_Update(vrect_t *rects) did_flip = true; } -qboolean VID_IsFullScreen(void) -{ - return true; -} - -void VID_LockBuffer(void) -{ -} - -void VID_UnlockBuffer(void) -{ -} - void D_BeginDirectRect(int x, int y, const byte *pbitmap, int width, int height) { } @@ -1414,7 +1394,7 @@ void D_EndDirectRect(int x, int y, int width, int height) } /* - * SOUND (TODO) + * SOUND */ static void audio_process(void) @@ -1559,6 +1539,9 @@ IN_Init(void) void IN_Shutdown(void) { + int i; + for (i = 0; i < MAX_PADS; i++) + quake_devices[i] = RETRO_DEVICE_NONE; } void @@ -1651,13 +1634,3 @@ IN_Move(usercmd_t *cmd) cl.viewangles[PITCH] = -70; } } - -/* -=========== -IN_ModeChanged -=========== -*/ -void -IN_ModeChanged(void) -{ -} diff --git a/common/menu.c b/common/menu.c index 5f298e1d..1bbbc56a 100644 --- a/common/menu.c +++ b/common/menu.c @@ -1164,11 +1164,6 @@ M_OptionsVideo_Draw(void) if (vid_menudrawfn) M_Print(16, 48, " Video Options"); - if (!VID_IsFullScreen()) { - M_Print(16, 56, " Use Mouse"); - M_DrawCheckbox(220, 56, _windowed_mouse.value); - } - cvar = Cvar_FindVar("dither_filter"); M_Print(16, 64, " Dither Filtering"); M_DrawCheckbox(220, 64, cvar->value); @@ -1247,7 +1242,7 @@ M_OptionsVideo_Key(int k) else optionsvideo_cursor = 3; } - if ((optionsvideo_cursor == 3) && VID_IsFullScreen()) { + if ((optionsvideo_cursor == 3)) { if (k == K_UPARROW) { if (!vid_menudrawfn) optionsvideo_cursor = 1; diff --git a/common/r_misc.c b/common/r_misc.c index 8119aa88..07c2fde0 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -130,7 +130,7 @@ WarpPalette(void) } } - VID_ShiftPalette(newpalette); + VID_SetPalette(newpalette); } /* diff --git a/common/vid.h b/common/vid.h index c802e2ee..35396d0d 100644 --- a/common/vid.h +++ b/common/vid.h @@ -64,10 +64,6 @@ extern unsigned d_8to24table[256]; void VID_SetPalette(unsigned char *palette); -// called at startup and after any gamma correction - -void VID_ShiftPalette(unsigned char *palette); - // called for bonus and pain flashes, and for underwater color changes extern unsigned short ramps[3][256]; @@ -87,11 +83,4 @@ void VID_Shutdown(void); void VID_Update(vrect_t *rects); -// flushes the given rectangles from the view buffer to the screen - -void VID_LockBuffer(void); -void VID_UnlockBuffer(void); - -qboolean VID_IsFullScreen(void); - #endif /* VID_H */ diff --git a/common/view.c b/common/view.c index 9b1197aa..836ab928 100644 --- a/common/view.c +++ b/common/view.c @@ -560,7 +560,7 @@ void V_UpdatePalette(void) newpal += 3; } - VID_ShiftPalette(pal); + VID_SetPalette(pal); } /* From 94bf7b85b1ad92b28fe60d5c0823f8760cc0a0dc Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 00:17:28 +0200 Subject: [PATCH 07/48] (Sound) Optimize around 16bit stereo sound, libretro port will never change from this, remove all alternate code paths --- common/libretro.c | 11 +++---- common/snd_dma.c | 20 +++-------- common/snd_mix.c | 84 +++++------------------------------------------ common/sound.h | 3 -- 4 files changed, 16 insertions(+), 102 deletions(-) diff --git a/common/libretro.c b/common/libretro.c index 93b08f8a..c8f5a718 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -1468,14 +1468,11 @@ static void audio_callback(void) qboolean SNDDMA_Init(dma_t *dma) { - shm = dma; - shm->speed = audio_samplerate; - shm->channels = 2; + shm = dma; + shm->speed = audio_samplerate; shm->samplepos = 0; - shm->samplebits = 16; - shm->signed8 = 0; - shm->samples = AUDIO_BUFFER_SIZE; - shm->buffer = (unsigned char *volatile)audio_buffer; + shm->samples = AUDIO_BUFFER_SIZE; + shm->buffer = (unsigned char *volatile)audio_buffer; return true; } diff --git a/common/snd_dma.c b/common/snd_dma.c index 75028e2c..3c449420 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -53,7 +53,6 @@ int total_channels; int snd_blocked = 0; static qboolean snd_ambient = 1; -static qboolean snd_initialized = false; #define CHANNELS 2 @@ -104,9 +103,6 @@ static void SND_Callback_sfxvolume (cvar_t *var) void S_Startup(void) { - if (!snd_initialized) - return; - if (!SNDDMA_Init(&sn)) { sound_started = 0; @@ -138,8 +134,6 @@ S_Init(void) Cvar_RegisterVariable(&snd_noextraupdate); Cvar_RegisterVariable(&_snd_mixahead); - snd_initialized = true; - S_Startup(); Cvar_SetCallback(&sfxvolume, SND_Callback_sfxvolume); @@ -152,14 +146,8 @@ S_Init(void) if (sound_started) Con_Printf("Sound sampling rate: %i\n", shm->speed); -#if 0 - /* provides a tick sound until washed clean; for debugging */ - if (shm->buffer) - shm->buffer[4] = shm->buffer[5] = 0x7f; -#endif - ambient_sfx[AMBIENT_WATER] = S_PrecacheSound("ambience/water1.wav"); - ambient_sfx[AMBIENT_SKY] = S_PrecacheSound("ambience/wind2.wav"); + ambient_sfx[AMBIENT_SKY] = S_PrecacheSound("ambience/wind2.wav"); S_CodecInit(); @@ -264,12 +252,12 @@ static channel_t * SND_PickChannel(int entnum, int entchannel) { int i; - int life_left; channel_t *channel; channel_t *first_to_die = NULL; /* Check for replacement sound, or find the best one to replace */ - life_left = 0x7fffffff; + int life_left = 0x7fffffff; + for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + MAX_DYNAMIC_CHANNELS; i++) { channel = &channels[i]; /* @@ -464,7 +452,7 @@ void S_ClearBuffer(void) if (!sound_started || !shm) return; - memset(shm->buffer, 0, shm->samples * shm->samplebits / 8); + memset(shm->buffer, 0, shm->samples * 16 / 8); } /* diff --git a/common/snd_mix.c b/common/snd_mix.c index df175cf9..f3154961 100644 --- a/common/snd_mix.c +++ b/common/snd_mix.c @@ -66,7 +66,6 @@ static void Snd_WriteLinearBlastStereo16 (void) static void S_TransferStereo16 (int endtime) { - int lpos; int lpaintedtime; snd_p = (int *) paintbuffer; @@ -74,10 +73,10 @@ static void S_TransferStereo16 (int endtime) while (lpaintedtime < endtime) { - // handle recirculating buffer issues - lpos = lpaintedtime & ((shm->samples >> 1) - 1); + // handle recirculating buffer issues + int lpos = lpaintedtime & ((shm->samples >> 1) - 1); - snd_out = (short *)shm->buffer + (lpos << 1); + snd_out = (short *)shm->buffer + (lpos << 1); snd_linear_count = (shm->samples >> 1) - lpos; if (lpaintedtime + snd_linear_count > endtime) @@ -85,7 +84,7 @@ static void S_TransferStereo16 (int endtime) snd_linear_count <<= 1; - // write a linear blast of samples + // write a linear blast of samples Snd_WriteLinearBlastStereo16 (); snd_p += snd_linear_count; @@ -93,71 +92,6 @@ static void S_TransferStereo16 (int endtime) } } -static void S_TransferPaintBuffer (int endtime) -{ - int out_idx, out_mask; - int count, step, val; - int *p; - - if (shm->samplebits == 16 && shm->channels == 2) - { - S_TransferStereo16 (endtime); - return; - } - - p = (int *) paintbuffer; - count = (endtime - paintedtime) * shm->channels; - out_mask = shm->samples - 1; - out_idx = paintedtime * shm->channels & out_mask; - step = 3 - shm->channels; - - if (shm->samplebits == 16) - { - short *out = (short *)shm->buffer; - while (count--) - { - val = *p >> 8; - p+= step; - if (val > 0x7fff) - val = 0x7fff; - else if (val < (short)0x8000) - val = (short)0x8000; - out[out_idx] = val; - out_idx = (out_idx + 1) & out_mask; - } - } - else if (shm->samplebits == 8 && !shm->signed8) - { - unsigned char *out = shm->buffer; - while (count--) - { - val = *p >> 8; - p+= step; - if (val > 0x7fff) - val = 0x7fff; - else if (val < (short)0x8000) - val = (short)0x8000; - out[out_idx] = (val >> 8) + 128; - out_idx = (out_idx + 1) & out_mask; - } - } - else if (shm->samplebits == 8) /* S8 format, e.g. with Amiga AHI */ - { - signed char *out = (signed char *) shm->buffer; - while (count--) - { - val = *p >> 8; - p+= step; - if (val > 0x7fff) - val = 0x7fff; - else if (val < (short)0x8000) - val = (short)0x8000; - out[out_idx] = (val >> 8); - out_idx = (out_idx + 1) & out_mask; - } - } -} - /* =============================================================================== @@ -268,8 +202,8 @@ void S_PaintChannels (int endtime) // Con_Printf ("full stream\n"); } - // transfer out according to DMA format - S_TransferPaintBuffer(end); + // transfer out according to DMA format + S_TransferStereo16 (end); paintedtime = end; } } @@ -327,12 +261,10 @@ static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, in { int data; int left, right; - int leftvol, rightvol; signed short *sfx; int i; - - leftvol = ch->leftvol * snd_vol; - rightvol = ch->rightvol * snd_vol; + int leftvol = ch->leftvol * snd_vol; + int rightvol = ch->rightvol * snd_vol; leftvol >>= 8; rightvol >>= 8; sfx = (signed short *)sc->data + ch->pos; diff --git a/common/sound.h b/common/sound.h index b3bc59a9..23bd5d2b 100644 --- a/common/sound.h +++ b/common/sound.h @@ -63,12 +63,9 @@ typedef struct { } sfxcache_t; typedef struct { - int channels; int samples; // mono samples in buffer int submission_chunk; // don't mix less than this # int samplepos; // in mono samples - int samplebits; - int signed8; /* device opened for S8 format? (e.g. Amiga AHI) */ int speed; unsigned char *buffer; } dma_t; From c1636b1817cbbf132b98f9e149ab4c9db57faa71 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 04:23:53 +0200 Subject: [PATCH 08/48] * Remove unused IN_Commands * Remove some unused variables/command variables * Simplify audio code - shm->samples will always be constant, so use a constant define. Plan to eventually get rid of shm struct/pointer (see comment in snd_dma/snd_mix.c code that this should be removed eventually) --- QW/client/cl_main.c | 6 ---- QW/client/client.h | 1 - QW/client/quakedef.h | 2 -- QW/server/sys_unix.c | 15 ---------- common/client.h | 2 -- common/host.c | 38 +++++++------------------ common/input.h | 12 -------- common/libretro.c | 37 +----------------------- common/snd_dma.c | 32 +++++---------------- common/snd_mix.c | 68 +++++++++++++++++--------------------------- common/sound.h | 24 ++++++---------- 11 files changed, 53 insertions(+), 184 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index 0efa84a7..f1d93402 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -148,8 +148,6 @@ byte *host_colormap; netadr_t master_adr; // address of the master server -int fps_count; - static jmp_buf host_abort; static float server_version = 0;// version of server we connected to @@ -1282,9 +1280,6 @@ Host_Frame(float time) // get new key events Sys_SendKeyEvents(); - /* allow mice or other external controllers to add commands */ - IN_Commands(); - /* process console commands */ Cbuf_Execute(); @@ -1324,7 +1319,6 @@ Host_Frame(float time) CDAudio_Update(); host_framecount++; - fps_count++; } //============================================================================ diff --git a/QW/client/client.h b/QW/client/client.h index 5d9e74bf..6dcd7a3d 100644 --- a/QW/client/client.h +++ b/QW/client/client.h @@ -385,7 +385,6 @@ void CL_BeginServerConnect(void); extern int cl_numvisedicts; extern entity_t cl_visedicts[]; -extern int fps_count; extern int minimum_memory; // diff --git a/QW/client/quakedef.h b/QW/client/quakedef.h index e91a6ff6..963e5161 100644 --- a/QW/client/quakedef.h +++ b/QW/client/quakedef.h @@ -59,8 +59,6 @@ extern qboolean noclip_anglehack; // extern quakeparms_t host_parms; -extern cvar_t sys_nostdout; - extern cvar_t password; extern qboolean host_initialized; // true if into command execution diff --git a/QW/server/sys_unix.c b/QW/server/sys_unix.c index 64296700..eb3a25b0 100644 --- a/QW/server/sys_unix.c +++ b/QW/server/sys_unix.c @@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // FIXME - header hacks extern int net_socket; -static cvar_t sys_nostdout = { "sys_nostdout", "0" }; static cvar_t sys_extrasleep = { "sys_extrasleep", "0" }; static qboolean stdin_ready; @@ -131,23 +130,10 @@ Sys_Printf(const char *fmt, ...) { va_list argptr; static char text[MAX_PRINTMSG]; - unsigned char *p; va_start(argptr, fmt); vsnprintf(text, sizeof(text), fmt, argptr); va_end(argptr); - - if (sys_nostdout.value) - return; - - for (p = (unsigned char *)text; *p; p++) { - *p &= 0x7f; - if ((*p > 128 || *p < 32) && *p != 10 && *p != 13 && *p != 9) - printf("[%02x]", *p); - else - putc(*p, stdout); - } - fflush(stdout); } @@ -175,7 +161,6 @@ is marked void Sys_Init(void) { - Cvar_RegisterVariable(&sys_nostdout); Cvar_RegisterVariable(&sys_extrasleep); } diff --git a/common/client.h b/common/client.h index 1f3b96fe..424710fd 100644 --- a/common/client.h +++ b/common/client.h @@ -307,8 +307,6 @@ void CL_NextDemo(void); extern int cl_numvisedicts; extern entity_t cl_visedicts[]; -extern int fps_count; - // // cl_input // diff --git a/common/host.c b/common/host.c index baaede4c..8d2285f8 100644 --- a/common/host.c +++ b/common/host.c @@ -67,7 +67,6 @@ qboolean host_initialized; // true if into command execution double host_frametime; double host_time; double realtime; // without any filtering or bounding -static double oldrealtime; // last frame run int host_framecount; int host_hunklevel; @@ -76,8 +75,6 @@ int minimum_memory; client_t *host_client; // current client -int fps_count; - static jmp_buf host_abort; byte *host_basepal; @@ -497,17 +494,15 @@ Host_ClearMemory(void) /* =================== Host_FilterTime - -Returns false if the time is too short to run a frame =================== */ -qboolean -Host_FilterTime(float time) +static void Host_FilterTime(float time) { - realtime += time; + static double oldrealtime; // last frame run + realtime += time; host_frametime = realtime - oldrealtime; - oldrealtime = realtime; + oldrealtime = realtime; { // don't allow really long or short frames if (host_frametime > 0.1) @@ -515,8 +510,6 @@ Host_FilterTime(float time) if (host_frametime < 0.001) host_frametime = 0.001; } - - return true; } /* @@ -610,13 +603,8 @@ Host_Frame Runs all active servers ================== */ -void -_Host_Frame(float time) +static void _Host_Frame(float time) { - /* something bad happened, or the server disconnected */ - if (setjmp(host_abort)) - return; - /* keep the random time dependent */ rand(); @@ -624,15 +612,11 @@ _Host_Frame(float time) * Decide the simulation time. Don't run too fast, or packets will flood * out. */ - if (!Host_FilterTime(time)) - return; + Host_FilterTime(time); /* get new key events */ Sys_SendKeyEvents(); - /* allow mice or other external controllers to add commands */ - IN_Commands(); - /* process console commands */ Cbuf_Execute(); @@ -674,7 +658,6 @@ _Host_Frame(float time) CL_RunParticles(); host_framecount++; - fps_count++; } void @@ -683,13 +666,12 @@ Host_Frame(float time) static int timecount; int i, c; - if (!serverprofile.value) - { + /* If setjmp returns true, something bad happened, or the server disconnected */ + if (!setjmp(host_abort)) _Host_Frame(time); - return; - } - _Host_Frame(time); + if (!serverprofile.value) + return; timecount++; diff --git a/common/input.h b/common/input.h index 15775ab6..342a6122 100644 --- a/common/input.h +++ b/common/input.h @@ -42,19 +42,7 @@ extern cvar_t _windowed_mouse; void IN_Init(void); void IN_Shutdown(void); -void IN_Commands(void); -// oportunity for devices to stick commands on the script buffer - void IN_Move(usercmd_t *cmd); // add additional movement on top of the keyboard move cmd -void IN_ClearStates(void); -// restores all button and position states to defaults - -void IN_Accumulate(void); -// save accumulated mouse movement (used in S_ExtraUpdate(), _WIN32 only) - -/* FIXME - hack to allow SDL input to pass back key events... */ -void IN_ProcessEvents(void); - #endif /* INPUT_H */ diff --git a/common/libretro.c b/common/libretro.c index c8f5a718..e799ead2 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -113,13 +113,6 @@ static bool libretro_supports_bitmasks = false; #define AUDIO_SAMPLERATE_48KHZ 48000 static uint16_t audio_samplerate = AUDIO_SAMPLERATE_DEFAULT; -/* Audio buffer must be sufficient for operation - * at 10 fps - * > (2 * 44100) / 10 = 8820 total samples - * > buffer size must be a power of 2 - * > Nearest power of 2 to 8820 is 16384 */ -#define AUDIO_BUFFER_SIZE 16384 - static int16_t audio_buffer[AUDIO_BUFFER_SIZE]; static unsigned audio_buffer_ptr; @@ -453,10 +446,6 @@ double Sys_DoubleTime(void) // Sleeps for microseconds // ======================================================================= -void -IN_Accumulate(void) -{} - void Sys_HighFPPrecision(void) { } @@ -1470,8 +1459,6 @@ qboolean SNDDMA_Init(dma_t *dma) { shm = dma; shm->speed = audio_samplerate; - shm->samplepos = 0; - shm->samples = AUDIO_BUFFER_SIZE; shm->buffer = (unsigned char *volatile)audio_buffer; return true; @@ -1479,24 +1466,7 @@ qboolean SNDDMA_Init(dma_t *dma) int SNDDMA_GetDMAPos(void) { - return shm->samplepos = audio_buffer_ptr; -} - -int SNDDMA_LockBuffer(void) -{ - return 0; -} - -void SNDDMA_UnlockBuffer(void) -{ -} - -void SNDDMA_Shutdown(void) -{ -} - -void SNDDMA_Submit(void) -{ + return audio_buffer_ptr; } /* @@ -1541,11 +1511,6 @@ IN_Shutdown(void) quake_devices[i] = RETRO_DEVICE_NONE; } -void -IN_Commands(void) -{ -} - void IN_Move(usercmd_t *cmd) { diff --git a/common/snd_dma.c b/common/snd_dma.c index 3c449420..03dcfd40 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -51,7 +51,6 @@ static void S_StopAllSoundsC(void); channel_t channels[MAX_CHANNELS]; int total_channels; -int snd_blocked = 0; static qboolean snd_ambient = 1; #define CHANNELS 2 @@ -136,16 +135,13 @@ S_Init(void) S_Startup(); - Cvar_SetCallback(&sfxvolume, SND_Callback_sfxvolume); + Cvar_SetCallback(&sfxvolume, SND_Callback_sfxvolume); SND_InitScaletable(); known_sfx = (sfx_t*)Hunk_AllocName(MAX_SFX * sizeof(sfx_t), "sfx_t"); num_sfx = 0; - if (sound_started) - Con_Printf("Sound sampling rate: %i\n", shm->speed); - ambient_sfx[AMBIENT_WATER] = S_PrecacheSound("ambience/water1.wav"); ambient_sfx[AMBIENT_SKY] = S_PrecacheSound("ambience/wind2.wav"); @@ -166,8 +162,6 @@ S_Shutdown(void) shm = 0; sound_started = 0; - - SNDDMA_Shutdown(); } /* @@ -452,7 +446,7 @@ void S_ClearBuffer(void) if (!sound_started || !shm) return; - memset(shm->buffer, 0, shm->samples * 16 / 8); + memset(shm->buffer, 0, SHM_SAMPLES * 16 / 8); } /* @@ -515,8 +509,6 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f break; dst = s_rawend & (MAX_RAW_SAMPLES - 1); s_rawend++; - // s_rawsamples [dst].left = ((signed char *) data)[src * 2] * intVolume; - // s_rawsamples [dst].right = ((signed char *) data)[src * 2 + 1] * intVolume; s_rawsamples [dst].left = (((byte *) data)[src * 2] - 128) * intVolume; s_rawsamples [dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume; } @@ -532,8 +524,6 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f break; dst = s_rawend & (MAX_RAW_SAMPLES - 1); s_rawend++; - // s_rawsamples [dst].left = ((signed char *) data)[src] * intVolume; - // s_rawsamples [dst].right = ((signed char *) data)[src] * intVolume; s_rawsamples [dst].left = (((byte *) data)[src] - 128) * intVolume; s_rawsamples [dst].right = (((byte *) data)[src] - 128) * intVolume; } @@ -592,9 +582,6 @@ S_UpdateAmbientSounds(void) mleaf_t *leaf; int ambient_channel; - if (!snd_ambient) - return; - /* calc ambient sound levels */ if (!cl.worldmodel) return; @@ -639,7 +626,7 @@ static void GetSoundtime(void) { static int buffers; static int oldsamplepos; - int fullsamples = shm->samples / CHANNELS; + int fullsamples = SHM_SAMPLES / CHANNELS; /* * it is possible to miscount buffers if it has wrapped twice between @@ -670,9 +657,6 @@ static void S_Update_(void) unsigned endtime; int samps; - if (!sound_started || (snd_blocked > 0)) - return; - /* Updates DMA time */ GetSoundtime(); @@ -682,12 +666,11 @@ static void S_Update_(void) paintedtime = soundtime; /* mix ahead of current position */ endtime = soundtime + _snd_mixahead.value * shm->speed; - samps = shm->samples >> 1; + samps = SHM_SAMPLES >> 1; if (endtime - soundtime > samps) endtime = soundtime + samps; S_PaintChannels(endtime); - SNDDMA_Submit(); } /* @@ -703,7 +686,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) channel_t *ch; channel_t *combine; - if (!sound_started || (snd_blocked > 0)) + if (!sound_started) return; VectorCopy(origin, listener_origin); @@ -712,7 +695,8 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) VectorCopy(up, listener_up); /* update general area ambient sound sources */ - S_UpdateAmbientSounds(); + if (snd_ambient) + S_UpdateAmbientSounds(); combine = NULL; @@ -761,8 +745,6 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) S_Update_(); } - - /* =============================================================================== diff --git a/common/snd_mix.c b/common/snd_mix.c index f3154961..17f4215d 100644 --- a/common/snd_mix.c +++ b/common/snd_mix.c @@ -74,11 +74,11 @@ static void S_TransferStereo16 (int endtime) while (lpaintedtime < endtime) { // handle recirculating buffer issues - int lpos = lpaintedtime & ((shm->samples >> 1) - 1); + int lpos = lpaintedtime & ((SHM_SAMPLES >> 1) - 1); snd_out = (short *)shm->buffer + (lpos << 1); - snd_linear_count = (shm->samples >> 1) - lpos; + snd_linear_count = (SHM_SAMPLES >> 1) - lpos; if (lpaintedtime + snd_linear_count > endtime) snd_linear_count = endtime - lpaintedtime; @@ -114,15 +114,15 @@ void S_PaintChannels (int endtime) while (paintedtime < endtime) { - // if paintbuffer is smaller than DMA buffer + // if paintbuffer is smaller than DMA buffer end = endtime; if (endtime - paintedtime > PAINTBUFFER_SIZE) end = paintedtime + PAINTBUFFER_SIZE; - // clear the paint buffer + // clear the paint buffer memset(paintbuffer, 0, (end - paintedtime) * sizeof(portable_samplepair_t)); - // paint in the channels. + // paint in the channels. ch = channels; for (i = 0; i < total_channels; i++, ch++) { @@ -155,7 +155,7 @@ void S_PaintChannels (int endtime) ltime += count; } - // if at end of loop, restart + // if at end of loop, restart if (ltime >= ch->end) { if (sc->loopstart >= 0) @@ -172,34 +172,28 @@ void S_PaintChannels (int endtime) } } - // clip each sample to 0dB, then reduce by 6dB (to leave some headroom for - // the lowpass filter and the music). the lowpass will smooth out the - // clipping + // clip each sample to 0dB, then reduce by 6dB (to leave some headroom for + // the lowpass filter and the music). the lowpass will smooth out the + // clipping for (i=0; i= paintedtime) { // copy from the streaming sound source - int s; - int stop; - - stop = (end < s_rawend) ? end : s_rawend; + int s; + int stop = (end < s_rawend) ? end : s_rawend; for (i = paintedtime; i < stop; i++) { s = i & (MAX_RAW_SAMPLES - 1); - // lower music by 6db to match sfx + // lower music by 6db to match sfx paintbuffer[i - paintedtime].left += s_rawsamples[s].left; paintbuffer[i - paintedtime].right += s_rawsamples[s].right; } - // if (i != end) - // Con_Printf ("partial stream\n"); - // else - // Con_Printf ("full stream\n"); } // transfer out according to DMA format @@ -211,11 +205,10 @@ void S_PaintChannels (int endtime) void SND_InitScaletable (void) { int i, j; - int scale; for (i = 0; i < 32; i++) { - scale = i * 8 * 256 * sfxvolume.value; + int scale = i * 8 * 256 * sfxvolume.value; for (j = 0; j < 256; j++) { /* When compiling with gcc-4.1.0 at optimisations O1 and @@ -224,7 +217,6 @@ void SND_InitScaletable (void) value from the index as required. From Kevin Shanahan. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26719 */ - // snd_scaletable[i][j] = ((signed char)j) * scale; snd_scaletable[i][j] = ((j < 128) ? j : j - 256) * scale; } } @@ -233,7 +225,6 @@ void SND_InitScaletable (void) static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) { - int data; int *lscale, *rscale; unsigned char *sfx; int i; @@ -249,8 +240,8 @@ static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int for (i = 0; i < count; i++) { - data = sfx[i]; - paintbuffer[paintbufferstart + i].left += lscale[data]; + int data = sfx[i]; + paintbuffer[paintbufferstart + i].left += lscale[data]; paintbuffer[paintbufferstart + i].right += rscale[data]; } @@ -259,26 +250,19 @@ static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) { - int data; - int left, right; - signed short *sfx; - int i; - int leftvol = ch->leftvol * snd_vol; - int rightvol = ch->rightvol * snd_vol; - leftvol >>= 8; - rightvol >>= 8; - sfx = (signed short *)sc->data + ch->pos; + int i; + int leftvol = (ch->leftvol * snd_vol) >> 8; + int rightvol = (ch->rightvol * snd_vol) >> 8; + signed short *sfx = (signed short *)sc->data + ch->pos; for (i = 0; i < count; i++) { - data = sfx[i]; - // this was causing integer overflow as observed in quakespasm - // with the warpspasm mod moved >>8 to left/right volume above. - // left = (data * leftvol) >> 8; - // right = (data * rightvol) >> 8; - left = data * leftvol; - right = data * rightvol; - paintbuffer[paintbufferstart + i].left += left; + int data = sfx[i]; + // this was causing integer overflow as observed in quakespasm + // with the warpspasm mod moved >>8 to left/right volume above. + int left = data * leftvol; + int right = data * rightvol; + paintbuffer[paintbufferstart + i].left += left; paintbuffer[paintbufferstart + i].right += right; } diff --git a/common/sound.h b/common/sound.h index 23bd5d2b..43069fac 100644 --- a/common/sound.h +++ b/common/sound.h @@ -33,6 +33,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "bothdefs.h" #endif +/* Audio buffer must be sufficient for operation + * at 10 fps + * > (2 * 44100) / 10 = 8820 total samples + * > buffer size must be a power of 2 + * > Nearest power of 2 to 8820 is 16384 */ +#define AUDIO_BUFFER_SIZE 16384 + +#define SHM_SAMPLES AUDIO_BUFFER_SIZE + // sound.h -- client sound i/o functions // FIXME - QW defines these in protocol.h, which is better? @@ -63,9 +72,6 @@ typedef struct { } sfxcache_t; typedef struct { - int samples; // mono samples in buffer - int submission_chunk; // don't mix less than this # - int samplepos; // in mono samples int speed; unsigned char *buffer; } dma_t; @@ -107,7 +113,6 @@ void S_StopSound(int entnum, int entchannel); void S_StopAllSounds(qboolean clear); void S_ClearBuffer(void); void S_Update(vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); -void S_ExtraUpdate(void); sfx_t *S_PrecacheSound(const char *sample); void S_TouchSound(const char *sample); @@ -126,13 +131,6 @@ qboolean SNDDMA_Init(dma_t *dma); // gets the current DMA position int SNDDMA_GetDMAPos(void); -/* Lock and unlock the DMA sound buffer */ -int SNDDMA_LockBuffer(void); -void SNDDMA_UnlockBuffer(void); - -// shutdown the DMA xfer. -void SNDDMA_Shutdown(void); - // ==================================================================== // User-setable variables // ==================================================================== @@ -152,12 +150,9 @@ extern int paintedtime; extern volatile dma_t *shm; extern int s_rawend; -extern cvar_t loadas8bit; extern cvar_t bgmvolume; extern cvar_t sfxvolume; -extern int snd_blocked; - #define MAX_RAW_SAMPLES 8192 extern portable_samplepair_t s_rawsamples[MAX_RAW_SAMPLES]; @@ -165,7 +160,6 @@ void S_LocalSound(const char *s); sfxcache_t *S_LoadSound(sfx_t *s); void SND_InitScaletable(void); -void SNDDMA_Submit(void); wavinfo_t *GetWavinfo (const char *name, byte *wav, int wavlength); void S_AmbientOff(void); From 7b8ec43e22ca66886fe1751f8966c5e8d8fce4d8 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 04:59:43 +0200 Subject: [PATCH 09/48] * Remove unneeded debug code (including member variable height of surfcache_s) * Remove unneeded low floating point/high floating point mode setting (this was only ever relevant on old 486/Pentium era CPUs) * Get rid of more useless debug functions * Direct initialization of local variables where possible --- common/cl_parse.c | 2 +- common/d_local.h | 1 - common/d_surf.c | 42 +----- common/input.h | 2 - common/libretro.c | 8 -- common/pr_cmds.c | 342 +++++++++++++++------------------------------- common/pr_edict.c | 252 ---------------------------------- common/pr_exec.c | 121 +--------------- common/progs.h | 6 - common/r_main.c | 9 -- common/r_misc.c | 43 +----- common/sys.h | 4 - 12 files changed, 119 insertions(+), 713 deletions(-) diff --git a/common/cl_parse.c b/common/cl_parse.c index cdc9ccfb..5bc72e91 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -44,7 +44,7 @@ CL_EntityNum This error checks and tracks the total number of entities =============== */ -entity_t * +static entity_t * CL_EntityNum(int num) { if (num >= cl.num_entities) { diff --git a/common/d_local.h b/common/d_local.h index 8e5c317d..3ca21045 100644 --- a/common/d_local.h +++ b/common/d_local.h @@ -46,7 +46,6 @@ typedef struct surfcache_s { int dlight; int size; // including header unsigned width; - unsigned height; // DEBUG only needed for debug float mipscale; struct texture_s *texture; // checked for animating textures byte data[4]; // width*height elements diff --git a/common/d_surf.c b/common/d_surf.c index f9f50a82..6b8aaa1a 100644 --- a/common/d_surf.c +++ b/common/d_surf.c @@ -60,10 +60,8 @@ int D_SurfaceCacheForRes(int width, int height) void D_CheckCacheGuard(void) { - byte *s; int i; - - s = (byte *)sc_base + sc_size; + byte *s = (byte *)sc_base + sc_size; for (i = 0; i < GUARDSIZE; i++) if (s[i] != (byte)i) Sys_Error("%s: failed", __func__); @@ -71,10 +69,8 @@ void D_CheckCacheGuard(void) void D_ClearCacheGuard(void) { - byte *s; int i; - - s = (byte *)sc_base + sc_size; + byte *s = (byte *)sc_base + sc_size; for (i = 0; i < GUARDSIZE; i++) s[i] = (byte)i; } @@ -187,10 +183,6 @@ D_SCAlloc(int width, int size) sc_rover = new_surf->next; new_surf->width = width; - // DEBUG - if (width > 0) - new_surf->height = (size - sizeof(*new_surf) + sizeof(new_surf->data)) / width; - new_surf->owner = NULL; // should be set properly after return if (d_roverwrapped) { @@ -205,36 +197,6 @@ D_SCAlloc(int width, int size) } -//============================================================================= - -/* if the num is not a power of 2, assume it will not repeat */ - -int -MaskForNum(int num) -{ - if (num == 128) - return 127; - if (num == 64) - return 63; - if (num == 32) - return 31; - if (num == 16) - return 15; - return 255; -} - -int -D_log2(int num) -{ - int c; - - c = 0; - - while (num >>= 1) - c++; - return c; -} - //============================================================================= /* diff --git a/common/input.h b/common/input.h index 342a6122..ad06549c 100644 --- a/common/input.h +++ b/common/input.h @@ -35,8 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif // FIXME - windows only? -extern unsigned int uiWheelMessage; -extern qboolean mouseactive; extern cvar_t _windowed_mouse; void IN_Init(void); diff --git a/common/libretro.c b/common/libretro.c index e799ead2..95a05e98 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -446,14 +446,6 @@ double Sys_DoubleTime(void) // Sleeps for microseconds // ======================================================================= -void Sys_HighFPPrecision(void) -{ -} - -void Sys_LowFPPrecision(void) -{ -} - viddef_t vid; // global video state void retro_init(void) diff --git a/common/pr_cmds.c b/common/pr_cmds.c index a25e9cf8..3a9dc8fa 100644 --- a/common/pr_cmds.c +++ b/common/pr_cmds.c @@ -84,15 +84,9 @@ error(value) static void PF_error(void) { - const char *s; - edict_t *ed; - - s = PF_VarString(0); + const char *s = PF_VarString(0); Con_Printf("======SERVER ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s); - ed = PROG_TO_EDICT(pr_global_struct->self); - ED_Print(ed); - SV_Error("Program error"); } @@ -116,7 +110,6 @@ PF_objerror(void) Con_Printf("======OBJECT ERROR in %s:\n%s\n", PR_GetString(pr_xfunction->s_name), s); ed = PROG_TO_EDICT(pr_global_struct->self); - ED_Print(ed); ED_Free(ed); SV_Error("Program error"); @@ -247,12 +240,9 @@ setsize (entity, minvector, maxvector) static void PF_setsize(void) { - edict_t *e; - float *min, *max; - - e = G_EDICT(OFS_PARM0); - min = G_VECTOR(OFS_PARM1); - max = G_VECTOR(OFS_PARM2); + edict_t *e = G_EDICT(OFS_PARM0); + float *min = G_VECTOR(OFS_PARM1); + float *max = G_VECTOR(OFS_PARM2); #ifdef NQ_HACK SetMinMaxSize(e, min, max, false); #endif @@ -276,14 +266,11 @@ Also sets size, mins, and maxs for inline bmodels static void PF_setmodel(void) { - edict_t *e; - const char **check; - const char *m; - model_t *mod; int i; - - e = G_EDICT(OFS_PARM0); - m = G_STRING(OFS_PARM1); + model_t *mod; + const char **check; + edict_t *e = G_EDICT(OFS_PARM0); + const char *m = G_STRING(OFS_PARM1); /* check to see if model was properly precached */ for (i = 0, check = sv.model_precache; *check; i++, check++) @@ -328,17 +315,16 @@ static void PF_bprint(void) { #ifdef NQ_HACK - const char *s; - - s = PF_VarString(0); + const char *s = PF_VarString(0); +#endif +#ifdef QW_HACK + int level = G_FLOAT(OFS_PARM0); + const char *s = PF_VarString(1); +#endif +#ifdef NQ_HACK SV_BroadcastPrintf("%s", s); #endif #ifdef QW_HACK - const char *s; - int level; - - level = G_FLOAT(OFS_PARM0); - s = PF_VarString(1); SV_BroadcastPrintf(level, "%s", s); #endif } @@ -356,12 +342,9 @@ static void PF_sprint(void) { #ifdef NQ_HACK - const char *s; client_t *client; - int entnum; - - entnum = G_EDICTNUM(OFS_PARM0); - s = PF_VarString(1); + int entnum = G_EDICTNUM(OFS_PARM0); + const char *s = PF_VarString(1); if (entnum < 1 || entnum > svs.maxclients) { Con_Printf("tried to sprint to a non-client\n"); @@ -373,14 +356,10 @@ PF_sprint(void) MSG_WriteString(&client->message, s); #endif #ifdef QW_HACK - const char *s; client_t *client; - int entnum; - int level; - - entnum = G_EDICTNUM(OFS_PARM0); - level = G_FLOAT(OFS_PARM1); - s = PF_VarString(2); + int entnum = G_EDICTNUM(OFS_PARM0); + int level = G_FLOAT(OFS_PARM1); + const char *s = PF_VarString(2); if (entnum < 1 || entnum > MAX_CLIENTS) { Con_Printf("tried to sprint to a non-client\n"); @@ -405,12 +384,9 @@ centerprint(clientent, value) static void PF_centerprint(void) { - const char *s; client_t *client; - int entnum; - - entnum = G_EDICTNUM(OFS_PARM0); - s = PF_VarString(1); + int entnum = G_EDICTNUM(OFS_PARM0); + const char *s = PF_VarString(1); #ifdef NQ_HACK if (entnum < 1 || entnum > svs.maxclients) { @@ -444,13 +420,9 @@ vector normalize(vector) static void PF_normalize(void) { - float *value1; vec3_t newvalue; - float newval; - - value1 = G_VECTOR(OFS_PARM0); - - newval = + float *value1 = G_VECTOR(OFS_PARM0); + float newval = value1[0] * value1[0] + value1[1] * value1[1] + value1[2] * value1[2]; newval = sqrt(newval); @@ -476,12 +448,8 @@ scalar vlen(vector) static void PF_vlen(void) { - float *value1; - float newobj; - - value1 = G_VECTOR(OFS_PARM0); - - newobj = + float *value1 = G_VECTOR(OFS_PARM0); + float newobj = value1[0] * value1[0] + value1[1] * value1[1] + value1[2] * value1[2]; newobj = sqrt(newobj); @@ -498,10 +466,8 @@ float vectoyaw(vector) static void PF_vectoyaw(void) { - float *value1; float yaw; - - value1 = G_VECTOR(OFS_PARM0); + float *value1 = G_VECTOR(OFS_PARM0); if (value1[1] == 0 && value1[0] == 0) yaw = 0; @@ -525,11 +491,9 @@ vector vectoangles(vector) static void PF_vectoangles(void) { - float *value1; float forward; float yaw, pitch; - - value1 = G_VECTOR(OFS_PARM0); + float *value1 = G_VECTOR(OFS_PARM0); if (value1[1] == 0 && value1[0] == 0) { yaw = 0; @@ -565,9 +529,7 @@ random() static void PF_random(void) { - float num; - - num = (rand() & 0x7fff) / ((float)0x7fff); + float num = (rand() & 0x7fff) / ((float)0x7fff); G_FLOAT(OFS_RETURN) = num; } @@ -583,14 +545,10 @@ particle(origin, color, count) static void PF_particle(void) { - float *org, *dir; - float color; - float count; - - org = G_VECTOR(OFS_PARM0); - dir = G_VECTOR(OFS_PARM1); - color = G_FLOAT(OFS_PARM2); - count = G_FLOAT(OFS_PARM3); + float *org = G_VECTOR(OFS_PARM0); + float *dir = G_VECTOR(OFS_PARM1); + float color = G_FLOAT(OFS_PARM2); + float count = G_FLOAT(OFS_PARM3); SV_StartParticle(org, dir, color, count); } @@ -628,18 +586,14 @@ PF_ambientsound static void PF_ambientsound(void) { - const char **check; - const char *samp; - float *pos; - float vol, attenuation; int i, soundnum; + const char **check; + float *pos = G_VECTOR(OFS_PARM0); + const char *samp = G_STRING(OFS_PARM1); + float vol = G_FLOAT(OFS_PARM2); + float attenuation = G_FLOAT(OFS_PARM3); - pos = G_VECTOR(OFS_PARM0); - samp = G_STRING(OFS_PARM1); - vol = G_FLOAT(OFS_PARM2); - attenuation = G_FLOAT(OFS_PARM3); - -// check to see if samp was properly precached + // check to see if samp was properly precached for (soundnum = 0, check = sv.sound_precache; *check; check++, soundnum++) if (!strcmp(*check, samp)) break; @@ -690,17 +644,11 @@ Larger attenuations will drop off. static void PF_sound(void) { - const char *sample; - int channel; - edict_t *entity; - int volume; - float attenuation; - - entity = G_EDICT(OFS_PARM0); - channel = G_FLOAT(OFS_PARM1); - sample = G_STRING(OFS_PARM2); - volume = G_FLOAT(OFS_PARM3) * 255; - attenuation = G_FLOAT(OFS_PARM4); + edict_t *entity = G_EDICT(OFS_PARM0); + int channel = G_FLOAT(OFS_PARM1); + const char *sample = G_STRING(OFS_PARM2); + int volume = G_FLOAT(OFS_PARM3) * 255; + float attenuation = G_FLOAT(OFS_PARM4); #ifdef NQ_HACK if (volume < 0 || volume > 255) @@ -743,17 +691,11 @@ traceline (vector1, vector2, tryents) static void PF_traceline(void) { - float *v1, *v2; - trace_t trace; - int nomonsters; - edict_t *ent; - - v1 = G_VECTOR(OFS_PARM0); - v2 = G_VECTOR(OFS_PARM1); - nomonsters = G_FLOAT(OFS_PARM2); - ent = G_EDICT(OFS_PARM3); - - trace = SV_Move(v1, vec3_origin, vec3_origin, v2, nomonsters, ent); + float *v1 = G_VECTOR(OFS_PARM0); + float *v2 = G_VECTOR(OFS_PARM1); + int nomonsters = G_FLOAT(OFS_PARM2); + edict_t *ent = G_EDICT(OFS_PARM3); + trace_t trace = SV_Move(v1, vec3_origin, vec3_origin, v2, nomonsters, ent); pr_global_struct->trace_allsolid = trace.allsolid; pr_global_struct->trace_startsolid = trace.startsolid; @@ -889,11 +831,9 @@ stuffcmd (clientent, value) static void PF_stuffcmd(void) { - int entnum; const char *str; client_t *client; - - entnum = G_EDICTNUM(OFS_PARM0); + int entnum = G_EDICTNUM(OFS_PARM0); #ifdef NQ_HACK if (entnum < 1 || entnum > svs.maxclients) PR_RunError("Parm 0 not a client"); @@ -947,9 +887,7 @@ float cvar (string) static void PF_cvar(void) { - const char *var; - - var = G_STRING(OFS_PARM0); + const char *var = G_STRING(OFS_PARM0); G_FLOAT(OFS_RETURN) = Cvar_VariableValue(var); } @@ -964,10 +902,8 @@ float cvar (string) static void PF_cvar_set(void) { - const char *var, *val; - - var = G_STRING(OFS_PARM0); - val = G_STRING(OFS_PARM1); + const char *var = G_STRING(OFS_PARM0); + const char *val = G_STRING(OFS_PARM1); Cvar_Set(var, val); } @@ -984,18 +920,13 @@ findradius (origin, radius) static void PF_findradius(void) { - edict_t *ent, *chain; - float rad; - float *org; vec3_t eorg; int i, j; + edict_t *chain = (edict_t *)sv.edicts; + float *org = G_VECTOR(OFS_PARM0); + float rad = G_FLOAT(OFS_PARM1); + edict_t *ent = NEXT_EDICT(sv.edicts); - chain = (edict_t *)sv.edicts; - - org = G_VECTOR(OFS_PARM0); - rad = G_FLOAT(OFS_PARM1); - - ent = NEXT_EDICT(sv.edicts); for (i = 1; i < sv.num_edicts; i++, ent = NEXT_EDICT(ent)) { if (ent->free) continue; @@ -1031,9 +962,7 @@ static char pr_string_temp[128]; static void PF_ftos(void) { - float v; - - v = G_FLOAT(OFS_PARM0); + float v = G_FLOAT(OFS_PARM0); if (v == (int)v) sprintf(pr_string_temp, "%d", (int)v); @@ -1045,9 +974,7 @@ PF_ftos(void) static void PF_fabs(void) { - float v; - - v = G_FLOAT(OFS_PARM0); + float v = G_FLOAT(OFS_PARM0); G_FLOAT(OFS_RETURN) = fabs(v); } @@ -1062,18 +989,14 @@ PF_vtos(void) static void PF_Spawn(void) { - edict_t *ed; - - ed = ED_Alloc(); + edict_t *ed = ED_Alloc(); RETURN_EDICT(ed); } static void PF_Remove(void) { - edict_t *ed; - - ed = G_EDICT(OFS_PARM0); + edict_t *ed = G_EDICT(OFS_PARM0); ED_Free(ed); } @@ -1082,19 +1005,16 @@ PF_Remove(void) static void PF_Find(void) { - int e; - int f; - const char *s, *t; - edict_t *ed; - - e = G_EDICTNUM(OFS_PARM0); - f = G_INT(OFS_PARM1); - s = G_STRING(OFS_PARM2); + const char *t; + int e = G_EDICTNUM(OFS_PARM0); + int f = G_INT(OFS_PARM1); + const char *s = G_STRING(OFS_PARM2); if (!s) PR_RunError("%s: bad search string", __func__); - for (e++; e < sv.num_edicts; e++) { - ed = EDICT_NUM(e); + for (e++; e < sv.num_edicts; e++) + { + edict_t *ed = EDICT_NUM(e); if (ed->free) continue; t = E_STRING(ed, f); @@ -1200,25 +1120,21 @@ PF_precache_model(void) static void PF_coredump(void) { - ED_PrintEdicts(); } static void PF_traceon(void) { - pr_trace = true; } static void PF_traceoff(void) { - pr_trace = false; } static void PF_eprint(void) { - ED_PrintNum(G_EDICTNUM(OFS_PARM0)); } /* @@ -1231,15 +1147,12 @@ float(float yaw, float dist) walkmove static void PF_walkmove(void) { - edict_t *ent; - float yaw, dist; vec3_t move; dfunction_t *oldf; int oldself; - - ent = PROG_TO_EDICT(pr_global_struct->self); - yaw = G_FLOAT(OFS_PARM0); - dist = G_FLOAT(OFS_PARM1); + edict_t *ent = PROG_TO_EDICT(pr_global_struct->self); + float yaw = G_FLOAT(OFS_PARM0); + float dist = G_FLOAT(OFS_PARM1); if (!((int)ent->v.flags & (FL_ONGROUND | FL_FLY | FL_SWIM))) { G_FLOAT(OFS_RETURN) = 0; @@ -1252,15 +1165,15 @@ PF_walkmove(void) move[1] = sin(yaw) * dist; move[2] = 0; -// save program state, because SV_movestep may call other progs - oldf = pr_xfunction; + // save program state, because SV_movestep may call other progs + oldf = pr_xfunction; oldself = pr_global_struct->self; G_FLOAT(OFS_RETURN) = SV_movestep(ent, move, true); -// restore program state - pr_xfunction = oldf; + // restore program state + pr_xfunction = oldf; pr_global_struct->self = oldself; } @@ -1274,11 +1187,9 @@ void() droptofloor static void PF_droptofloor(void) { - edict_t *ent; vec3_t end; trace_t trace; - - ent = PROG_TO_EDICT(pr_global_struct->self); + edict_t *ent = PROG_TO_EDICT(pr_global_struct->self); VectorCopy(ent->v.origin, end); end[2] -= 256; @@ -1306,18 +1217,15 @@ void(float style, string value) lightstyle static void PF_lightstyle(void) { - int style; - const char *val; - client_t *client; int i; + client_t *client; + int style = G_FLOAT(OFS_PARM0); + const char *val = G_STRING(OFS_PARM1); - style = G_FLOAT(OFS_PARM0); - val = G_STRING(OFS_PARM1); - -// change the string in sv + // change the string in sv sv.lightstyles[style] = val; -// send message to all clients on this server + // send message to all clients on this server if (sv.state != ss_active) return; @@ -1343,9 +1251,7 @@ PF_lightstyle(void) static void PF_rint(void) { - float f; - - f = G_FLOAT(OFS_PARM0); + float f = G_FLOAT(OFS_PARM0); if (f > 0) G_FLOAT(OFS_RETURN) = (int)(f + 0.5); else @@ -1373,9 +1279,7 @@ PF_checkbottom static void PF_checkbottom(void) { - edict_t *ent; - - ent = G_EDICT(OFS_PARM0); + edict_t *ent = G_EDICT(OFS_PARM0); G_FLOAT(OFS_RETURN) = SV_CheckBottom(ent); } @@ -1388,9 +1292,7 @@ PF_pointcontents static void PF_pointcontents(void) { - float *v; - - v = G_VECTOR(OFS_PARM0); + float *v = G_VECTOR(OFS_PARM0); G_FLOAT(OFS_RETURN) = SV_PointContents(v); } @@ -1405,10 +1307,9 @@ entity nextent(entity) static void PF_nextent(void) { - int i; edict_t *ent; + int i = G_EDICTNUM(OFS_PARM0); - i = G_EDICTNUM(OFS_PARM0); while (1) { i++; if (i == sv.num_edicts) { @@ -1441,7 +1342,7 @@ cvar_t sv_aim = { "sv_aim", "2" }; static void PF_aim(void) { - edict_t *ent, *check, *bestent; + edict_t *check, *bestent; vec3_t start, dir, end, bestdir; int i, j; trace_t tr; @@ -1451,9 +1352,7 @@ PF_aim(void) #ifdef QW_HACK char *noaim; #endif - - ent = G_EDICT(OFS_PARM0); - //speed = G_FLOAT(OFS_PARM1); + edict_t *ent = G_EDICT(OFS_PARM0); VectorCopy(ent->v.origin, start); start[2] += 20; @@ -1530,13 +1429,11 @@ This was a major timewaster in progs, so it was converted to C void PF_changeyaw(void) { - edict_t *ent; - float ideal, current, move, speed; - - ent = PROG_TO_EDICT(pr_global_struct->self); - current = anglemod(ent->v.angles[1]); - ideal = ent->v.ideal_yaw; - speed = ent->v.yaw_speed; + float move; + edict_t *ent = PROG_TO_EDICT(pr_global_struct->self); + float current = anglemod(ent->v.angles[1]); + float ideal = ent->v.ideal_yaw; + float speed = ent->v.yaw_speed; if (current == ideal) return; @@ -1578,13 +1475,11 @@ MESSAGE WRITING static sizebuf_t * WriteDest(void) { - int dest; #ifdef NQ_HACK int entnum; edict_t *ent; #endif - - dest = G_FLOAT(OFS_PARM0); + int dest = G_FLOAT(OFS_PARM0); switch (dest) { case MSG_BROADCAST: return &sv.datagram; @@ -1629,11 +1524,8 @@ WriteDest(void) static client_t * Write_GetClient(void) { - int entnum; - edict_t *ent; - - ent = PROG_TO_EDICT(pr_global_struct->msg_entity); - entnum = NUM_FOR_EDICT(ent); + edict_t *ent = PROG_TO_EDICT(pr_global_struct->msg_entity); + int entnum = NUM_FOR_EDICT(ent); if (entnum < 1 || entnum > MAX_CLIENTS) PR_RunError("%s: not a client", __func__); return &svs.clients[entnum - 1]; @@ -1757,13 +1649,11 @@ PF_WriteEntity(void) static void PF_makestatic(void) { - edict_t *ent; int i; #ifdef NQ_HACK unsigned int bits; #endif - - ent = G_EDICT(OFS_PARM0); + edict_t *ent = G_EDICT(OFS_PARM0); #ifdef NQ_HACK bits = 0; @@ -1819,12 +1709,9 @@ PF_setspawnparms static void PF_setspawnparms(void) { - edict_t *ent; - int i; client_t *client; - - ent = G_EDICT(OFS_PARM0); - i = NUM_FOR_EDICT(ent); + edict_t *ent = G_EDICT(OFS_PARM0); + int i = NUM_FOR_EDICT(ent); #ifdef NQ_HACK if (i < 1 || i > svs.maxclients) #endif @@ -1879,15 +1766,11 @@ logfrag (killer, killee) static void PF_logfrag(void) { - edict_t *ent1, *ent2; - int e1, e2; const char *s; - - ent1 = G_EDICT(OFS_PARM0); - ent2 = G_EDICT(OFS_PARM1); - - e1 = NUM_FOR_EDICT(ent1); - e2 = NUM_FOR_EDICT(ent2); + edict_t *ent1 = G_EDICT(OFS_PARM0); + edict_t *ent2 = G_EDICT(OFS_PARM1); + int e1 = NUM_FOR_EDICT(ent1); + int e2 = NUM_FOR_EDICT(ent2); if (e1 < 1 || e1 > MAX_CLIENTS || e2 < 1 || e2 > MAX_CLIENTS) return; @@ -1915,13 +1798,9 @@ PF_infokey(void) { static char buf[256]; /* only needs to fit IP or ping */ const char *value; - const char *key; - edict_t *e; - int e1; - - e = G_EDICT(OFS_PARM0); - e1 = NUM_FOR_EDICT(e); - key = G_STRING(OFS_PARM1); + edict_t *e = G_EDICT(OFS_PARM0); + int e1 = NUM_FOR_EDICT(e); + const char *key = G_STRING(OFS_PARM1); if (e1 == 0) { if ((value = Info_ValueForKey(svs.info, key)) == NULL || !*value) @@ -1953,9 +1832,7 @@ float(string s) stof static void PF_stof(void) { - const char *s; - - s = G_STRING(OFS_PARM0); + const char *s = G_STRING(OFS_PARM0); G_FLOAT(OFS_RETURN) = atof(s); } @@ -1971,11 +1848,8 @@ void(vector where, float set) multicast static void PF_multicast(void) { - float *o; - int to; - - o = G_VECTOR(OFS_PARM0); - to = G_FLOAT(OFS_PARM1); + float *o = G_VECTOR(OFS_PARM0); + int to = G_FLOAT(OFS_PARM1); SV_Multicast(o, to); } diff --git a/common/pr_edict.c b/common/pr_edict.c index 21001ced..2e951056 100644 --- a/common/pr_edict.c +++ b/common/pr_edict.c @@ -199,27 +199,6 @@ ED_Free(edict_t *ed) ed->freetime = sv.time; } -//=========================================================================== - -/* -============ -ED_GlobalAtOfs -============ -*/ -static ddef_t * -ED_GlobalAtOfs(int ofs) -{ - ddef_t *def; - int i; - - for (i = 0; i < progs->numglobaldefs; i++) { - def = &pr_globaldefs[i]; - if (def->ofs == ofs) - return def; - } - return NULL; -} - /* ============ ED_FieldAtOfs @@ -327,59 +306,6 @@ GetEdictFieldValue(edict_t *ed, const char *field) return (eval_t *)((char *)&ed->v + def->ofs * 4); } -/* -============ -PR_ValueString - -Returns a string describing *data in a type specific manner -============= -*/ -static char * -PR_ValueString(etype_t type, eval_t *val) -{ - static char line[128]; - ddef_t *def; - dfunction_t *f; - - type &= ~DEF_SAVEGLOBAL; - - switch (type) { - case ev_string: - snprintf(line, sizeof(line), "%s", PR_GetString(val->string)); - break; - case ev_entity: - snprintf(line, sizeof(line), "entity %i", - NUM_FOR_EDICT(PROG_TO_EDICT(val->edict))); - break; - case ev_function: - f = pr_functions + val->function; - snprintf(line, sizeof(line), "%s()", PR_GetString(f->s_name)); - break; - case ev_field: - def = ED_FieldAtOfs(val->_int); - snprintf(line, sizeof(line), ".%s", PR_GetString(def->s_name)); - break; - case ev_void: - snprintf(line, sizeof(line), "void"); - break; - case ev_float: - snprintf(line, sizeof(line), "%5.1f", val->_float); - break; - case ev_vector: - snprintf(line, sizeof(line), "'%5.1f %5.1f %5.1f'", - val->vector[0], val->vector[1], val->vector[2]); - break; - case ev_pointer: - snprintf(line, sizeof(line), "pointer"); - break; - default: - snprintf(line, sizeof(line), "bad type %i", type); - break; - } - - return line; -} - /* ============ PR_UglyValueString @@ -431,105 +357,6 @@ PR_UglyValueString(etype_t type, eval_t *val) return line; } -/* -============ -PR_GlobalString - -Returns a string with a description and the contents of a global, -padded to 20 field width -============ -*/ -char *PR_GlobalString(int ofs) -{ - static char line[128]; - char *s; - int i; - void *val = (void *)&pr_globals[ofs]; - ddef_t *def = ED_GlobalAtOfs(ofs); - - if (!def) - snprintf(line, sizeof(line), "%i(???"")", ofs); - else - { - s = (char*)PR_ValueString((etype_t)def->type, (eval_t*)val); - snprintf(line, sizeof(line), "%i(%s)%s", ofs, - PR_GetString(def->s_name), s); - } - - for (i = strlen(line); i < 20; i++) - strcat(line, " "); - strcat(line, " "); - - return line; -} - -char *PR_GlobalStringNoContents(int ofs) -{ - static char line[128]; - int i; - ddef_t *def = ED_GlobalAtOfs(ofs); - if (!def) - snprintf(line, sizeof(line), "%i(???"")", ofs); - else - snprintf(line, sizeof(line), "%i(%s)", ofs, PR_GetString(def->s_name)); - - i = strlen(line); - for (; i < 20; i++) - strcat(line, " "); - strcat(line, " "); - - return line; -} - - -/* -============= -ED_Print - -For debugging -============= -*/ -void ED_Print(edict_t *ed) -{ - int i; - - if (ed->free) - { - Con_Printf("FREE\n"); - return; - } - - Con_Printf("\nEDICT %i:\n", NUM_FOR_EDICT(ed)); - for (i = 1; i < progs->numfielddefs; i++) - { - int *v; - int type, j, l; - ddef_t *d = &pr_fielddefs[i]; - const char *name = PR_GetString(d->s_name); - - if (name[strlen(name) - 2] == '_') - continue; // skip _x, _y, _z vars - - v = (int *)((char *)&ed->v + d->ofs * 4); - - // if the value is still all 0, skip the field - type = d->type & ~DEF_SAVEGLOBAL; - - for (j = 0; j < type_size[type]; j++) - if (v[j]) - break; - if (j == type_size[type]) - continue; - - Con_Printf("%s", name); - l = strlen(name); - while (l++ < 15) - Con_Printf(" "); - - Con_Printf("%s\n", PR_ValueString((etype_t)d->type, (eval_t *)v)); - } -} - /* ============= ED_Write @@ -576,79 +403,6 @@ void ED_Write(RFILE *f, edict_t *ed) rfprintf(f, "}\n"); } -void ED_PrintNum(int ent) -{ - ED_Print(EDICT_NUM(ent)); -} - -/* -============= -ED_PrintEdicts - -For debugging, prints all the entities in the current server -============= -*/ -void -ED_PrintEdicts(void) -{ - int i; - - Con_Printf("%i entities\n", sv.num_edicts); - for (i = 0; i < sv.num_edicts; i++) - ED_PrintNum(i); -} - -/* -============= -ED_PrintEdict_f - -For debugging, prints a single edicy -============= -*/ -static void ED_PrintEdict_f(void) -{ - int i = Q_atoi(Cmd_Argv(1)); - if (i >= 0 && i < sv.num_edicts) - ED_PrintNum(i); - else - Con_Printf("Bad edict number\n"); -} - -/* -============= -ED_Count - -For debugging -============= -*/ -static void ED_Count(void) -{ - int i; - int models, solid, step; - int active = models = solid = step = 0; - - for (i = 0; i < sv.num_edicts; i++) - { - edict_t *ent = EDICT_NUM(i); - if (ent->free) - continue; - active++; - if (ent->v.solid) - solid++; - if (ent->v.model) - models++; - if (ent->v.movetype == MOVETYPE_STEP) - step++; - } - - Con_Printf("num_edicts:%3i\n", sv.num_edicts); - Con_Printf("active :%3i\n", active); - Con_Printf("view :%3i\n", models); - Con_Printf("touch :%3i\n", solid); - Con_Printf("step :%3i\n", step); - -} - /* ============================================================================== @@ -1005,7 +759,6 @@ ED_LoadFromFile(const char *data) // if (!ent->v.classname) { Con_Printf("No classname for:\n"); - ED_Print(ent); ED_Free(ent); continue; } @@ -1014,7 +767,6 @@ ED_LoadFromFile(const char *data) if (!func) { Con_Printf("No spawn function for:\n"); - ED_Print(ent); ED_Free(ent); continue; } @@ -1172,10 +924,6 @@ PR_Init void PR_Init(void) { - Cmd_AddCommand("edict", ED_PrintEdict_f); - Cmd_AddCommand("edicts", ED_PrintEdicts); - Cmd_AddCommand("edictcount", ED_Count); - Cmd_AddCommand("profile", PR_Profile_f); #ifdef NQ_HACK Cvar_RegisterVariable(&nomonsters); Cvar_RegisterVariable(&gamecfg); diff --git a/common/pr_exec.c b/common/pr_exec.c index 2c407057..9232a3d0 100644 --- a/common/pr_exec.c +++ b/common/pr_exec.c @@ -46,7 +46,6 @@ int pr_depth; int localstack[LOCALSTACK_SIZE]; int localstack_used; -qboolean pr_trace; dfunction_t *pr_xfunction; int pr_xstatement; int pr_argc; @@ -139,115 +138,6 @@ const char *pr_opnames[] = { "BITOR" }; -char *PR_GlobalString(int ofs); -char *PR_GlobalStringNoContents(int ofs); - - -//============================================================================= - -/* -================= -PR_PrintStatement -================= -*/ -void -PR_PrintStatement(dstatement_t *s) -{ - int i; - - if ((unsigned)s->op < sizeof(pr_opnames) / sizeof(pr_opnames[0])) { - Con_Printf("%s ", pr_opnames[s->op]); - i = strlen(pr_opnames[s->op]); - for (; i < 10; i++) - Con_Printf(" "); - } - - if (s->op == OP_IF || s->op == OP_IFNOT) - Con_Printf("%sbranch %i", PR_GlobalString(s->a), s->b); - else if (s->op == OP_GOTO) { - Con_Printf("branch %i", s->a); - } else if ((unsigned)(s->op - OP_STORE_F) < 6) { - Con_Printf("%s", PR_GlobalString(s->a)); - Con_Printf("%s", PR_GlobalStringNoContents(s->b)); - } else { - if (s->a) - Con_Printf("%s", PR_GlobalString(s->a)); - if (s->b) - Con_Printf("%s", PR_GlobalString(s->b)); - if (s->c) - Con_Printf("%s", PR_GlobalStringNoContents(s->c)); - } - Con_Printf("\n"); -} - -/* -============ -PR_StackTrace -============ -*/ -void -PR_StackTrace(void) -{ - dfunction_t *f; - int i; - - if (pr_depth == 0) { - Con_Printf("\n"); - return; - } - - pr_stack[pr_depth].f = pr_xfunction; - for (i = pr_depth; i >= 0; i--) { - f = pr_stack[i].f; - if (!f) - Con_Printf("\n"); - else - Con_Printf("%12s : %s\n", PR_GetString(f->s_file), - PR_GetString(f->s_name)); - } -} - - -/* -============ -PR_Profile_f - -============ -*/ -void -PR_Profile_f(void) -{ - dfunction_t *f, *best; - int max; - int num; - int i; - - // FIXME - progs get unloaded? if so, check that progs gets zero'd - if (!progs) - return; - - num = 0; - do { - max = 0; - best = NULL; - for (i = 0; i < progs->numfunctions; i++) { - f = &pr_functions[i]; - if (f->profile > max) { - max = f->profile; - best = f; - } - } - if (best) { - if (num < 10) - Con_Printf("%7i %s\n", best->profile, - PR_GetString(best->s_name)); - num++; - best->profile = 0; - } - } while (best); -} - - /* ============ PR_RunError @@ -265,8 +155,6 @@ PR_RunError(const char *error, ...) vsnprintf(string, sizeof(string), error, argptr); va_end(argptr); - PR_PrintStatement(pr_statements + pr_xstatement); - PR_StackTrace(); Con_Printf("%s\n", string); /* dump the stack so SV/Host_Error can shutdown functions */ @@ -383,9 +271,8 @@ PR_ExecuteProgram(func_t fnum) int exitdepth; eval_t *ptr; - if (!fnum || fnum >= progs->numfunctions) { - if (pr_global_struct->self) - ED_Print(PROG_TO_EDICT(pr_global_struct->self)); + if (!fnum || fnum >= progs->numfunctions) + { #ifdef NQ_HACK Host_Error("PR_ExecuteProgram: NULL function"); #endif @@ -397,7 +284,6 @@ PR_ExecuteProgram(func_t fnum) f = &pr_functions[fnum]; runaway = 1000000; - pr_trace = false; // make a stack frame exitdepth = pr_depth; @@ -418,9 +304,6 @@ PR_ExecuteProgram(func_t fnum) pr_xfunction->profile++; pr_xstatement = s; - if (pr_trace) - PR_PrintStatement(st); - switch (st->op) { case OP_ADD_F: c->_float = a->_float + b->_float; diff --git a/common/progs.h b/common/progs.h index b5c15b77..98944e59 100644 --- a/common/progs.h +++ b/common/progs.h @@ -72,14 +72,11 @@ void PR_Init(void); void PR_ExecuteProgram(func_t fnum); void PR_LoadProgs(void); -void PR_Profile_f(void); - edict_t *ED_Alloc(void); void ED_Free(edict_t *ed); // returns a copy of the string allocated from the server's string heap -void ED_Print(edict_t *ed); void ED_Write(RFILE *f, edict_t *ed); const char *ED_ParseEdict(const char *data, edict_t *ent); @@ -135,9 +132,6 @@ extern func_t SpectatorDisconnect; void PR_RunError(const char *error, ...); -void ED_PrintEdicts(void); -void ED_PrintNum(int ent); - eval_t *GetEdictFieldValue(edict_t *ed, const char *field); /* diff --git a/common/r_main.c b/common/r_main.c index 07827f30..ef47cf6c 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -1027,12 +1027,6 @@ R_RenderView_(void) R_MarkSurfaces(); // done here so we know if we're in water R_CullSurfaces(r_worldentity.model, r_refdef.vieworg); - // make FDIV fast. This reduces timing precision after we've been running - // for a while, so we don't do it globally. This also sets chop mode, and - // we do it here so that setup stuff like the refresh area calculations - // match what's done in screen.c - Sys_LowFPPrecision(); - if (!r_worldentity.model || !cl.worldmodel) Sys_Error("%s: NULL worldmodel", __func__); @@ -1048,9 +1042,6 @@ R_RenderView_(void) D_WarpScreen(); V_SetContentsColor(r_viewleaf->contents); - - // back to high floating-point precision - Sys_HighFPPrecision(); } void diff --git a/common/r_misc.c b/common/r_misc.c index 07c2fde0..5ea21c31 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -49,25 +49,6 @@ R_CheckVariables(void) } } -/* -============ -Show - -Debugging use -============ -*/ -void -Show(void) -{ - vrect_t vr; - - vr.x = vr.y = 0; - vr.width = vid.width; - vr.height = vid.height; - vr.pnext = NULL; - VID_Update(&vr); -} - /* ================ R_LineGraph @@ -122,7 +103,7 @@ WarpPalette(void) basecolor[1] = 80; basecolor[2] = 50; -// pull the colors halfway to bright brown + // pull the colors halfway to bright brown for (i = 0; i < 256; i++) { for (j = 0; j < 3; j++) { newpalette[i * 3 + j] = @@ -187,11 +168,9 @@ R_TransformPlane void R_TransformPlane(mplane_t *p, float *normal, float *dist) { - float d; - - d = DotProduct(r_origin, p->normal); - *dist = p->dist - d; -// TODO: when we have rotating entities, this will need to use the view matrix + float d = DotProduct(r_origin, p->normal); + *dist = p->dist - d; + // TODO: when we have rotating entities, this will need to use the view matrix TransformVector(p->normal, normal); } @@ -259,23 +238,13 @@ R_SetupFrame(void) r_framecount++; -// debugging -#if 0 - r_refdef.vieworg[0] = 80; - r_refdef.vieworg[1] = 64; - r_refdef.vieworg[2] = 40; - r_refdef.viewangles[0] = 0; - r_refdef.viewangles[1] = 46.763641357; - r_refdef.viewangles[2] = 0; -#endif - -// build the transformation matrix for the given view angles + // build the transformation matrix for the given view angles VectorCopy(r_refdef.vieworg, modelorg); VectorCopy(r_refdef.vieworg, r_origin); AngleVectors(r_refdef.viewangles, vpn, vright, vup); -// current viewleaf + // current viewleaf r_oldviewleaf = r_viewleaf; r_viewleaf = Mod_PointInLeaf(cl.worldmodel, r_origin); diff --git a/common/sys.h b/common/sys.h index 428f338b..7251bd70 100644 --- a/common/sys.h +++ b/common/sys.h @@ -61,10 +61,6 @@ void Sys_SendKeyEvents(void); // Perform Key_Event () callbacks until the input que is empty -void Sys_LowFPPrecision(void); -void Sys_HighFPPrecision(void); -void Sys_SetFPCW(void); - void Sys_Init(void); #endif /* SYS_H */ From 431694ae4cb075d7614d38c48cd71b5211162315 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 05:09:15 +0200 Subject: [PATCH 10/48] Remove if 0 codeblocks --- QW/client/cl_cam.c | 103 ----------------------------- QW/client/cl_demo.c | 14 ---- QW/client/cl_input.c | 13 ---- QW/client/cl_main.c | 6 -- QW/client/cl_parse.c | 13 +--- QW/common/net_chan.c | 25 ------- QW/server/sv_ccmds.c | 8 --- QW/server/sv_user.c | 34 ---------- common/common.c | 11 --- common/d_iface.h | 5 -- common/libretro.c | 19 +----- common/menu.c | 31 --------- common/net_dgrm.c | 5 -- common/r_edge.c | 13 ---- common/r_surf.c | 61 ----------------- common/render.h | 6 +- common/snd_modplug.c | 4 -- deps/libFLAC/include/private/crc.h | 3 - deps/libFLAC/stream_decoder.c | 5 -- deps/libvorbis/lib/block.c | 11 --- deps/libvorbis/lib/psy.c | 49 -------------- deps/libvorbis/lib/vorbisfile.c | 5 -- 22 files changed, 3 insertions(+), 441 deletions(-) diff --git a/QW/client/cl_cam.c b/QW/client/cl_cam.c index 41c1a287..3f9086c8 100644 --- a/QW/client/cl_cam.c +++ b/QW/client/cl_cam.c @@ -141,14 +141,6 @@ Cam_Lock(int playernum) static pmtrace_t Cam_DoTrace(vec3_t vec1, vec3_t vec2) { -#if 0 - memset(&pmove, 0, sizeof(pmove)); - - pmove.numphysent = 1; - VectorCopy(vec3_origin, pmove.physents[0].origin); - pmove.physents[0].model = cl.worldmodel; -#endif - VectorCopy(vec1, pmove.origin); return PM_PlayerMove(pmove.origin, vec2); } @@ -408,75 +400,6 @@ Cam_Track(usercmd_t *cmd) } } -#if 0 -static float -adjustang(float current, float ideal, float speed) -{ - float move; - - current = anglemod(current); - ideal = anglemod(ideal); - - if (current == ideal) - return current; - - move = ideal - current; - if (ideal > current) { - if (move >= 180) - move = move - 360; - } else { - if (move <= -180) - move = move + 360; - } - if (move > 0) { - if (move > speed) - move = speed; - } else { - if (move < -speed) - move = -speed; - } - -//Con_Printf("c/i: %4.2f/%4.2f move: %4.2f\n", current, ideal, move); - return anglemod(current + move); -} -#endif - -#if 0 -static void -Cam_SetView(void) -{ - return; - player_state_t *player, *self; - frame_t *frame; - vec3_t vec, vec2; - - if (cls.state != ca_active || !cl.spectator || !autocam || !locked) - return; - - frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; - player = frame->playerstate + spec_track; - self = frame->playerstate + cl.playernum; - - VectorSubtract(player->origin, cl.simorg, vec); - if (cam_forceview) { - cam_forceview = false; - vectoangles(vec, cam_viewangles); - cam_viewangles[0] = -cam_viewangles[0]; - } else { - vectoangles(vec, vec2); - vec2[PITCH] = -vec2[PITCH]; - - cam_viewangles[PITCH] = - adjustang(cam_viewangles[PITCH], vec2[PITCH], - cl_camera_maxpitch.value); - cam_viewangles[YAW] = - adjustang(cam_viewangles[YAW], vec2[YAW], cl_camera_maxyaw.value); - } - VectorCopy(cam_viewangles, cl.viewangles); - VectorCopy(cl.viewangles, cl.simangles); -} -#endif - void Cam_FinishMove(usercmd_t *cmd) { @@ -490,32 +413,6 @@ Cam_FinishMove(usercmd_t *cmd) if (!cl.spectator) // only in spectator mode return; -#if 0 - if (autocam && locked) { - frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; - player = frame->playerstate + spec_track; - self = frame->playerstate + cl.playernum; - - VectorSubtract(player->origin, self->origin, vec); - if (cam_forceview) { - cam_forceview = false; - vectoangles(vec, cam_viewangles); - cam_viewangles[0] = -cam_viewangles[0]; - } else { - vectoangles(vec, vec2); - vec2[PITCH] = -vec2[PITCH]; - - cam_viewangles[PITCH] = - adjustang(cam_viewangles[PITCH], vec2[PITCH], - cl_camera_maxpitch.value); - cam_viewangles[YAW] = - adjustang(cam_viewangles[YAW], vec2[YAW], - cl_camera_maxyaw.value); - } - VectorCopy(cam_viewangles, cl.viewangles); - } -#endif - if (cmd->buttons & BUTTON_ATTACK) { if (!(oldbuttons & BUTTON_ATTACK)) { diff --git a/QW/client/cl_demo.c b/QW/client/cl_demo.c index c9038dec..34083c92 100644 --- a/QW/client/cl_demo.c +++ b/QW/client/cl_demo.c @@ -636,20 +636,6 @@ CL_Record_f(void) } } -#if 0 - MSG_WriteByte(&buf, svc_updatestatlong); - MSG_WriteByte(&buf, STAT_TOTALMONSTERS); - MSG_WriteLong(&buf, cl.stats[STAT_TOTALMONSTERS]); - - MSG_WriteByte(&buf, svc_updatestatlong); - MSG_WriteByte(&buf, STAT_SECRETS); - MSG_WriteLong(&buf, cl.stats[STAT_SECRETS]); - - MSG_WriteByte(&buf, svc_updatestatlong); - MSG_WriteByte(&buf, STAT_MONSTERS); - MSG_WriteLong(&buf, cl.stats[STAT_MONSTERS]); -#endif - // get the client to check and download skins // when that is completed, a begin command will be issued MSG_WriteByte(&buf, svc_stufftext); diff --git a/QW/client/cl_input.c b/QW/client/cl_input.c index 486e5d54..3375161a 100644 --- a/QW/client/cl_input.c +++ b/QW/client/cl_input.c @@ -706,16 +706,3 @@ CL_InitInput(void) Cvar_RegisterVariable(&cl_nodelta); } - -// FIXME - unused function? -#if 0 -/* -============ -CL_ClearStates -============ -*/ -static void -CL_ClearStates(void) -{ -} -#endif diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index f1d93402..ccfe268f 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -889,12 +889,6 @@ CL_ConnectionlessPacket(void) CL_SendConnectPacket(); return; } -#if 0 - if (c == svc_disconnect) { - Con_Printf("disconnect\n"); - Host_EndGame("Server disconnected"); - } -#endif Con_Printf("unknown: %c\n", c); } diff --git a/QW/client/cl_parse.c b/QW/client/cl_parse.c index 9520528f..6aa4f2b8 100644 --- a/QW/client/cl_parse.c +++ b/QW/client/cl_parse.c @@ -397,15 +397,8 @@ CL_ParseDownload(void) msg_readcount += size; if (percent != 100) { -// change display routines by zoid + // change display routines by zoid // request next block -#if 0 - Con_Printf("."); - if (10 * (percent / 10) != cls.downloadpercent) { - cls.downloadpercent = 10 * (percent / 10); - Con_Printf("%i%%", cls.downloadpercent); - } -#endif cls.downloadpercent = percent; MSG_WriteByte(&cls.netchan.message, clc_stringcmd); @@ -414,10 +407,6 @@ CL_ParseDownload(void) char oldn[MAX_OSPATH]; char newn[MAX_OSPATH]; -#if 0 - Con_Printf("100%%\n"); -#endif - rfclose(cls.download); // rename the temp file to it's final name diff --git a/QW/common/net_chan.c b/QW/common/net_chan.c index 0d66cb38..5843eff8 100644 --- a/QW/common/net_chan.c +++ b/QW/common/net_chan.c @@ -360,31 +360,6 @@ Netchan_Process(netchan_t *chan) Con_Printf("<-- s=%i(%i) a=%i(%i) %i\n", sequence, reliable_message, sequence_ack, reliable_ack, net_message.cursize); -#if 0 - /* get a rate estimation */ - if (chan->outgoing_sequence - sequence_ack < MAX_LATENT) { - int i; - double time, rate; - - i = sequence_ack & (MAX_LATENT - 1); - time = realtime - chan->outgoing_time[i]; - time -= 0.1; /* subtract 100 ms */ - if (time <= 0) { /* gotta be a digital link for <100 ms ping */ - if (chan->rate > 1.0 / 5000) - chan->rate = 1.0 / 5000; - } else { - if (chan->outgoing_size[i] < 512) { /* only deal with small msgs */ - rate = chan->outgoing_size[i] / time; - if (rate > 5000) - rate = 5000; - rate = 1.0 / rate; - if (chan->rate > rate) - chan->rate = rate; - } - } - } -#endif - /* * discard stale or duplicated packets */ diff --git a/QW/server/sv_ccmds.c b/QW/server/sv_ccmds.c index 5a5c5e0d..dfe886ac 100644 --- a/QW/server/sv_ccmds.c +++ b/QW/server/sv_ccmds.c @@ -319,14 +319,6 @@ SV_Map_f(void) } strcpy(level, Cmd_Argv(1)); -#if 0 - if (!strcmp(level, "e1m8")) { // QuakeWorld can't go to e1m8 - SV_BroadcastPrintf(PRINT_HIGH, - "can't go to low grav level in QuakeWorld...\n"); - strcpy(level, "e1m5"); - } -#endif - // check to make sure the level exists sprintf(expanded, "maps/%s.bsp", level); COM_FOpenFile(expanded, &f); diff --git a/QW/server/sv_user.c b/QW/server/sv_user.c index 01274e3d..2a82dc22 100644 --- a/QW/server/sv_user.c +++ b/QW/server/sv_user.c @@ -481,19 +481,6 @@ SV_Begin_f(void) ClientReliableWrite_Byte(host_client, sv.paused); SV_ClientPrintf(host_client, PRINT_HIGH, "Server is paused.\n"); } -#if 0 -// -// send a fixangle over the reliable channel to make sure it gets there -// Never send a roll angle, because savegames can catch the server -// in a state where it is expecting the client to correct the angle -// and it won't happen if the game was just loaded, so you wind up -// with a permanent head tilt - ent = EDICT_NUM(1 + (host_client - svs.clients)); - MSG_WriteByte(&host_client->netchan.message, svc_setangle); - for (i = 0; i < 2; i++) - MSG_WriteAngle(&host_client->netchan.message, ent->v.angles[i]); - MSG_WriteAngle(&host_client->netchan.message, 0); -#endif } //============================================================================= @@ -1368,21 +1355,7 @@ SV_RunCmd(usercmd_t *ucmd) AddAllEntsToPmove(mins, maxs); #endif -#if 0 - { - int before, after; - - before = PM_TestPlayerPosition(pmove.origin); - PlayerMove(); - after = PM_TestPlayerPosition(pmove.origin); - - if (sv_player->v.health > 0 && before && !after) - Con_Printf("player %s got stuck in playermove!!!!\n", - host_client->name); - } -#else PlayerMove(); -#endif host_client->oldbuttons = pmove.oldbuttons; sv_player->v.teleport_time = pmove.waterjumptime; @@ -1398,14 +1371,7 @@ SV_RunCmd(usercmd_t *ucmd) sv_player->v.origin[i] = pmove.origin[i] - (sv_player->v.mins[i] - player_mins[i]); -#if 0 - // truncate velocity the same way the net protocol will - for (i = 0; i < 3; i++) - sv_player->v.velocity[i] = (int)pmove.velocity[i]; -#else VectorCopy(pmove.velocity, sv_player->v.velocity); -#endif - VectorCopy(pmove.angles, sv_player->v.v_angle); if (!host_client->spectator) { diff --git a/common/common.c b/common/common.c index e48f3fb6..47395c41 100644 --- a/common/common.c +++ b/common/common.c @@ -146,17 +146,6 @@ void InsertLinkBefore(link_t *l, link_t *before) l->next->prev = l; } -/* Unused */ -#if 0 -void InsertLinkAfter(link_t *l, link_t *after) -{ - l->next = after->next; - l->prev = after; - l->prev->next = l; - l->next->prev = l; -} -#endif - /* ============================================================================ diff --git a/common/d_iface.h b/common/d_iface.h index 7c192a8b..dd5fa70e 100644 --- a/common/d_iface.h +++ b/common/d_iface.h @@ -114,11 +114,6 @@ extern qboolean r_dowarp; extern affinetridesc_t r_affinetridesc; extern spritedesc_t r_spritedesc; -extern int d_con_indirect; // if 0, Quake will draw console directly - // to vid.buffer; if 1, Quake will - // draw console via D_DrawRect. Must be - // defined by driver - extern vec3_t r_pright, r_pup, r_ppn; diff --git a/common/libretro.c b/common/libretro.c index 95a05e98..7ade4211 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -316,15 +316,6 @@ static retro_input_state_t input_cb; void Sys_Printf(const char *fmt, ...) { -#if 0 - char buffer[256]; - va_list ap; - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - if (log_cb) - log_cb(RETRO_LOG_INFO, "%s\n", buffer); - va_end(ap); -#endif } void Sys_Quit(void) @@ -427,15 +418,7 @@ double Sys_DoubleTime(void) oldtime = newtime; } - if (newtime < oldtime) - { -#if 0 - // warn if it's significant - if (newtime - oldtime < -0.01) - Con_Printf("Sys_DoubleTime: time stepped backwards (went from %f to %f, difference %f)\n", oldtime, newtime, newtime - oldtime); -#endif - } - else + if (newtime >= oldtime) curtime += newtime - oldtime; oldtime = newtime; diff --git a/common/menu.c b/common/menu.c index 1bbbc56a..24bd7ca0 100644 --- a/common/menu.c +++ b/common/menu.c @@ -456,12 +456,6 @@ M_SinglePlayer_Key(int key) switch (m_singleplayer_cursor) { case 0: -#if 0 - if (sv.active) - if (!SCR_ModalMessage("Are you sure you want to\n" - "start a new game?\n")) - break; -#endif key_dest = key_game; if (sv.active) Cbuf_AddText("disconnect\n"); @@ -1940,36 +1934,11 @@ M_Menu_Quit_f(void) static void M_Quit_Key(int key) { -#if 0 - switch (key) { - case K_ESCAPE: - case 'n': - case 'N': - if (wasInMenus) { - m_state = (m_state_enum)m_quit_prevstate; - m_entersound = true; - } else { - key_dest = key_game; - m_state = m_none; - } - break; - - case 'Y': - case 'y': - key_dest = key_console; - Host_Quit_f(); - break; - - default: - break; - } -#else extern bool shutdown_core; key_dest = key_console; Host_Quit_f(); shutdown_core = true; environ_cb(RETRO_ENVIRONMENT_SHUTDOWN, NULL); -#endif } diff --git a/common/net_dgrm.c b/common/net_dgrm.c index 90d36862..4188cce1 100644 --- a/common/net_dgrm.c +++ b/common/net_dgrm.c @@ -258,11 +258,6 @@ Datagram_GetMessage(qsocket_t *sock) while (1) { length = sock->landriver->Read(sock->socket, &packetBuffer, NET_MESSAGESIZE, &readaddr); -#if 0 - /* for testing packet loss effects */ - if ((rand() & 255) > 220) - continue; -#endif if (length == 0) break; diff --git a/common/r_edge.c b/common/r_edge.c index cd053c5b..7ee1fbfa 100644 --- a/common/r_edge.c +++ b/common/r_edge.c @@ -25,19 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "r_local.h" #include "sound.h" -// FIXME - header hacks -extern int screenwidth; - -#if 0 -// FIXME -/* - the complex cases add new polys on most lines, so dont optimize for keeping - them the same have multiple free span lists to try to get better coherence? - low depth complexity -- 1 to 3 or so this breaks spans at every edge, even - hidden ones (bad) have a sentinal at both ends ? -*/ -#endif - edge_t *auxedges; edge_t *r_edges, *edge_p, *edge_max; diff --git a/common/r_surf.c b/common/r_surf.c index e4013f5b..daa8d699 100644 --- a/common/r_surf.c +++ b/common/r_surf.c @@ -977,64 +977,3 @@ void R_DrawSurfaceBlock16(void) prowdestbase = prowdest; } - -//============================================================================ - -// FIXME - unused functions? -#if 0 -/* -================ -R_GenTurbTile -================ -*/ -static void -R_GenTurbTile(pixel_t *pbasetex, void *pdest) -{ - int *turb; - int i, j, s, t; - byte *pd; - - turb = sintable + ((int)(cl.time * TURB_SPEED) & (TURB_CYCLE - 1)); - pd = (byte *)pdest; - - for (i = 0; i < TILE_SIZE; i++) - { - for (j = 0; j < TILE_SIZE; j++) - { - s = (((j << 16) + turb[i & (TURB_CYCLE - 1)]) >> 16) & 63; - t = (((i << 16) + turb[j & (TURB_CYCLE - 1)]) >> 16) & 63; - *pd++ = *(pbasetex + (t << 6) + s); - } - } -} - - -/* -================ -R_GenTurbTile16 -================ -*/ -static void -R_GenTurbTile16(pixel_t *pbasetex, void *pdest) -{ - int *turb; - int i, j, s, t; - unsigned short *pd; - - turb = sintable + ((int)(cl.time * TURB_SPEED) & (TURB_CYCLE - 1)); - pd = (unsigned short *)pdest; - - for (i = 0; i < TILE_SIZE; i++) - { - for (j = 0; j < TILE_SIZE; j++) - { - s = (((j << 16) + turb[i & (TURB_CYCLE - 1)]) >> 16) & 63; - t = (((i << 16) + turb[j & (TURB_CYCLE - 1)]) >> 16) & 63; - *pd++ = d_8to16table[*(pbasetex + (t << 6) + s)]; - } - } -} - - - -#endif diff --git a/common/render.h b/common/render.h index 3ee3927f..8ebb07aa 100644 --- a/common/render.h +++ b/common/render.h @@ -82,12 +82,8 @@ typedef struct entity_s { int effects; // light, particals, etc #endif int dlightframe; // dynamic lighting - /* qbism - not used here... */ -#if 0 - int dlightbits; -#endif -// FIXME: could turn these into a union + // FIXME: could turn these into a union int trivial_accept; struct mnode_s *topnode; // for bmodels, first world node // that splits bmodel, or NULL if diff --git a/common/snd_modplug.c b/common/snd_modplug.c index b089349d..415973b3 100644 --- a/common/snd_modplug.c +++ b/common/snd_modplug.c @@ -77,10 +77,6 @@ static qboolean S_MODPLUG_CodecOpenStream (snd_stream_t *stream) return false; ModPlug_Seek((ModPlugFile*)stream->priv, 0); -#if 0 - /* default volume (128) sounds rather low? */ - ModPlug_SetMasterVolume((ModPlugFile*)stream->priv, 384); /* 0-512 */ -#endif return true; } diff --git a/deps/libFLAC/include/private/crc.h b/deps/libFLAC/include/private/crc.h index c77c7853..bf9c8073 100644 --- a/deps/libFLAC/include/private/crc.h +++ b/deps/libFLAC/include/private/crc.h @@ -53,9 +53,6 @@ extern unsigned const FLAC__crc16_table[256]; #define FLAC__CRC16_UPDATE(data, crc) (((((crc)<<8) & 0xffff) ^ FLAC__crc16_table[((crc)>>8) ^ (data)])) /* this alternate may be faster on some systems/compilers */ -#if 0 -#define FLAC__CRC16_UPDATE(data, crc) ((((crc)<<8) ^ FLAC__crc16_table[((crc)>>8) ^ (data)]) & 0xffff) -#endif unsigned FLAC__crc16(const FLAC__byte *data, unsigned len); diff --git a/deps/libFLAC/stream_decoder.c b/deps/libFLAC/stream_decoder.c index 48d1785a..11373c0e 100644 --- a/deps/libFLAC/stream_decoder.c +++ b/deps/libFLAC/stream_decoder.c @@ -2909,11 +2909,6 @@ FLAC__bool seek_to_absolute_sample_(FLAC__StreamDecoder *decoder, FLAC__uint64 s } /* our write callback will change the state when it gets to the target frame */ /* actually, we could have got_a_frame if our decoder is at FLAC__STREAM_DECODER_END_OF_STREAM so we need to check for that also */ -#if 0 - /*@@@@@@ used to be the following; not clear if the check for end of stream is needed anymore */ - if(decoder->protected_->state != FLAC__SEEKABLE_STREAM_DECODER_SEEKING && decoder->protected_->state != FLAC__STREAM_DECODER_END_OF_STREAM) - break; -#endif if(!decoder->private_->is_seeking) break; diff --git a/deps/libvorbis/lib/block.c b/deps/libvorbis/lib/block.c index c194bf97..36c8087a 100644 --- a/deps/libvorbis/lib/block.c +++ b/deps/libvorbis/lib/block.c @@ -430,17 +430,6 @@ static void _preextrapolate_helper(vorbis_dsp_state *v){ /* prime as above */ vorbis_lpc_from_data(work,lpc,v->pcm_current-v->centerW,order); -#if 0 - if(v->vi->channels==2){ - if(i==0) - _analysis_output("predataL",0,work,v->pcm_current-v->centerW,0,0,0); - else - _analysis_output("predataR",0,work,v->pcm_current-v->centerW,0,0,0); - }else{ - _analysis_output("predata",0,work,v->pcm_current-v->centerW,0,0,0); - } -#endif - /* run the predictor filter */ vorbis_lpc_predict(lpc,work+v->pcm_current-v->centerW-order, order, diff --git a/deps/libvorbis/lib/psy.c b/deps/libvorbis/lib/psy.c index 958388cc..a0b27fc1 100644 --- a/deps/libvorbis/lib/psy.c +++ b/deps/libvorbis/lib/psy.c @@ -348,14 +348,6 @@ void _vp_psy_init(vorbis_look_psy *p,vorbis_info_psy *vi, p->vi->noiseoff[j][inthalfoc+1]*del; } -#if 0 - { - static int ls=0; - _analysis_output_always("noiseoff0",ls,p->noiseoffset[0],n,1,0,0); - _analysis_output_always("noiseoff1",ls,p->noiseoffset[1],n,1,0,0); - _analysis_output_always("noiseoff2",ls++,p->noiseoffset[2],n,1,0,0); - } -#endif } void _vp_psy_clear(vorbis_look_psy *p){ @@ -712,28 +704,6 @@ void _vp_noisemask(vorbis_look_psy *p, for(i=0;i=NOISE_COMPAND_LEVELS)dB=NOISE_COMPAND_LEVELS-1; @@ -1019,9 +989,6 @@ void _vp_couple_quantize_normalize(int blobno, int limit = g->coupling_pointlimit[p->vi->blockflag][blobno]; float prepoint=stereo_threshholds[g->coupling_prepointamp[blobno]]; float postpoint=stereo_threshholds[g->coupling_postpointamp[blobno]]; -#if 0 - float de=0.1*p->m_val; /* a blend of the AoTuV M2 and M3 code here and below */ -#endif /* mdct is our raw mdct output, floor not removed. */ /* inout passes in the ifloor, passes back quantized result */ @@ -1155,28 +1122,12 @@ void _vp_couple_quantize_normalize(int blobno, reM[j] += reA[j]; qeM[j] = fabs(reM[j]); }else{ -#if 0 - /* AoTuV */ - /** @ M2 ** - The boost problem by the combination of noise normalization and point stereo is eased. - However, this is a temporary patch. - by Aoyumi @ 2004/04/18 - */ - float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit))); - /* elliptical */ - if(reM[j]+reA[j]<0){ - reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate); - }else{ - reM[j] = (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate); - } -#else /* elliptical */ if(reM[j]+reA[j]<0){ reM[j] = - (qeM[j] = fabs(reM[j])+fabs(reA[j])); }else{ reM[j] = (qeM[j] = fabs(reM[j])+fabs(reA[j])); } -#endif } reA[j]=qeA[j]=0.f; diff --git a/deps/libvorbis/lib/vorbisfile.c b/deps/libvorbis/lib/vorbisfile.c index e4ae4534..c8d70598 100644 --- a/deps/libvorbis/lib/vorbisfile.c +++ b/deps/libvorbis/lib/vorbisfile.c @@ -2232,11 +2232,6 @@ int ov_crosslap(OggVorbis_File *vf1, OggVorbis_File *vf2){ /* consolidate and expose the buffer. */ vorbis_synthesis_lapout(&vf2->vd,&pcm); -#if 0 - _analysis_output_always("pcmL",0,pcm[0],n1*2,0,0,0); - _analysis_output_always("pcmR",0,pcm[1],n1*2,0,0,0); -#endif - /* splice */ _ov_splice(pcm,lappcm,n1,n2,vi1->channels,vi2->channels,w1,w2); From d4f4167dd4dabde282f4a436998adb7c539c52ff Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 05:19:19 +0200 Subject: [PATCH 11/48] No need for if 1 statements --- QW/client/view.c | 7 ++----- QW/common/pmovetst.c | 11 ----------- QW/server/sv_user.c | 4 ---- common/view.c | 4 +--- common/world.c | 7 ------- deps/libFLAC/fixed.c | 24 ------------------------ deps/libFLAC/stream_decoder.c | 7 ------- 7 files changed, 3 insertions(+), 61 deletions(-) diff --git a/QW/client/view.c b/QW/client/view.c index 1950e211..ef1c3136 100644 --- a/QW/client/view.c +++ b/QW/client/view.c @@ -167,11 +167,8 @@ cvar_t v_centerspeed = { "v_centerspeed", "500" }; void V_StartPitchDrift(void) { -#if 1 - if (cl.laststop == cl.time) { - return; // something else is keeping it from drifting - } -#endif + if (cl.laststop == cl.time) + return; // something else is keeping it from drifting if (cl.nodrift || !cl.pitchvel) { cl.pitchvel = v_centerspeed.value; cl.nodrift = false; diff --git a/QW/common/pmovetst.c b/QW/common/pmovetst.c index 6a45458d..dd13be25 100644 --- a/QW/common/pmovetst.c +++ b/QW/common/pmovetst.c @@ -209,7 +209,6 @@ PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, t2 = DotProduct(plane->normal, p2) - plane->dist; } -#if 1 if (t1 >= 0 && t2 >= 0) { child = node->children[0]; return PM_RecursiveHullCheck(hull, child, p1f, p2f, p1, p2, trace); @@ -218,16 +217,6 @@ PM_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, child = node->children[1]; return PM_RecursiveHullCheck(hull, child, p1f, p2f, p1, p2, trace); } -#else - if ((t1 >= DIST_EPSILON && t2 >= DIST_EPSILON) || (t2 > t1 && t1 >= 0)) { - child = node->children[0]; - return PM_RecursiveHullCheck(hull, child, p1f, p2f, p1, p2, trace); - } - if ((t1 <= -DIST_EPSILON && t2 <= -DIST_EPSILON) || (t2 < t1 && t1 <= 0)) { - child = node->children[1]; - return PM_RecursiveHullCheck(hull, child, p1f, p2f, p1, p2, trace); - } -#endif // put the crosspoint DIST_EPSILON pixels on the near side if (t1 < 0) diff --git a/QW/server/sv_user.c b/QW/server/sv_user.c index 2a82dc22..dce13289 100644 --- a/QW/server/sv_user.c +++ b/QW/server/sv_user.c @@ -1349,11 +1349,7 @@ SV_RunCmd(usercmd_t *ucmd) mins[i] = pmove.origin[i] - 256; maxs[i] = pmove.origin[i] + 256; } -#if 1 SV_AddLinksToPmove(mins, maxs); -#else - AddAllEntsToPmove(mins, maxs); -#endif PlayerMove(); diff --git a/common/view.c b/common/view.c index 836ab928..651fa5ed 100644 --- a/common/view.c +++ b/common/view.c @@ -175,10 +175,8 @@ cvar_t v_centerspeed = { "v_centerspeed", "500" }; void V_StartPitchDrift(void) { -#if 1 if (cl.laststop == cl.time) - return; // something else is keeping it from drifting -#endif + return; // something else is keeping it from drifting if (cl.nodrift || !cl.pitchvel) { cl.pitchvel = v_centerspeed.value; diff --git a/common/world.c b/common/world.c index 09e69b07..67b4bb46 100644 --- a/common/world.c +++ b/common/world.c @@ -767,17 +767,10 @@ qboolean SV_RecursiveHullCheck(hull_t *hull, int num, float p1f, float p2f, t2 = DotProduct(plane->normal, p2) - plane->dist; } -#if 1 if (t1 >= 0 && t2 >= 0) return SV_RecursiveHullCheck(hull, node->children[0], p1f, p2f, p1, p2, trace); if (t1 < 0 && t2 < 0) return SV_RecursiveHullCheck(hull, node->children[1], p1f, p2f, p1, p2, trace); -#else - if ((t1 >= DIST_EPSILON && t2 >= DIST_EPSILON) || (t2 > t1 && t1 >= 0)) - return SV_RecursiveHullCheck(hull, node->children[0], p1f, p2f, p1, p2, trace); - if ((t1 <= -DIST_EPSILON && t2 <= -DIST_EPSILON) || (t2 < t1 && t1 <= 0)) - return SV_RecursiveHullCheck(hull, node->children[1], p1f, p2f, p1, p2, trace); -#endif /* put the crosspoint DIST_EPSILON pixels on the near side */ if (t1 < 0) diff --git a/deps/libFLAC/fixed.c b/deps/libFLAC/fixed.c index 6339f931..e7e03a24 100644 --- a/deps/libFLAC/fixed.c +++ b/deps/libFLAC/fixed.c @@ -360,27 +360,15 @@ void FLAC__fixed_compute_residual(const FLAC__int32 data[], unsigned data_len, u break; case 2: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ residual[i] = data[i] - (data[i-1] << 1) + data[i-2]; -#else - residual[i] = data[i] - 2*data[i-1] + data[i-2]; -#endif break; case 3: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ residual[i] = data[i] - (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) - data[i-3]; -#else - residual[i] = data[i] - 3*data[i-1] + 3*data[i-2] - data[i-3]; -#endif break; case 4: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ residual[i] = data[i] - ((data[i-1]+data[i-3])<<2) + ((data[i-2]<<2) + (data[i-2]<<1)) + data[i-4]; -#else - residual[i] = data[i] - 4*data[i-1] + 6*data[i-2] - 4*data[i-3] + data[i-4]; -#endif break; default: FLAC__ASSERT(0); @@ -402,27 +390,15 @@ void FLAC__fixed_restore_signal(const FLAC__int32 residual[], unsigned data_len, break; case 2: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ data[i] = residual[i] + (data[i-1]<<1) - data[i-2]; -#else - data[i] = residual[i] + 2*data[i-1] - data[i-2]; -#endif break; case 3: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ data[i] = residual[i] + (((data[i-1]-data[i-2])<<1) + (data[i-1]-data[i-2])) + data[i-3]; -#else - data[i] = residual[i] + 3*data[i-1] - 3*data[i-2] + data[i-3]; -#endif break; case 4: for(i = 0; i < idata_len; i++) -#if 1 /* OPT: may be faster with some compilers on some systems */ data[i] = residual[i] + ((data[i-1]+data[i-3])<<2) - ((data[i-2]<<2) + (data[i-2]<<1)) - data[i-4]; -#else - data[i] = residual[i] + 4*data[i-1] - 6*data[i-2] + 4*data[i-3] - data[i-4]; -#endif break; default: FLAC__ASSERT(0); diff --git a/deps/libFLAC/stream_decoder.c b/deps/libFLAC/stream_decoder.c index 11373c0e..8ef99ae3 100644 --- a/deps/libFLAC/stream_decoder.c +++ b/deps/libFLAC/stream_decoder.c @@ -1859,19 +1859,12 @@ FLAC__bool read_frame_(FLAC__StreamDecoder *decoder, FLAC__bool *got_a_frame, FL case FLAC__CHANNEL_ASSIGNMENT_MID_SIDE: FLAC__ASSERT(decoder->private_->frame.header.channels == 2); for(i = 0; i < decoder->private_->frame.header.blocksize; i++) { -#if 1 mid = decoder->private_->output[0][i]; side = decoder->private_->output[1][i]; mid <<= 1; mid |= (side & 1); /* i.e. if 'side' is odd... */ decoder->private_->output[0][i] = (mid + side) >> 1; decoder->private_->output[1][i] = (mid - side) >> 1; -#else - /* OPT: without 'side' temp variable */ - mid = (decoder->private_->output[0][i] << 1) | (decoder->private_->output[1][i] & 1); /* i.e. if 'side' is odd... */ - decoder->private_->output[0][i] = (mid + decoder->private_->output[1][i]) >> 1; - decoder->private_->output[1][i] = (mid - decoder->private_->output[1][i]) >> 1; -#endif } break; default: From e6023ef7d36fb6d94380face73f9304ec6a9f7b3 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 07:38:22 +0200 Subject: [PATCH 12/48] Remove demo recording --- common/cl_demo.c | 203 +--------------------------------------------- common/cl_main.c | 10 +-- common/cl_parse.c | 2 +- common/client.h | 5 -- 4 files changed, 3 insertions(+), 217 deletions(-) diff --git a/common/cl_demo.c b/common/cl_demo.c index 42c197d1..7e32ee8d 100644 --- a/common/cl_demo.c +++ b/common/cl_demo.c @@ -35,14 +35,8 @@ RFILE* rfopen(const char *path, const char *mode); int rfclose(RFILE* stream); int64_t rfread(void* buffer, size_t elem_size, size_t elem_count, RFILE* stream); -int64_t rfflush(RFILE * stream); -int64_t rfwrite(void const* buffer, - size_t elem_size, size_t elem_count, RFILE* stream); -int rfprintf(RFILE * stream, const char * format, ...); int rfgetc(RFILE* stream); -static void CL_FinishTimeDemo(void); - /* ============================================================================== @@ -73,37 +67,6 @@ CL_StopPlayback(void) cls.demoplayback = false; cls.demofile = NULL; cls.state = ca_disconnected; - - if (cls.timedemo) - CL_FinishTimeDemo(); -} - -/* -==================== -CL_WriteDemoMessage - -Dumps the current net message, prefixed by the length and view angles -==================== -*/ -static void -CL_WriteDemoMessage(void) -{ - int i; -#ifdef MSB_FIRST - float f; - int len = LittleLong(net_message.cursize); - rfwrite(&len, 4, 1, cls.demofile); - for (i = 0; i < 3; i++) { - f = LittleFloat(cl.viewangles[i]); - rfwrite(&f, 4, 1, cls.demofile); - } -#else - rfwrite (&net_message.cursize, 4, 1, cls.demofile); - for (i = 0 ; i < 3 ; i++) - rfwrite (&cl.viewangles[i], 4, 1, cls.demofile); -#endif - rfwrite(net_message.data, net_message.cursize, 1, cls.demofile); - rfflush(cls.demofile); } /* @@ -129,19 +92,7 @@ CL_GetMessage(void) // allways grab until fully connected if (cls.state == ca_active) { - if (cls.timedemo) - { - if (host_framecount == cls.td_lastframe) - return 0; // allready read this frame's message - - cls.td_lastframe = host_framecount; - - // if this is the second frame, grab the real td_starttime - // so the bogus time on the first frame doesn't count - if (host_framecount == cls.td_startframe + 1) - cls.td_starttime = realtime; - } - else if (cl.time <= cl.mtime[0]) + if (cl.time <= cl.mtime[0]) { // don't need another message yet return 0; @@ -188,110 +139,9 @@ CL_GetMessage(void) break; } - if (cls.demorecording) - CL_WriteDemoMessage(); - return r; } - -/* -==================== -CL_Stop_f - -stop recording a demo -==================== -*/ -void -CL_Stop_f(void) -{ - if (cmd_source != src_command) - return; - - if (!cls.demorecording) { - Con_Printf("Not recording a demo.\n"); - return; - } -// write a disconnect message to the demo file - SZ_Clear(&net_message); - MSG_WriteByte(&net_message, svc_disconnect); - CL_WriteDemoMessage(); - -// finish up - rfclose(cls.demofile); - cls.demofile = NULL; - cls.demorecording = false; - Con_Printf("Completed demo\n"); -} - -/* -==================== -CL_Record_f - -record [cd track] -==================== -*/ -void -CL_Record_f(void) -{ - int c; - char name[MAX_OSPATH]; - int track; - - if (cmd_source != src_command) - return; - - c = Cmd_Argc(); - if (c != 2 && c != 3 && c != 4) { - Con_Printf("record [ [cd track]]\n"); - return; - } - - if (strstr(Cmd_Argv(1), "..")) { - Con_Printf("Relative pathnames are not allowed.\n"); - return; - } - - if (c == 2 && cls.state >= ca_connected) { - Con_Printf("Can not record - already connected to server\n" - "Client demo recording must be started before" - " connecting\n"); - return; - } -// write the forced cd track number, or -1 - if (c == 4) { - track = atoi(Cmd_Argv(3)); - Con_Printf("Forcing CD track to %i\n", cls.forcetrack); - } else - track = -1; - - sprintf(name, "%s/%s", com_gamedir, Cmd_Argv(1)); - -// -// start the map up -// - if (c > 2) - Cmd_ExecuteString(va("map %s", Cmd_Argv(2)), src_command); - -// -// open the demo file -// - COM_DefaultExtension(name, ".dem"); - - Con_Printf("recording to %s.\n", name); - cls.demofile = rfopen(name, "wb"); - if (!cls.demofile) { - Con_Printf("ERROR: couldn't open.\n"); - return; - } - - cls.forcetrack = track; - rfprintf(cls.demofile, "%i\n", cls.forcetrack); - - cls.demorecording = true; -} - - /* ==================== CL_PlayDemo_f @@ -357,7 +207,6 @@ CL_Demo_Arg_f(const char *arg) root->entries = 0; root->maxlen = 0; root->minlen = -1; - //root->root = NULL; root->stack = NULL; STree_AllocInit(); COM_ScanDir(root, "", arg, ".dem", true); @@ -365,53 +214,3 @@ CL_Demo_Arg_f(const char *arg) return root; } - -/* -==================== -CL_FinishTimeDemo - -==================== -*/ -static void CL_FinishTimeDemo(void) -{ - int frames; - float time; - - cls.timedemo = false; - -// the first frame didn't count - frames = (host_framecount - cls.td_startframe) - 1; - time = realtime - cls.td_starttime; - if (!time) - time = 1; - Con_Printf("%i frames %5.1f seconds %5.1f fps\n", frames, time, - frames / time); -} - -/* -==================== -CL_TimeDemo_f - -timedemo [demoname] -==================== -*/ -void -CL_TimeDemo_f(void) -{ - if (cmd_source != src_command) - return; - - if (Cmd_Argc() != 2) { - Con_Printf("timedemo : gets demo speeds\n"); - return; - } - - CL_PlayDemo_f(); - -// cls.td_starttime will be grabbed at the second frame of the demo, so -// all the loading time doesn't get counted - - cls.timedemo = true; - cls.td_startframe = host_framecount; - cls.td_lastframe = -1; // get a new message this frame -} diff --git a/common/cl_main.c b/common/cl_main.c index 9cc3e8b1..b6f6a25c 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -161,9 +161,6 @@ void CL_Disconnect(void) CL_StopPlayback(); else if (cls.state >= ca_connected) { - if (cls.demorecording) - CL_Stop_f(); - SZ_Clear(&cls.message); MSG_WriteByte(&cls.message, clc_disconnect); NET_SendUnreliableMessage(cls.netcon, &cls.message); @@ -176,7 +173,6 @@ void CL_Disconnect(void) } cls.demoplayback = false; - cls.timedemo = false; cls.signon = 0; } @@ -387,7 +383,7 @@ float CL_LerpPoint(void) float frac; float f = cl.mtime[0] - cl.mtime[1]; - if (!f || cl_nolerp.value || cls.timedemo || sv.active) + if (!f || cl_nolerp.value || sv.active) { cl.time = cl.mtime[0]; return 1; @@ -730,10 +726,6 @@ void CL_Init(void) Cvar_RegisterVariable(&m_side); Cmd_AddCommand("disconnect", CL_Disconnect_f); - Cmd_AddCommand("record", CL_Record_f); - Cmd_AddCommand("stop", CL_Stop_f); Cmd_AddCommand("playdemo", CL_PlayDemo_f); Cmd_SetCompletion("playdemo", CL_Demo_Arg_f); - Cmd_AddCommand("timedemo", CL_TimeDemo_f); - Cmd_SetCompletion("timedemo", CL_Demo_Arg_f); } diff --git a/common/cl_parse.c b/common/cl_parse.c index 5bc72e91..e8d929b0 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -1082,7 +1082,7 @@ CL_ParseServerMessage(void) case svc_cdtrack: cl.cdtrack = MSG_ReadByte(); cl.looptrack = MSG_ReadByte(); - if ((cls.demoplayback || cls.demorecording) + if ((cls.demoplayback) && (cls.forcetrack != -1)) BGM_PlayCDtrack ((byte)cls.forcetrack, true); else diff --git a/common/client.h b/common/client.h index 424710fd..50c2d66b 100644 --- a/common/client.h +++ b/common/client.h @@ -114,7 +114,6 @@ typedef struct { // demo recording info must be here, because record is started before // entering a map (and clearing client_state_t) - qboolean demorecording; qboolean demoplayback; qboolean timedemo; int forcetrack; // -1 = use normal cd track @@ -339,10 +338,6 @@ void CL_BaseMove(usercmd_t *cmd); void CL_StopPlayback(void); int CL_GetMessage(void); -void CL_Stop_f(void); -void CL_Record_f(void); - -void CL_TimeDemo_f(void); void CL_PlayDemo_f(void); struct stree_root *CL_Demo_Arg_f(const char *arg); From 6e408ded61f129fd71c93ef5a5a76de4a1804bf9 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 07:54:16 +0200 Subject: [PATCH 13/48] Remove unused variables that got incremented every frame --- common/d_edge.c | 2 -- common/r_draw.c | 25 ++++--------------------- common/r_local.h | 6 ------ common/r_main.c | 4 ---- common/r_misc.c | 7 ------- common/r_shared.h | 2 -- 6 files changed, 4 insertions(+), 42 deletions(-) diff --git a/common/d_edge.c b/common/d_edge.c index 5ae89c00..f6ccbb69 100644 --- a/common/d_edge.c +++ b/common/d_edge.c @@ -165,8 +165,6 @@ void D_DrawSurfaces(void) if (!s->spans) continue; - r_drawnpolycount++; - d_zistepu = s->d_zistepu; d_zistepv = s->d_zistepv; d_ziorigin = s->d_ziorigin; diff --git a/common/r_draw.c b/common/r_draw.c index 2e1b6e8a..1e66a622 100644 --- a/common/r_draw.c +++ b/common/r_draw.c @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FULLY_CLIPPED_CACHED 0x80000000 #define FRAMECOUNT_MASK 0x7FFFFFFF -int c_faceclip; // number of faces clipped unsigned int cacheoffset; clipplane_t view_clipplanes[4]; @@ -366,17 +365,11 @@ void R_RenderFace(const entity_t *e, msurface_t *fa, int clipflags) clipplane_t *pclip; // skip out if no more surfs - if ((surface_p) >= surf_max) { - r_outofsurfaces++; + if ((surface_p) >= surf_max) return; - } // ditto if not enough edges left, or switch to auxedges if possible - if ((edge_p + fa->numedges + 4) >= edge_max) { - r_outofedges += fa->numedges; + if ((edge_p + fa->numedges + 4) >= edge_max) return; - } - - c_faceclip++; // set up clip planes pclip = NULL; @@ -463,8 +456,6 @@ void R_RenderFace(const entity_t *e, msurface_t *fa, int clipflags) if (!r_emitted) return; - r_polycount++; - surface_p->data = (void *)fa; surface_p->nearzi = r_nearzi; surface_p->flags = fa->flags; @@ -505,17 +496,11 @@ void R_RenderBmodelFace(const entity_t *e, bedge_t *pedges, msurface_t *psurf) clipplane_t *pclip; // skip out if no more surfs - if (surface_p >= surf_max) { - r_outofsurfaces++; + if (surface_p >= surf_max) return; - } // ditto if not enough edges left, or switch to auxedges if possible - if ((edge_p + psurf->numedges + 4) >= edge_max) { - r_outofedges += psurf->numedges; + if ((edge_p + psurf->numedges + 4) >= edge_max) return; - } - - c_faceclip++; // this is a dummy to give the caching mechanism someplace to write to r_pedge = &tedge; @@ -566,8 +551,6 @@ void R_RenderBmodelFace(const entity_t *e, bedge_t *pedges, msurface_t *psurf) if (!r_emitted) return; - r_polycount++; - surface_p->data = (void *)psurf; surface_p->nearzi = r_nearzi; surface_p->flags = psurf->flags; diff --git a/common/r_local.h b/common/r_local.h index 65b2f268..1a4c17be 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -140,9 +140,6 @@ extern void R_EdgeCodeEnd(void); extern void R_RotateBmodel(const entity_t *e); -extern int c_faceclip; -extern int r_polycount; - // !!! if this is changed, it must be changed in asm_draw.h too !!! #define NEAR_CLIP 0.01 @@ -211,9 +208,6 @@ extern int r_bmodelactive; extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter; extern float r_aliastransition, r_resfudge; -extern int r_outofsurfaces; -extern int r_outofedges; - extern mvertex_t *r_pcurrentvertbase; extern int r_maxvalidedgeoffset; diff --git a/common/r_main.c b/common/r_main.c index ef47cf6c..9632942f 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -36,8 +36,6 @@ int r_numallocatededges; qboolean r_recursiveaffinetriangles = true; float r_aliasuvscale = 1.0; -int r_outofsurfaces; -int r_outofedges; static vec3_t viewlightvec; static alight_t r_viewlighting = { 128, 192, viewlightvec }; @@ -90,8 +88,6 @@ mplane_t screenedge[4]; // int r_framecount = 1; // so frame counts initialized to 0 don't match int r_visframecount; -int r_polycount; -int r_drawnpolycount; mleaf_t *r_viewleaf, *r_oldviewleaf; diff --git a/common/r_misc.c b/common/r_misc.c index 5ea21c31..1d77c9e8 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -310,12 +310,5 @@ R_SetupFrame(void) r_cache_thrash = false; -// clear frame counts - c_faceclip = 0; - r_polycount = 0; - r_drawnpolycount = 0; - r_outofsurfaces = 0; - r_outofedges = 0; - D_SetupFrame(); } diff --git a/common/r_shared.h b/common/r_shared.h index a1d7c123..1e57ac0c 100644 --- a/common/r_shared.h +++ b/common/r_shared.h @@ -50,8 +50,6 @@ extern int screenwidth; extern float pixelAspect; -extern int r_drawnpolycount; - extern cvar_t r_clearcolor; #define TURB_TABLE_SIZE (2*TURB_CYCLE) From f62cf641b5f33a1322443f00cc7b2ec29bba9427 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 10:29:41 +0200 Subject: [PATCH 14/48] Remove scr_ram/scr_net and DrawNet --- common/screen.c | 57 +++++-------------------------------------------- 1 file changed, 5 insertions(+), 52 deletions(-) diff --git a/common/screen.c b/common/screen.c index 0cd8492b..384aefa6 100644 --- a/common/screen.c +++ b/common/screen.c @@ -110,9 +110,6 @@ static cvar_t scr_conspeed = { "scr_conspeed", "300" }; static vrect_t *pconupdate; qboolean scr_skipupdate; -static const qpic_t *scr_ram; -static const qpic_t *scr_net; - static char scr_centerstring[1024]; static float scr_centertime_start; // for slow victory printing float scr_centertime_off; @@ -126,36 +123,11 @@ static float scr_disabled_time; #endif #ifdef QW_HACK static float oldsbar; -static cvar_t scr_allowsnap = { "scr_allowsnap", "1" }; #endif //============================================================================= -/* -============== -SCR_DrawNet -============== -*/ -static void -SCR_DrawNet(void) -{ -#ifdef NQ_HACK - if (realtime - cl.last_received_message < 0.3) - return; -#endif -#ifdef QW_HACK - if (cls.netchan.outgoing_sequence - cls.netchan.incoming_acknowledged < - UPDATE_BACKUP - 1) - return; -#endif - - if (cls.demoplayback) - return; - - Draw_Pic(scr_vrect.x + 64, scr_vrect.y, scr_net); -} - //============================================================================= /* @@ -289,9 +261,7 @@ static void SCR_DrawCenterString(void) { char *start; - int l; - int j; - int x, y; + int l, j, x, y; int remaining; scr_copytop = 1; @@ -305,7 +275,7 @@ SCR_DrawCenterString(void) if (key_dest != key_game) return; -// the finale prints the characters one at a time + // the finale prints the characters one at a time if (cl.intermission) remaining = scr_printspeed.value * (cl.time - scr_centertime_start); else @@ -350,14 +320,9 @@ static qboolean scr_drawdialog; static void SCR_DrawNotifyString(void) { - const char *start; - int l; - int j; - int x, y; - - start = scr_notifystring; - - y = vid.height * 0.35; + int l, j, x; + const char *start = scr_notifystring; + int y = vid.height * 0.35; do { // scan the width of the line @@ -710,7 +675,6 @@ SCR_UpdateScreen(void) SCR_DrawCenterString(); #endif } else { - SCR_DrawNet(); SCR_DrawCenterString(); Sbar_Draw(); SCR_DrawConsole(); @@ -769,16 +733,5 @@ SCR_Init(void) Cmd_AddCommand("sizeup", SCR_SizeUp_f); Cmd_AddCommand("sizedown", SCR_SizeDown_f); -#ifdef NQ_HACK - scr_ram = (qpic_t*)Draw_PicFromWad("ram"); - scr_net = (qpic_t*)Draw_PicFromWad("net"); -#endif -#ifdef QW_HACK - scr_ram = W_GetLumpName("ram"); - scr_net = W_GetLumpName("net"); - - Cvar_RegisterVariable(&scr_allowsnap); -#endif - scr_initialized = true; } From bbc5d8e18a39977b84c7864730e84f95e0008c12 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 14:46:29 +0200 Subject: [PATCH 15/48] r_recursiveaffinetriangles is always enabled --- common/d_iface.h | 8 -------- common/d_init.c | 1 - common/r_alias.c | 3 +-- common/r_main.c | 2 -- 4 files changed, 1 insertion(+), 13 deletions(-) diff --git a/common/d_iface.h b/common/d_iface.h index dd5fa70e..f45d2170 100644 --- a/common/d_iface.h +++ b/common/d_iface.h @@ -98,14 +98,6 @@ typedef struct { } spritedesc_t; extern int r_framecount; // sequence # of current frame since Quake started -extern qboolean r_recursiveaffinetriangles; // true if a driver wants to use - - // recursive triangular subdivison - // and vertex drawing via - // D_PolysetDrawFinalVerts() past - // a certain distance (normally - // only used by the software - // driver) extern float r_aliasuvscale; // scale-up factor for screen u and v // on Alias vertices passed to driver diff --git a/common/d_init.c b/common/d_init.c index 992f1011..955bd4ab 100644 --- a/common/d_init.c +++ b/common/d_init.c @@ -53,7 +53,6 @@ D_Init(void) Cvar_RegisterVariable(&d_mipscale); Cvar_RegisterVariable(&dither_filter); - r_recursiveaffinetriangles = true; r_aliasuvscale = 1.0; } diff --git a/common/r_alias.c b/common/r_alias.c index 656cd475..f9dbc193 100644 --- a/common/r_alias.c +++ b/common/r_alias.c @@ -848,8 +848,7 @@ void R_AliasDrawModel(entity_t *e, alight_t *plighting) if (!e->colormap) Sys_Error("%s: !e->colormap", __func__); - r_affinetridesc.drawtype = (e->trivial_accept == 3) && - r_recursiveaffinetriangles; + r_affinetridesc.drawtype = (e->trivial_accept == 3); if (r_affinetridesc.drawtype) D_PolysetUpdateTables(); // FIXME: precalc... diff --git a/common/r_main.c b/common/r_main.c index 9632942f..6b6e5c44 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -33,8 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. void *colormap; int r_numallocatededges; -qboolean r_recursiveaffinetriangles = true; - float r_aliasuvscale = 1.0; static vec3_t viewlightvec; From 3fc527cbbb096ca2a1254ab2043a5e293f381f08 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Wed, 8 Jun 2022 14:54:02 +0200 Subject: [PATCH 16/48] Get rid of r_drawentities - remove more unused functions --- common/d_init.c | 2 - common/d_local.h | 1 - common/d_modech.c | 13 ----- common/d_scan.c | 127 ---------------------------------------------- common/r_local.h | 1 - common/r_main.c | 14 +---- 6 files changed, 2 insertions(+), 156 deletions(-) diff --git a/common/d_init.c b/common/d_init.c index 955bd4ab..92604a95 100644 --- a/common/d_init.c +++ b/common/d_init.c @@ -116,8 +116,6 @@ D_SetupFrame(void) for (i = 0; i < (NUM_MIPS - 1); i++) d_scalemip[i] = basemip[i] * d_mipscale.value; - D_DrawSpans = D_DrawSpans8; - if (cvar && cvar->value == 1.0f) D_DrawSpans = D_DrawSpans16QbDither; else diff --git a/common/d_local.h b/common/d_local.h index 3ca21045..79526128 100644 --- a/common/d_local.h +++ b/common/d_local.h @@ -69,7 +69,6 @@ extern float d_sdivzorigin, d_tdivzorigin, d_ziorigin; extern fixed16_t sadjust, tadjust; extern fixed16_t bbextents, bbextentt; -void D_DrawSpans8(espan_t *pspans); void D_DrawSpans16(espan_t *pspans); extern void (*D_DrawSpans)(espan_t *pspan); diff --git a/common/d_modech.c b/common/d_modech.c index 8e371af5..94394676 100644 --- a/common/d_modech.c +++ b/common/d_modech.c @@ -31,17 +31,6 @@ int d_y_aspect_shift, d_pix_min, d_pix_max, d_pix_shift; int d_scantable[MAXHEIGHT]; short *zspantable[MAXHEIGHT]; -/* -================ -D_Patch -================ -*/ -void -D_Patch(void) -{ -} - - /* ================ D_ViewChanged @@ -89,6 +78,4 @@ void D_ViewChanged(void) zspantable[i] = d_pzbuffer + i * d_zwidth; } } - - D_Patch(); } diff --git a/common/d_scan.c b/common/d_scan.c index 2b66302e..73c107c8 100644 --- a/common/d_scan.c +++ b/common/d_scan.c @@ -612,133 +612,6 @@ void D_DrawSpans16QbDither (espan_t *pspan) //qbism up it from 8 to 16. This + u } while ((pspan = pspan->pnext) != NULL); } -/* -============= -D_DrawSpans8 -============= -*/ -void -D_DrawSpans8(espan_t *pspan) -{ - fixed16_t sstep = 0; // keep compiler happy - fixed16_t tstep = 0; // ditto - - unsigned char *pbase = (unsigned char *)cacheblock; - float sdivz8stepu = d_sdivzstepu * 8; - float tdivz8stepu = d_tdivzstepu * 8; - float zi8stepu = d_zistepu * 8; - - do - { - fixed16_t t; - uint8_t *pdest = (uint8_t*)((byte *)d_viewbuffer + - (screenwidth * pspan->v) + pspan->u); - - int count = pspan->count; - - // calculate the initial s/z, t/z, 1/z, s, and t and clamp - float du = (float)pspan->u; - float dv = (float)pspan->v; - - float sdivz = d_sdivzorigin + dv * d_sdivzstepv + du * d_sdivzstepu; - float tdivz = d_tdivzorigin + dv * d_tdivzstepv + du * d_tdivzstepu; - float zi = d_ziorigin + dv * d_zistepv + du * d_zistepu; - float z = (float)0x10000 / zi; // prescale to 16.16 fixed-point - - fixed16_t s = (int)(sdivz * z) + sadjust; - if (s > bbextents) - s = bbextents; - else if (s < 0) - s = 0; - - t = (int)(tdivz * z) + tadjust; - if (t > bbextentt) - t = bbextentt; - else if (t < 0) - t = 0; - - do - { - fixed16_t snext, tnext; - int spancount = count; - /* calculate s and t at the far end of the span */ - if (count >= 8) - spancount = 8; - - count -= spancount; - - if (count) - { - // calculate s/z, t/z, zi->fixed s and t at far end of span, - // calculate s and t steps across span by shifting - sdivz += sdivz8stepu; - tdivz += tdivz8stepu; - zi += zi8stepu; - z = (float)0x10000 / zi; // prescale to 16.16 fixed-point - - snext = (int)(sdivz * z) + sadjust; - if (snext > bbextents) - snext = bbextents; - else if (snext < 8) - snext = 8; // prevent round-off error on <0 steps from - // from causing overstepping & running off the - // edge of the texture - - tnext = (int)(tdivz * z) + tadjust; - if (tnext > bbextentt) - tnext = bbextentt; - else if (tnext < 8) - tnext = 8; // guard against round-off error on <0 steps - - sstep = (snext - s) >> 3; - tstep = (tnext - t) >> 3; - } - else - { - // calculate s/z, t/z, zi->fixed s and t at last pixel in span (so - // can't step off polygon), clamp, calculate s and t steps across - // span by division, biasing steps low so we don't run off the - // texture - float spancountminus1 = (float)(spancount - 1); - sdivz += d_sdivzstepu * spancountminus1; - tdivz += d_tdivzstepu * spancountminus1; - zi += d_zistepu * spancountminus1; - z = (float)0x10000 / zi; // prescale to 16.16 fixed-point - snext = (int)(sdivz * z) + sadjust; - if (snext > bbextents) - snext = bbextents; - else if (snext < 8) - snext = 8; // prevent round-off error on <0 steps from - // from causing overstepping & running off the - // edge of the texture - - tnext = (int)(tdivz * z) + tadjust; - if (tnext > bbextentt) - tnext = bbextentt; - else if (tnext < 8) - tnext = 8; // guard against round-off error on <0 steps - - if (spancount > 1) { - sstep = (snext - s) / (spancount - 1); - tstep = (tnext - t) / (spancount - 1); - } - } - - do - { - *pdest++ = *(pbase + (s >> 16) + (t >> 16) * cachewidth); - s += sstep; - t += tstep; - } while (--spancount > 0); - - s = snext; - t = tnext; - - } while (count); - - } while ((pspan = pspan->pnext) != NULL); -} - /* ============= D_DrawSpans diff --git a/common/r_local.h b/common/r_local.h index 1a4c17be..ddaeb9fa 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -63,7 +63,6 @@ extern cvar_t r_graphheight; extern cvar_t r_clearcolor; extern cvar_t r_waterwarp; extern cvar_t r_fullbright; -extern cvar_t r_drawentities; extern cvar_t r_ambient; extern cvar_t r_numsurfs; extern cvar_t r_numedges; diff --git a/common/r_main.c b/common/r_main.c index 6b6e5c44..b3a4bf4c 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -99,8 +99,6 @@ cvar_t r_draworder = { "r_draworder", "0" }; cvar_t r_graphheight = { "r_graphheight", "15" }; cvar_t r_clearcolor = { "r_clearcolor", "2" }; cvar_t r_waterwarp = { "r_waterwarp", "1" }; -cvar_t r_drawentities = { "r_drawentities", "1" }; -cvar_t r_drawviewmodel = { "r_drawviewmodel", "1" }; cvar_t r_ambient = { "r_ambient", "0" }; cvar_t r_numsurfs = { "r_numsurfs", "0" }; cvar_t r_numedges = { "r_numedges", "0" }; @@ -190,8 +188,6 @@ R_Init(void) Cvar_RegisterVariable(&r_graphheight); Cvar_RegisterVariable(&r_clearcolor); Cvar_RegisterVariable(&r_waterwarp); - Cvar_RegisterVariable(&r_drawentities); - Cvar_RegisterVariable(&r_drawviewmodel); Cvar_RegisterVariable(&r_ambient); Cvar_RegisterVariable(&r_numsurfs); Cvar_RegisterVariable(&r_numedges); @@ -688,9 +684,6 @@ R_DrawEntitiesOnList(void) vec3_t dist; float add; - if (!r_drawentities.value) - return; - for (i = 0; i < cl_numvisedicts; i++) { e = &cl_visedicts[i]; #ifdef NQ_HACK @@ -780,11 +773,11 @@ R_DrawViewModel(void) dlight_t *dl; #ifdef NQ_HACK - if (!r_drawviewmodel.value || chase_active.value) + if (chase_active.value) return; #endif #ifdef QW_HACK - if (!r_drawviewmodel.value || !Cam_DrawViewModel()) + if (!Cam_DrawViewModel()) return; #endif @@ -891,9 +884,6 @@ static void R_DrawBEntitiesOnList(void) model_t *model; vec3_t mins, maxs; - if (!r_drawentities.value) - return; - VectorCopy(modelorg, oldorigin); insubmodel = true; From 2d3450a53d06f21c3230fd4f4b7eede04b2e6822 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 02:50:59 +0200 Subject: [PATCH 17/48] Don't write keybinds to config.cfg --- QW/client/cl_main.c | 6 ------ common/host.c | 7 ------- common/keys.c | 19 ------------------- common/keys.h | 1 - 4 files changed, 33 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index ccfe268f..f5fe2793 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -1225,13 +1225,7 @@ Host_WriteConfiguration(void) return; } - Key_WriteBindings(f); Cvar_WriteVariables(f); - - /* Save the mlook state (rarely used as an actual key binding) */ - if (in_mlook.state & 1) - rfprintf(f, "+mlook\n"); - rfclose(f); } } diff --git a/common/host.c b/common/host.c index 8d2285f8..474e54df 100644 --- a/common/host.c +++ b/common/host.c @@ -265,14 +265,7 @@ Host_WriteConfiguration(void) Con_Printf("Couldn't write config.cfg.\n"); return; } - - Key_WriteBindings(f); Cvar_WriteVariables(f); - - /* Save the mlook state (rarely used as an actual key binding) */ - if (in_mlook.state & 1) - rfprintf(f, "+mlook\n"); - rfclose(f); } } diff --git a/common/keys.c b/common/keys.c index 63a524b8..3a3991b5 100644 --- a/common/keys.c +++ b/common/keys.c @@ -539,25 +539,6 @@ Key_Bind_f(void) Key_SetBinding((knum_t)keynum, cmd); } -/* -============ -Key_WriteBindings - -Writes lines containing "bind key value" -============ -*/ -void -Key_WriteBindings(RFILE *f) -{ - int i; - - for (i = 0; i < K_LAST; i++) - if (keybindings[i]) - rfprintf(f, "bind \"%s\" \"%s\"\n", - Key_KeynumToString(i), keybindings[i]); -} - - /* =================== Key_Init diff --git a/common/keys.h b/common/keys.h index b6c9dc0e..cc2337da 100644 --- a/common/keys.h +++ b/common/keys.h @@ -298,7 +298,6 @@ extern qboolean chat_team; void Key_Event(knum_t key, qboolean down); void Key_Init(void); -void Key_WriteBindings(RFILE *f); void Key_SetBinding(knum_t keynum, const char *binding); void Key_ClearStates(void); void Key_ClearTyping(void); From 67bb4972a3773f704f6fffe4144e93a6d5a146c7 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 02:53:45 +0200 Subject: [PATCH 18/48] Remove unused function call declarations for rfprintf --- QW/client/cl_main.c | 1 - common/host.c | 1 - common/keys.c | 5 ----- 3 files changed, 7 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index f5fe2793..1ac4fb9a 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -53,7 +53,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* Forward declarations */ RFILE* rfopen(const char *path, const char *mode); int rfclose(RFILE* stream); -int rfprintf(RFILE * stream, const char * format, ...); /* Argument completion function for the skin cvar */ static struct stree_root * CL_Skin_Arg_f(const char *arg); diff --git a/common/host.c b/common/host.c index 474e54df..1f31e508 100644 --- a/common/host.c +++ b/common/host.c @@ -48,7 +48,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* forward declarations */ RFILE* rfopen(const char *path, const char *mode); int rfclose(RFILE* stream); -int rfprintf(RFILE * stream, const char * format, ...); /* * A server can always be started, even if the system started out as a client diff --git a/common/keys.c b/common/keys.c index 3a3991b5..7ec4f9b3 100644 --- a/common/keys.c +++ b/common/keys.c @@ -35,11 +35,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #endif -#include - -/* forward declarations */ -int rfprintf(RFILE * stream, const char * format, ...); - /* key up events are sent even if in console mode From 7fb147fd8db39d20767fe365f9096618b290955f Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 05:24:50 +0200 Subject: [PATCH 19/48] Cleanups --- QW/client/cl_main.c | 8 ++------ QW/server/sv_ccmds.c | 4 ---- QW/server/sv_user.c | 2 -- common/common.c | 45 -------------------------------------------- common/common.h | 2 -- common/host.c | 8 +++----- 6 files changed, 5 insertions(+), 64 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index 1ac4fb9a..67731744 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -472,10 +472,8 @@ CL_User_f(void) if (!cl.players[i].name[0]) continue; if (cl.players[i].userid == uid - || !strcmp(cl.players[i].name, Cmd_Argv(1))) { - Info_Print(cl.players[i].userinfo); + || !strcmp(cl.players[i].name, Cmd_Argv(1))) return; - } } Con_Printf("User not in server.\n"); } @@ -633,10 +631,8 @@ Allow clients to change userinfo void CL_SetInfo_f(void) { - if (Cmd_Argc() == 1) { - Info_Print(cls.userinfo); + if (Cmd_Argc() == 1) return; - } if (Cmd_Argc() != 3) { Con_Printf("usage: setinfo [ ]\n"); return; diff --git a/QW/server/sv_ccmds.c b/QW/server/sv_ccmds.c index dfe886ac..8b6d2288 100644 --- a/QW/server/sv_ccmds.c +++ b/QW/server/sv_ccmds.c @@ -540,7 +540,6 @@ SV_Serverinfo_f(void) { if (Cmd_Argc() == 1) { Con_Printf("Server info settings:\n"); - Info_Print(svs.info); return; } @@ -577,7 +576,6 @@ SV_Localinfo_f(void) { if (Cmd_Argc() == 1) { Con_Printf("Local info settings:\n"); - Info_Print(localinfo); return; } @@ -612,8 +610,6 @@ SV_User_f(void) if (!SV_SetPlayer()) return; - - Info_Print(host_client->userinfo); } /* diff --git a/QW/server/sv_user.c b/QW/server/sv_user.c index dce13289..fdfcbbfd 100644 --- a/QW/server/sv_user.c +++ b/QW/server/sv_user.c @@ -1032,7 +1032,6 @@ SV_SetInfo_f(void) if (Cmd_Argc() == 1) { Con_Printf("User info settings:\n"); - Info_Print(host_client->userinfo); return; } @@ -1078,7 +1077,6 @@ Dumps the serverinfo info string void SV_ShowServerinfo_f(void) { - Info_Print(svs.info); } void diff --git a/common/common.c b/common/common.c index 47395c41..b8cb2c5f 100644 --- a/common/common.c +++ b/common/common.c @@ -1205,33 +1205,6 @@ static int COM_FileOpenRead(const char *path, RFILE **hndl) return -1; } -/* -============ -COM_WriteFile - -The filename will be prefixed by the current game directory -============ -*/ -void COM_WriteFile(const char *filename, const void *data, int len) -{ - RFILE *f; - char name[MAX_OSPATH]; - - snprintf(name, sizeof(name), "%s/%s", com_gamedir, filename); - - f = rfopen(name, "wb"); - if (!f) - { - Sys_mkdir(com_gamedir); - f = rfopen(name, "wb"); - if (!f) - Sys_Error("Error opening %s", filename); - } - rfwrite(data, 1, len, f); - rfclose(f); -} - - /* ============ COM_CreatePath @@ -2165,24 +2138,6 @@ void Info_SetValueForKey(char *infostring, const char *key, const char *value, Info_SetValueForStarKey(infostring, key, value, maxsize); } -void Info_Print(const char *infostring) -{ - char key[MAX_INFO_STRING]; - char value[MAX_INFO_STRING]; - - while (*infostring) - { - infostring = Info_ReadKey(infostring, key, sizeof(key)); - if (*infostring) - infostring++; - infostring = Info_ReadValue(infostring, value, sizeof(value)); - if (*infostring) - infostring++; - - Con_Printf("%-20.20s %s\n", key, *value ? value : "MISSING VALUE"); - } -} - static byte chktbl[1024 + 4] = { 0x78, 0xd2, 0x94, 0xe3, 0x41, 0xec, 0xd6, 0xd5, 0xcb, 0xfc, 0xdb, 0x8a, 0x4b, 0xcc, 0x85, 0x01, 0x23, 0xd2, 0xe5, 0xf2, 0x29, 0xa7, 0x45, 0x94, 0x4a, 0x62, 0xe3, 0xa5, 0x6f, 0x3f, 0xe1, 0x7a, diff --git a/common/common.h b/common/common.h index b47139cb..08cfce10 100644 --- a/common/common.h +++ b/common/common.h @@ -253,7 +253,6 @@ extern char com_gamedir[MAX_OSPATH]; extern char com_savedir[MAX_OSPATH]; extern int file_from_pak; // global indicating that file came from a pak -void COM_WriteFile(const char *filename, const void *data, int len); int COM_FOpenFile(const char *filename, RFILE **file); void COM_ScanDir(struct stree_root *root, const char *path, const char *pfx, const char *ext, qboolean stripext); @@ -279,7 +278,6 @@ void Info_SetValueForKey(char *infostring, const char *key, const char *value, int maxsize); void Info_SetValueForStarKey(char *infostring, const char *key, const char *value, int maxsize); -void Info_Print(const char *infostring); unsigned Com_BlockChecksum(const void *buffer, int length); void Com_BlockFullChecksum(const void *buffer, int len, diff --git a/common/host.c b/common/host.c index 1f31e508..ce2ddd91 100644 --- a/common/host.c +++ b/common/host.c @@ -254,12 +254,10 @@ Writes key bindings and archived cvars to config.cfg void Host_WriteConfiguration(void) { - RFILE *f; - -// dedicated servers initialize the host but don't parse and set the -// config.cfg cvars + // dedicated servers initialize the host but don't parse and set the + // config.cfg cvars if (host_initialized & !isDedicated) { - f = rfopen(va("%s/config.cfg", com_savedir), "w"); + RFILE *f = rfopen(va("%s/config.cfg", com_savedir), "w"); if (!f) { Con_Printf("Couldn't write config.cfg.\n"); return; From edc451707660c7ed0bf3d300d782f61ba1fb7f75 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 10:54:54 +0200 Subject: [PATCH 20/48] Miscellanous cleanups - turn functions static if we can --- common/keys.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/common/keys.c b/common/keys.c index 7ec4f9b3..cc3a0ccc 100644 --- a/common/keys.c +++ b/common/keys.c @@ -234,8 +234,7 @@ Key_Console Interactive line editing and console scrollback ==================== */ -void -Key_Console(int key) +static void Key_Console(int key) { if (key == K_ENTER) { EnterCommand(key_lines[edit_line] + 1); @@ -319,13 +318,11 @@ Key_Console(int key) } //============================================================================ - -qboolean chat_team; -char chat_buffer[MAXCMDLINE]; int chat_bufferlen = 0; +char chat_buffer[MAXCMDLINE]; +qboolean chat_team; -void -Key_Message(int key) +static void Key_Message(int key) { if (key == K_ENTER) { if (chat_team) @@ -456,8 +453,7 @@ Key_SetBinding(knum_t keynum, const char *binding) Key_Unbind_f =================== */ -void -Key_Unbind_f(void) +static void Key_Unbind_f(void) { int b; @@ -475,8 +471,7 @@ Key_Unbind_f(void) Key_SetBinding((knum_t)b, NULL); } -void -Key_Unbindall_f(void) +static void Key_Unbindall_f(void) { int i; @@ -491,8 +486,7 @@ Key_Unbindall_f(void) Key_Bind_f =================== */ -void -Key_Bind_f(void) +static void Key_Bind_f(void) { int i, keynum, len; char cmd[1024]; From 63d299abee5e6b7b87e966c2f76d4945ab5dcaf8 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 11:00:22 +0200 Subject: [PATCH 21/48] Get rid of unnecessary console commands viewframe, viewmodel, viewmodel_prev, viewmodel_next, version --- common/host_cmd.c | 143 +--------------------------------------------- 1 file changed, 1 insertion(+), 142 deletions(-) diff --git a/common/host_cmd.c b/common/host_cmd.c index e3338d26..c0519c3e 100644 --- a/common/host_cmd.c +++ b/common/host_cmd.c @@ -438,7 +438,7 @@ Host_SavegameComment Writes a SAVEGAME_COMMENT_LENGTH character comment describing the current =============== */ -void Host_SavegameComment(char *text) +static void Host_SavegameComment(char *text) { int i; char kills[20]; @@ -738,15 +738,6 @@ void Host_Name_f(void) MSG_WriteString(&sv.reliable_datagram, host_client->name); } - -void -Host_Version_f(void) -{ - Con_Printf("Version TyrQuake-%s\n", stringify(TYR_VERSION)); - Con_Printf("Exe: " __TIME__ " " __DATE__ "\n"); -} - - void Host_Say(qboolean teamonly) { @@ -1362,132 +1353,6 @@ Host_Give_f(void) } } -edict_t * -FindViewthing(void) -{ - int i; - edict_t *e; - - for (i = 0; i < sv.num_edicts; i++) { - e = EDICT_NUM(i); - if (!strcmp(PR_GetString(e->v.classname), "viewthing")) - return e; - } - Con_Printf("No viewthing on map\n"); - return NULL; -} - -/* -================== -Host_Viewmodel_f -================== -*/ -void -Host_Viewmodel_f(void) -{ - edict_t *e; - model_t *m; - - e = FindViewthing(); - if (!e) - return; - - m = Mod_ForName(Cmd_Argv(1), false); - if (!m) { - Con_Printf("Can't load %s\n", Cmd_Argv(1)); - return; - } - - e->v.frame = 0; - cl.model_precache[(int)e->v.modelindex] = m; -} - -/* -================== -Host_Viewframe_f -================== -*/ -void -Host_Viewframe_f(void) -{ - edict_t *e; - int f; - model_t *m; - - e = FindViewthing(); - if (!e) - return; - m = cl.model_precache[(int)e->v.modelindex]; - - f = atoi(Cmd_Argv(1)); - if (f >= m->numframes) - f = m->numframes - 1; - - e->v.frame = f; -} - - -void -PrintFrameName(model_t *m, int frame) -{ - aliashdr_t *hdr; - maliasframedesc_t *pframedesc; - - hdr = (aliashdr_t*)Mod_Extradata(m); - if (!hdr) - return; - pframedesc = &hdr->frames[frame]; - - Con_Printf("frame %i: %s\n", frame, pframedesc->name); -} - -/* -================== -Host_Viewnext_f -================== -*/ -void -Host_Viewnext_f(void) -{ - edict_t *e; - model_t *m; - - e = FindViewthing(); - if (!e) - return; - m = cl.model_precache[(int)e->v.modelindex]; - - e->v.frame = e->v.frame + 1; - if (e->v.frame >= m->numframes) - e->v.frame = m->numframes - 1; - - PrintFrameName(m, e->v.frame); -} - -/* -================== -Host_Viewprev_f -================== -*/ -void -Host_Viewprev_f(void) -{ - edict_t *e; - model_t *m; - - e = FindViewthing(); - if (!e) - return; - - m = cl.model_precache[(int)e->v.modelindex]; - - e->v.frame = e->v.frame - 1; - if (e->v.frame < 0) - e->v.frame = 0; - - PrintFrameName(m, e->v.frame); -} - /* =============================================================================== @@ -1593,7 +1458,6 @@ Host_InitCommands(void) Cmd_AddCommand("reconnect", Host_Reconnect_f); Cmd_AddCommand("name", Host_Name_f); Cmd_AddCommand("noclip", Host_Noclip_f); - Cmd_AddCommand("version", Host_Version_f); Cmd_AddCommand("say", Host_Say_f); Cmd_AddCommand("say_team", Host_Say_Team_f); @@ -1613,9 +1477,4 @@ Host_InitCommands(void) Cmd_AddCommand("startdemos", Host_Startdemos_f); Cmd_AddCommand("demos", Host_Demos_f); Cmd_AddCommand("stopdemo", Host_Stopdemo_f); - - Cmd_AddCommand("viewmodel", Host_Viewmodel_f); - Cmd_AddCommand("viewframe", Host_Viewframe_f); - Cmd_AddCommand("viewnext", Host_Viewnext_f); - Cmd_AddCommand("viewprev", Host_Viewprev_f); } From a30501b8d03e56d89bb15a1bd21aff4624a0bdad Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 16:52:28 +0200 Subject: [PATCH 22/48] * COM_LoadPakFile - CRC checking on PAK file is unnecessary * draworder always 0, remove conditional * Random miscellaneous cleanups, make functions static if we can --- common/common.c | 34 +---------------------- common/pr_edict.c | 12 +-------- common/progs.h | 3 --- common/r_edge.c | 69 +++++++++-------------------------------------- common/r_light.c | 42 +++++++++++++---------------- common/r_local.h | 5 ---- common/r_main.c | 2 -- common/r_misc.c | 10 ------- common/sv_main.c | 4 +-- 9 files changed, 35 insertions(+), 146 deletions(-) diff --git a/common/common.c b/common/common.c index b8cb2c5f..7f99c769 100644 --- a/common/common.c +++ b/common/common.c @@ -81,17 +81,11 @@ cvar_t registered = { "registered", "0" }; static cvar_t cmdline = { "cmdline", "0", false, true }; #endif -static qboolean com_modified; // set true if using non-id files static int static_registered = 1; // only for startup check, then set static void COM_InitFilesystem(void); static void *SZ_GetSpace(sizebuf_t *buf, int length); -// if a packfile directory differs from this, it is assumed to be hacked -#define PAK0_COUNT 339 -#define NQ_PAK0_CRC 32981 -#define QW_PAK0_CRC 52883 - #ifdef NQ_HACK #define CMDLINE_LENGTH 256 static char com_cmdline[CMDLINE_LENGTH]; @@ -1572,7 +1566,6 @@ static pack_t *COM_LoadPackFile(const char *packfile) packfile_t *mfiles; pack_t *pack; int i, numfiles; - unsigned short crc; if (COM_FileOpenRead(packfile, &packhandle) == -1) goto error; @@ -1589,9 +1582,6 @@ static pack_t *COM_LoadPackFile(const char *packfile) numfiles = header.dirlen / sizeof(dpackfile_t); - if (numfiles != PAK0_COUNT) - com_modified = true; // not the original file - #ifdef NQ_HACK mfiles = (packfile_t*)Hunk_AllocName(numfiles * sizeof(*mfiles), "packfile"); mark = Hunk_LowMark(); @@ -1605,19 +1595,6 @@ static pack_t *COM_LoadPackFile(const char *packfile) rfseek(packhandle, header.dirofs, SEEK_SET); rfread(dfiles, 1, header.dirlen, packhandle); -#if defined(NQ_HACK) || defined(QW_HACK) - // crc the directory to check for modifications - crc = CRC_Block(((byte *)dfiles), header.dirlen); -#ifdef NQ_HACK - if (crc != NQ_PAK0_CRC) - com_modified = true; -#endif -#ifdef QW_HACK - if (crc != QW_PAK0_CRC) - com_modified = true; -#endif -#endif - /* parse the directory */ for (i = 0; i < numfiles; i++) { @@ -1835,10 +1812,7 @@ static void COM_InitFilesystem(void) // Adds basedir/gamedir as an override game i = COM_CheckParm("-game"); if (i && i < com_argc - 1) - { - com_modified = true; COM_AddGameDirectory(com_basedir, com_argv[i + 1]); - } #endif #ifdef QW_HACK COM_AddGameDirectory(com_basedir, "qw"); @@ -1861,7 +1835,6 @@ static void COM_InitFilesystem(void) #ifdef NQ_HACK i = COM_CheckParm("-path"); if (i) { - com_modified = true; com_searchpaths = NULL; while (++i < com_argc) { if (!com_argv[i] || com_argv[i][0] == '+' @@ -2185,7 +2158,6 @@ For proxy protecting */ byte COM_BlockSequenceCRCByte(const byte *base, int length, int sequence) { - unsigned short crc; byte chkb[60 + 4]; const byte *p = chktbl + (sequence % (sizeof(chktbl) - 8)); @@ -2200,11 +2172,7 @@ byte COM_BlockSequenceCRCByte(const byte *base, int length, int sequence) length += 4; - crc = CRC_Block(chkb, length); - - crc &= 0xff; - - return crc; + return CRC_Block(chkb, length) & 0xff; } #endif /* QW_HACK */ diff --git a/common/pr_edict.c b/common/pr_edict.c index 2e951056..b82f55e4 100644 --- a/common/pr_edict.c +++ b/common/pr_edict.c @@ -85,14 +85,11 @@ typedef struct { static gefv_cache gefvCache[GEFV_CACHESIZE] = { {NULL, ""}, {NULL, ""} }; #ifdef NQ_HACK -unsigned short pr_crc; cvar_t nomonsters = { "nomonsters", "0" }; -static cvar_t gamecfg = { "gamecfg", "0" }; static cvar_t scratch1 = { "scratch1", "0" }; static cvar_t scratch2 = { "scratch2", "0" }; static cvar_t scratch3 = { "scratch3", "0" }; static cvar_t scratch4 = { "scratch4", "0" }; -static cvar_t savedgamecfg = { "savedgamecfg", "0", true }; static cvar_t saved1 = { "saved1", "0", true }; static cvar_t saved2 = { "saved2", "0", true }; static cvar_t saved3 = { "saved3", "0", true }; @@ -809,9 +806,6 @@ PR_LoadProgs(void) if (!progs) SV_Error("%s: couldn't load progs.dat", __func__); -#ifdef NQ_HACK - pr_crc = CRC_Block((byte *)progs, com_filesize); -#endif #if defined(QW_HACK) && defined(SERVERONLY) // add prog crc to the serverinfo sprintf(num, "%i", CRC_Block((byte *)progs, com_filesize)); @@ -926,12 +920,10 @@ PR_Init(void) { #ifdef NQ_HACK Cvar_RegisterVariable(&nomonsters); - Cvar_RegisterVariable(&gamecfg); Cvar_RegisterVariable(&scratch1); Cvar_RegisterVariable(&scratch2); Cvar_RegisterVariable(&scratch3); Cvar_RegisterVariable(&scratch4); - Cvar_RegisterVariable(&savedgamecfg); Cvar_RegisterVariable(&saved1); Cvar_RegisterVariable(&saved2); Cvar_RegisterVariable(&saved3); @@ -955,9 +947,7 @@ EDICT_NUM(int n) int NUM_FOR_EDICT(const edict_t *e) { - int b; - - b = (byte *)e - (byte *)sv.edicts; + int b = (byte *)e - (byte *)sv.edicts; b = b / pr_edict_size; if (b < 0 || b >= sv.num_edicts) diff --git a/common/progs.h b/common/progs.h index 98944e59..62ef326f 100644 --- a/common/progs.h +++ b/common/progs.h @@ -121,9 +121,6 @@ extern qboolean pr_trace; extern dfunction_t *pr_xfunction; extern int pr_xstatement; -#ifdef NQ_HACK -extern unsigned short pr_crc; -#endif #if defined(QW_HACK) && defined(SERVERONLY) extern func_t SpectatorConnect; extern func_t SpectatorThink; diff --git a/common/r_edge.c b/common/r_edge.c index 7ee1fbfa..f22abca1 100644 --- a/common/r_edge.c +++ b/common/r_edge.c @@ -56,11 +56,6 @@ edge_t edge_sentinel; float fv; void R_GenerateSpans(void); -void R_GenerateSpansBackward(void); - -void R_LeadingEdge(edge_t *edge); -void R_LeadingEdgeBackwards(edge_t *edge); -void R_TrailingEdge(surf_t *surf, edge_t *edge); //============================================================================= @@ -82,15 +77,9 @@ void R_BeginEdgeFrame(void) surfaces[1].flags = SURF_DRAWBACKGROUND; // put the background behind everything in the world - if (r_draworder.value) { - pdrawfunc = R_GenerateSpansBackward; - surfaces[1].key = 0; - r_currentkey = 1; - } else { - pdrawfunc = R_GenerateSpans; - surfaces[1].key = 0x7FFFFFFF; - r_currentkey = 0; - } + pdrawfunc = R_GenerateSpans; + surfaces[1].key = 0x7FFFFFFF; + r_currentkey = 0; // FIXME: set with memset for (v = r_refdef.vrect.y; v < r_refdef.vrectbottom; v++) { @@ -110,7 +99,7 @@ sentinel at the end (actually, this is the active edge table starting at edge_head.next). ============== */ -void R_InsertNewEdges(edge_t *edgestoadd, edge_t *edgelist) +static void R_InsertNewEdges(edge_t *edgestoadd, edge_t *edgelist) { edge_t *next_edge; @@ -145,7 +134,7 @@ void R_InsertNewEdges(edge_t *edgestoadd, edge_t *edgelist) R_RemoveEdges ============== */ -void R_RemoveEdges(edge_t *pedge) +static void R_RemoveEdges(edge_t *pedge) { do { @@ -159,7 +148,7 @@ void R_RemoveEdges(edge_t *pedge) R_StepActiveU ============== */ -void R_StepActiveU(edge_t *pedge) +static void R_StepActiveU(edge_t *pedge) { edge_t *pnext_edge, *pwedge; @@ -222,7 +211,7 @@ void R_StepActiveU(edge_t *pedge) R_CleanupSpan ============== */ -void R_CleanupSpan(void) +static void R_CleanupSpan(void) { espan_t *span; @@ -254,7 +243,7 @@ void R_CleanupSpan(void) R_LeadingEdgeBackwards ============== */ -void R_LeadingEdgeBackwards(edge_t *edge) +static void R_LeadingEdgeBackwards(edge_t *edge) { espan_t *span; surf_t *surf2; @@ -329,7 +318,7 @@ void R_LeadingEdgeBackwards(edge_t *edge) R_TrailingEdge ============== */ -void R_TrailingEdge(surf_t *surf, edge_t *edge) +static void R_TrailingEdge(surf_t *surf, edge_t *edge) { espan_t *span; int iu; @@ -366,7 +355,7 @@ void R_TrailingEdge(surf_t *surf, edge_t *edge) R_LeadingEdge ============== */ -void R_LeadingEdge(edge_t *edge) +static void R_LeadingEdge(edge_t *edge) { espan_t *span; surf_t *surf, *surf2; @@ -507,35 +496,6 @@ void R_GenerateSpans(void) R_CleanupSpan(); } -/* -============== -R_GenerateSpansBackward -============== -*/ -void R_GenerateSpansBackward(void) -{ - edge_t *edge; - - r_bmodelactive = 0; - - // clear active surfaces to just the background surface - surfaces[1].next = surfaces[1].prev = &surfaces[1]; - surfaces[1].last_u = edge_head_u_shift20; - - // generate spans - for (edge = edge_head.next; edge != &edge_tail; edge = edge->next) - { - if (edge->surfs[0]) - R_TrailingEdge(&surfaces[edge->surfs[0]], edge); - - if (edge->surfs[1]) - R_LeadingEdgeBackwards(edge); - } - - R_CleanupSpan(); -} - - /* ============== R_ScanEdges @@ -550,13 +510,10 @@ Each surface has a linked list of its visible spans */ void R_ScanEdges(void) { - int iv, bottom; - espan_t *basespans; - espan_t *basespan_p; surf_t *s; - - basespans = malloc(sizeof(espan_t)*CACHE_PAD_ARRAY(MAXSPANS, espan_t)); - basespan_p = (espan_t *) + int iv, bottom; + espan_t *basespans = malloc(sizeof(espan_t)*CACHE_PAD_ARRAY(MAXSPANS, espan_t)); + espan_t *basespan_p = (espan_t *) ((uintptr_t)(basespans + CACHE_SIZE - 1) & ~(uintptr_t)(CACHE_SIZE - 1)); max_span_p = &basespan_p[MAXSPANS - r_refdef.vrect.width]; diff --git a/common/r_light.c b/common/r_light.c index 668dbf63..511349a1 100644 --- a/common/r_light.c +++ b/common/r_light.c @@ -65,7 +65,7 @@ DYNAMIC LIGHTS R_MarkLights ============= */ -void R_MarkLights (dlight_t *light, int num, mnode_t *node) //qbism- adapted from MH tute - increased dlights +static void R_MarkLights (dlight_t *light, int num, mnode_t *node) //qbism- adapted from MH tute - increased dlights { mplane_t *splitplane; float dist; @@ -138,7 +138,7 @@ LIGHT SAMPLING ============================================================================= */ -int RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end) +static int RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end) { int r; float front, back, frac; @@ -251,7 +251,7 @@ vec3_t lightspot; // LordHavoc: .lit support begin // LordHavoc: original code replaced entirely -int RecursiveLightPointRGB(vec3_t color, mnode_t *node, vec3_t start, vec3_t end) +static int RecursiveLightPointRGB(vec3_t color, mnode_t *node, vec3_t start, vec3_t end) { float front, back, frac; vec3_t mid; @@ -361,15 +361,13 @@ int R_LightPoint(vec3_t p) vec3_t end; int r; - if (!cl.worldmodel->lightdata){ - lightcolor[0] = lightcolor[1] = lightcolor[2] = 255; - return 255; - } - - - + if (!cl.worldmodel->lightdata) + { + lightcolor[0] = lightcolor[1] = lightcolor[2] = 255; + return 255; + } - if (coloredlights) + if (coloredlights) { end[0] = p[0]; end[1] = p[1]; @@ -378,22 +376,18 @@ int R_LightPoint(vec3_t p) r = RecursiveLightPointRGB(lightcolor, cl.worldmodel->nodes, p, end); return ((lightcolor[0] + lightcolor[1] + lightcolor[2]) * (1.0f / 3.0f)); } - else - { - end[0] = p[0]; - end[1] = p[1]; - end[2] = p[2] - (8192 + 2); - - r = RecursiveLightPoint(cl.worldmodel->nodes, p, end); + end[0] = p[0]; + end[1] = p[1]; + end[2] = p[2] - (8192 + 2); - if (r == -1) - r = 0; + r = RecursiveLightPoint(cl.worldmodel->nodes, p, end); - if (r < r_refdef.ambientlight) - r = r_refdef.ambientlight; + if (r == -1) + r = 0; - return r; - } + if (r < r_refdef.ambientlight) + r = r_refdef.ambientlight; + return r; } diff --git a/common/r_local.h b/common/r_local.h index ddaeb9fa..43beace6 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -58,7 +58,6 @@ typedef struct { //=========================================================================== -extern cvar_t r_draworder; extern cvar_t r_graphheight; extern cvar_t r_clearcolor; extern cvar_t r_waterwarp; @@ -126,9 +125,6 @@ surf_t *R_GetSurf(void); void R_AliasDrawModel(entity_t *e, alight_t *plighting); void R_BeginEdgeFrame(void); void R_ScanEdges(void); -void R_InsertNewEdges(edge_t *edgestoadd, edge_t *edgelist); -void R_StepActiveU(edge_t *pedge); -void R_RemoveEdges(edge_t *pedge); extern void R_Surf8Start(void); extern void R_Surf8End(void); @@ -235,7 +231,6 @@ void R_cshift_f(void); void R_EmitEdge(mvertex_t *pv0, mvertex_t *pv1); void R_ClipEdge(mvertex_t *pv0, mvertex_t *pv1, clipplane_t *clip); void R_SplitEntityOnNode2(mnode_t *node); -void R_MarkLights(dlight_t *light, int bit, mnode_t *node); void R_DrawSurfaceBlockRGB_mip0(void); void R_DrawSurfaceBlockRGB_mip1(void); diff --git a/common/r_main.c b/common/r_main.c index b3a4bf4c..9dfcbe8f 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -95,7 +95,6 @@ float r_aliastransition, r_resfudge; int d_lightstylevalue[256]; // 8.8 fraction of base light value -cvar_t r_draworder = { "r_draworder", "0" }; cvar_t r_graphheight = { "r_graphheight", "15" }; cvar_t r_clearcolor = { "r_clearcolor", "2" }; cvar_t r_waterwarp = { "r_waterwarp", "1" }; @@ -184,7 +183,6 @@ R_Init(void) Cmd_AddCommand("pointfile", R_ReadPointFile_f); - Cvar_RegisterVariable(&r_draworder); Cvar_RegisterVariable(&r_graphheight); Cvar_RegisterVariable(&r_clearcolor); Cvar_RegisterVariable(&r_waterwarp); diff --git a/common/r_misc.c b/common/r_misc.c index 1d77c9e8..26876556 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -189,13 +189,11 @@ R_SetupFrame(void) // don't allow cheats in multiplayer #ifdef NQ_HACK if (cl.maxclients > 1) { - Cvar_Set("r_draworder", "0"); Cvar_Set("r_fullbright", "0"); Cvar_Set("r_ambient", "0"); } #endif #ifdef QW_HACK - r_draworder.value = 0; r_fullbright.value = 0; r_ambient.value = 0; #endif @@ -224,14 +222,6 @@ R_SetupFrame(void) if (r_refdef.ambientlight < 0) r_refdef.ambientlight = 0; -#ifdef NQ_HACK - if (!sv.active) - r_draworder.value = 0; // don't let cheaters look behind walls -#endif -#ifdef QW_HACK - r_draworder.value = 0; // don't let cheaters look behind walls -#endif - R_CheckVariables(); R_AnimateLight(); diff --git a/common/sv_main.c b/common/sv_main.c index 4c573be1..f68e0fed 100644 --- a/common/sv_main.c +++ b/common/sv_main.c @@ -349,8 +349,8 @@ void SV_SendServerinfo(client_t *client) MSG_WriteByte(&client->message, svc_print); MSG_WriteStringf(&client->message, - "%c\nVERSION TyrQuake-%s SERVER (%i CRC)", - 2, stringify(TYR_VERSION), pr_crc); + "%c\nVERSION TyrQuake-%s SERVER", + 2, stringify(TYR_VERSION)); MSG_WriteByte(&client->message, svc_serverinfo); MSG_WriteLong(&client->message, sv.protocol); From 85b6e574f11a1620285b4163bdbf09e7592da7f2 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 17:28:58 +0200 Subject: [PATCH 23/48] Get rid of unused variables r_fullbright, r_ambient, r_pointfile --- common/r_alias.c | 3 +-- common/r_local.h | 5 ---- common/r_main.c | 12 ---------- common/r_misc.c | 56 +-------------------------------------------- common/r_part.c | 59 ------------------------------------------------ common/r_surf.c | 4 ++-- 6 files changed, 4 insertions(+), 135 deletions(-) diff --git a/common/r_alias.c b/common/r_alias.c index f9dbc193..9aeeba05 100644 --- a/common/r_alias.c +++ b/common/r_alias.c @@ -689,8 +689,7 @@ static void R_AliasSetupSkin(const entity_t *e, aliashdr_t *pahdr) R_AliasSetupLighting ================ */ -void -R_AliasSetupLighting(alight_t *plighting) +static void R_AliasSetupLighting(alight_t *plighting) { // guarantee that no vertex will ever be lit below LIGHT_MIN, so we don't have diff --git a/common/r_local.h b/common/r_local.h index 43beace6..bb77b1be 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -61,10 +61,6 @@ typedef struct { extern cvar_t r_graphheight; extern cvar_t r_clearcolor; extern cvar_t r_waterwarp; -extern cvar_t r_fullbright; -extern cvar_t r_ambient; -extern cvar_t r_numsurfs; -extern cvar_t r_numedges; #define XCENTERING (1.0 / 2.0) #define YCENTERING (1.0 / 2.0) @@ -181,7 +177,6 @@ qboolean R_AliasCheckBBox(entity_t *e); void R_DrawParticles(void); void R_InitParticles(void); void R_ClearParticles(void); -void R_ReadPointFile_f(void); void R_PushDlights (struct mnode_s *headnode); //qbism - moved from render.h diff --git a/common/r_main.c b/common/r_main.c index 9dfcbe8f..0a88f3b4 100644 --- a/common/r_main.c +++ b/common/r_main.c @@ -98,15 +98,10 @@ int d_lightstylevalue[256]; // 8.8 fraction of base light value cvar_t r_graphheight = { "r_graphheight", "15" }; cvar_t r_clearcolor = { "r_clearcolor", "2" }; cvar_t r_waterwarp = { "r_waterwarp", "1" }; -cvar_t r_ambient = { "r_ambient", "0" }; -cvar_t r_numsurfs = { "r_numsurfs", "0" }; -cvar_t r_numedges = { "r_numedges", "0" }; cvar_t r_lockpvs = { "r_lockpvs", "0" }; cvar_t r_lockfrustum = { "r_lockfrustum", "0" }; -cvar_t r_fullbright = { "r_fullbright", "0" }; - static cvar_t r_maxsurfs = { "r_maxsurfs", "0" }; static cvar_t r_maxedges = { "r_maxedges", "0" }; static cvar_t r_aliastransbase = { "r_aliastransbase", "200" }; @@ -181,14 +176,9 @@ R_Init(void) R_InitTurb(); - Cmd_AddCommand("pointfile", R_ReadPointFile_f); - Cvar_RegisterVariable(&r_graphheight); Cvar_RegisterVariable(&r_clearcolor); Cvar_RegisterVariable(&r_waterwarp); - Cvar_RegisterVariable(&r_ambient); - Cvar_RegisterVariable(&r_numsurfs); - Cvar_RegisterVariable(&r_numedges); #ifdef NQ_HACK Cvar_RegisterVariable(&r_lerpmodels); Cvar_RegisterVariable(&r_lerpmove); @@ -196,8 +186,6 @@ R_Init(void) Cvar_RegisterVariable(&r_lockpvs); Cvar_RegisterVariable(&r_lockfrustum); - Cvar_RegisterVariable(&r_fullbright); - Cvar_RegisterVariable(&r_maxsurfs); Cvar_RegisterVariable(&r_maxedges); Cvar_RegisterVariable(&r_aliastransbase); diff --git a/common/r_misc.c b/common/r_misc.c index 26876556..9c23c16e 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -32,23 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include "sys.h" -/* -=============== -R_CheckVariables -=============== -*/ -static void -R_CheckVariables(void) -{ - // FIXME - do it right (cvar callback) - static float oldbright; - - if (r_fullbright.value != oldbright) { - oldbright = r_fullbright.value; - D_FlushCaches(); // so all lighting changes - } -} - /* ================ R_LineGraph @@ -182,47 +165,10 @@ R_SetupFrame void R_SetupFrame(void) { - int edgecount; vrect_t vrect; float w, h; -// don't allow cheats in multiplayer -#ifdef NQ_HACK - if (cl.maxclients > 1) { - Cvar_Set("r_fullbright", "0"); - Cvar_Set("r_ambient", "0"); - } -#endif -#ifdef QW_HACK - r_fullbright.value = 0; - r_ambient.value = 0; -#endif - - if (r_numsurfs.value) { - if ((surface_p - surfaces) > r_maxsurfsseen) - r_maxsurfsseen = surface_p - surfaces; - - Con_Printf("Used %d of %d surfs; %d max\n", - (int)(surface_p - surfaces), - (int)(surf_max - surfaces), r_maxsurfsseen); - } - - if (r_numedges.value) { - edgecount = edge_p - r_edges; - - if (edgecount > r_maxedgesseen) - r_maxedgesseen = edgecount; - - Con_Printf("Used %d of %d edges; %d max\n", edgecount, - r_numallocatededges, r_maxedgesseen); - } - - r_refdef.ambientlight = r_ambient.value; - - if (r_refdef.ambientlight < 0) - r_refdef.ambientlight = 0; - - R_CheckVariables(); + r_refdef.ambientlight = 0; R_AnimateLight(); diff --git a/common/r_part.c b/common/r_part.c index 22416fb3..e9a945fa 100644 --- a/common/r_part.c +++ b/common/r_part.c @@ -28,12 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "d_iface.h" #include "r_local.h" -#include - -/* forward declarations */ -int rfscanf(RFILE * stream, const char * format, ...); -int rfclose(RFILE* stream); - #define MAX_PARTICLES 2048 // default max # of particles at one // time #define ABSOLUTE_MIN_PARTICLES 512 // no fewer than this no matter what's @@ -50,7 +44,6 @@ int r_numparticles; vec3_t r_pright, r_pup, r_ppn; - /* =============== R_InitParticles @@ -156,58 +149,6 @@ void R_ClearParticles(void) particles[r_numparticles - 1].next = NULL; } - -void R_ReadPointFile_f(void) -{ - RFILE *f; - vec3_t org; - int r; - int c; - particle_t *p; - char name[MAX_OSPATH]; - -#ifdef NQ_HACK - snprintf(name, sizeof(name), "maps/%s.pts", sv.name); -#endif -#ifdef QW_HACK - snprintf(name, sizeof(name), "maps/%s.pts", - Info_ValueForKey(cl.serverinfo, "map")); -#endif - - COM_FOpenFile(name, &f); - if (!f) { - Con_Printf("couldn't open %s\n", name); - return; - } - - Con_Printf("Reading %s...\n", name); - c = 0; - for (;;) { - r = rfscanf(f, "%f %f %f\n", &org[0], &org[1], &org[2]); - if (r != 3) - break; - c++; - - if (!free_particles) { - Con_Printf("Not enough free particles\n"); - break; - } - p = free_particles; - free_particles = p->next; - p->next = active_particles; - active_particles = p; - - p->die = 99999; - p->color = (-c) & 15; - p->type = pt_static; - VectorCopy(vec3_origin, p->vel); - VectorCopy(org, p->org); - } - - rfclose(f); - Con_Printf("%i points read\n", c); -} - #ifdef NQ_HACK /* =============== diff --git a/common/r_surf.c b/common/r_surf.c index daa8d699..02574405 100644 --- a/common/r_surf.c +++ b/common/r_surf.c @@ -251,7 +251,7 @@ static void R_BuildLightMap(void) int size = smax * tmax; byte *lightmap = surf->samples; - if (r_fullbright.value || !cl.worldmodel->lightdata) + if (!cl.worldmodel->lightdata) { for (i = 0; i < size; i++) blocklights[i] = 0; @@ -311,7 +311,7 @@ void R_BuildLightMapRGB (void) size = smax*tmax*3; lightmap = surf->samples; - if (/* r_fullbright.value || */ !cl.worldmodel->lightdata) + if (!cl.worldmodel->lightdata) { for (i=0 ; i Date: Thu, 9 Jun 2022 17:43:22 +0200 Subject: [PATCH 24/48] Get rid of unused snd_noextraupdate --- common/cl_demo.c | 1 - common/cl_parse.c | 26 ++++++++++---------------- common/draw.c | 21 ++++----------------- common/snd_dma.c | 2 -- 4 files changed, 14 insertions(+), 36 deletions(-) diff --git a/common/cl_demo.c b/common/cl_demo.c index 7e32ee8d..47393b20 100644 --- a/common/cl_demo.c +++ b/common/cl_demo.c @@ -31,7 +31,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include /* forward declarations */ -RFILE* rfopen(const char *path, const char *mode); int rfclose(RFILE* stream); int64_t rfread(void* buffer, size_t elem_size, size_t elem_count, RFILE* stream); diff --git a/common/cl_parse.c b/common/cl_parse.c index e8d929b0..66e73478 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -392,7 +392,7 @@ CL_ParseUpdate(unsigned int bits) int i; model_t *model; int modnum; - qboolean forcelink; + qboolean forcelink = false; entity_t *ent; int num; @@ -423,8 +423,6 @@ CL_ParseUpdate(unsigned int bits) if (ent->msgtime != cl.mtime[1]) forcelink = true; // no previous frame to lerp from - else - forcelink = false; ent->msgtime = cl.mtime[0]; @@ -605,9 +603,8 @@ void CL_ParseClientdata(void) { int i, j; - unsigned int bits; + unsigned int bits = (unsigned short)MSG_ReadShort(); - bits = (unsigned short)MSG_ReadShort(); if (bits & SU_FITZ_EXTEND1) bits |= MSG_ReadByte() << 16; if (bits & SU_FITZ_EXTEND2) @@ -771,9 +768,7 @@ void CL_ParseStatic(unsigned int bits) { entity_t *ent; - int i; - - i = cl.num_statics; + int i = cl.num_statics; if (i >= MAX_STATIC_ENTITIES) Host_Error("Too many static entities"); ent = &cl_static_entities[i]; @@ -841,9 +836,9 @@ CL_ParseStaticSound(void) for (i = 0; i < 3; i++) org[i] = MSG_ReadCoord(); - sound_num = CL_ReadSoundNum_Static(); - vol = MSG_ReadByte(); - atten = MSG_ReadByte(); + sound_num = CL_ReadSoundNum_Static(); + vol = MSG_ReadByte(); + atten = MSG_ReadByte(); S_StaticSound(cl.sound_precache[sound_num], org, vol, atten); } @@ -858,9 +853,9 @@ CL_ParseFitzStaticSound2(void) for (i = 0; i < 3; i++) org[i] = MSG_ReadCoord(); - sound_num = MSG_ReadShort(); - vol = MSG_ReadByte(); - atten = MSG_ReadByte(); + sound_num = MSG_ReadShort(); + vol = MSG_ReadByte(); + atten = MSG_ReadByte(); S_StaticSound(cl.sound_precache[sound_num], org, vol, atten); } @@ -891,9 +886,8 @@ CL_ParseServerMessage(void) cmd = MSG_ReadByte(); - if (cmd == -1) { + if (cmd == -1) return; // end of message - } // if the high bit of the command byte is set, it is a fast update if (cmd & 128) { CL_ParseUpdate(cmd & 127); diff --git a/common/draw.c b/common/draw.c index 2ef61f05..a7cbaa95 100644 --- a/common/draw.c +++ b/common/draw.c @@ -670,10 +670,8 @@ Draw_Fill(int x, int y, int w, int h, int c) byte *dest; int u, v; - if (x < 0 || x + w > vid.width || y < 0 || y + h > vid.height) { - Con_Printf("Bad Draw_Fill(%d, %d, %d, %d, %c)\n", x, y, w, h, c); + if (x < 0 || x + w > vid.width || y < 0 || y + h > vid.height) return; - } { dest = vid.buffer + y * vid.rowbytes + x; @@ -695,14 +693,11 @@ void Draw_FadeScreen(void) { int x, y; - byte *pbuf; for (y = 0; y < vid.height; y++) { - int t; - - pbuf = (byte *)(vid.buffer + vid.rowbytes * y); - t = (y & 1) << 1; + byte *pbuf = (byte *)(vid.buffer + vid.rowbytes * y); + int t = (y & 1) << 1; for (x = 0; x < vid.width; x++) { if ((x & 3) != t) @@ -742,15 +737,9 @@ Draw_EndDisc(void) D_EndDirectRect(vid.width - 24, 0, 24, 24); } - - // Colored Lighting lookup tables - byte palmap2[64][64][64]; - - - /* =============== BestColor @@ -759,9 +748,7 @@ BestColor byte BestColor (int r, int g, int b, int start, int stop) { int i; -// -// let any color go to 0 as a last resort -// + // let any color go to 0 as a last resort int bestdistortion = 256*256*4; int bestcolor = 0; byte *pal = host_basepal + start*3; diff --git a/common/snd_dma.c b/common/snd_dma.c index 03dcfd40..3584fd3d 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -85,7 +85,6 @@ cvar_t sfxvolume = { "volume", "0.7", true }; static cvar_t precache = { "precache", "1" }; static cvar_t ambient_level = { "ambient_level", "0.3" }; static cvar_t ambient_fade = { "ambient_fade", "100" }; -static cvar_t snd_noextraupdate = { "snd_noextraupdate", "0" }; static cvar_t _snd_mixahead = { "_snd_mixahead", "0.1", true }; static void SND_Callback_sfxvolume (cvar_t *var) @@ -130,7 +129,6 @@ S_Init(void) Cvar_RegisterVariable(&bgmvolume); Cvar_RegisterVariable(&ambient_level); Cvar_RegisterVariable(&ambient_fade); - Cvar_RegisterVariable(&snd_noextraupdate); Cvar_RegisterVariable(&_snd_mixahead); S_Startup(); From 6ed92569ecc9c842cfe5e0054dd935771c1fb013 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 17:49:51 +0200 Subject: [PATCH 25/48] Remove unused cl_warncmd --- QW/client/cl_main.c | 2 -- QW/client/cl_parse.c | 2 -- QW/client/client.h | 1 - QW/server/sv_ccmds.c | 2 -- common/client.h | 4 ---- common/cmd.c | 14 +++----------- common/cmd.h | 2 -- 7 files changed, 3 insertions(+), 24 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index 67731744..55833564 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -1040,7 +1040,6 @@ CL_Init(void) // // register our commands // - Cvar_RegisterVariable(&cl_warncmd); Cvar_RegisterVariable(&cl_upspeed); Cvar_RegisterVariable(&cl_forwardspeed); Cvar_RegisterVariable(&cl_backspeed); @@ -1387,7 +1386,6 @@ Host_Init(quakeparms_t *parms) Cbuf_AddText("echo Type connect or use GameSpy to " "connect to a game.\n"); - Cbuf_AddText("cl_warncmd 1\n"); } diff --git a/QW/client/cl_parse.c b/QW/client/cl_parse.c index 6aa4f2b8..dab98db7 100644 --- a/QW/client/cl_parse.c +++ b/QW/client/cl_parse.c @@ -561,10 +561,8 @@ CL_ParseServerData(void) snprintf(fn, sizeof(fn), "%s/%s", com_gamedir, "config.cfg"); if ((f = rfopen(fn, "r")) != NULL) { rfclose(f); - Cbuf_AddText("cl_warncmd 0\n"); Cbuf_AddText("exec config.cfg\n"); Cbuf_AddText("exec frontend.cfg\n"); - Cbuf_AddText("cl_warncmd 1\n"); } } // parse player slot, high bit means spectator diff --git a/QW/client/client.h b/QW/client/client.h index 6dcd7a3d..61bbb137 100644 --- a/QW/client/client.h +++ b/QW/client/client.h @@ -297,7 +297,6 @@ typedef struct { // // cvars // -extern cvar_t cl_warncmd; extern cvar_t cl_upspeed; extern cvar_t cl_forwardspeed; extern cvar_t cl_backspeed; diff --git a/QW/server/sv_ccmds.c b/QW/server/sv_ccmds.c index 8b6d2288..b4e06962 100644 --- a/QW/server/sv_ccmds.c +++ b/QW/server/sv_ccmds.c @@ -876,6 +876,4 @@ SV_InitOperatorCommands(void) Cmd_AddCommand("sv_gamedir", SV_Gamedir); Cmd_AddCommand("floodprot", SV_Floodprot_f); Cmd_AddCommand("floodprotmsg", SV_Floodprotmsg_f); - - cl_warncmd.value = 1; } diff --git a/common/client.h b/common/client.h index 50c2d66b..7849f5ea 100644 --- a/common/client.h +++ b/common/client.h @@ -27,11 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "render.h" #include "vid.h" -#include - -// // client_state_t should hold all pieces of the client state -// typedef struct { vec3_t viewangles; diff --git a/common/cmd.c b/common/cmd.c index 786612b8..ebcaae2d 100644 --- a/common/cmd.c +++ b/common/cmd.c @@ -53,8 +53,6 @@ static DECLARE_STREE_ROOT(cmdalias_tree); static qboolean cmd_wait; -cvar_t cl_warncmd = { "cl_warncmd", "0" }; - //============================================================================= /* @@ -325,8 +323,6 @@ Cmd_Exec_f(void) Con_Printf("couldn't exec %s\n", Cmd_Argv(1)); return; } - if (cl_warncmd.value) - Con_Printf("execing %s\n", Cmd_Argv(1)); Cbuf_InsertText(f); Hunk_FreeToLowMark(mark); @@ -765,11 +761,11 @@ Cmd_ExecuteString(const char *text) #endif Cmd_TokenizeString(text); -// execute the command line + // execute the command line if (!Cmd_Argc()) return; // no tokens -// check functions + // check functions cmd = Cmd_FindCommand(cmd_argv[0]); if (cmd) { if (cmd->function) @@ -781,16 +777,12 @@ Cmd_ExecuteString(const char *text) return; } -// check alias + // check alias a = Cmd_Alias_Find(cmd_argv[0]); if (a) { Cbuf_InsertText(a->value); return; } - -// check cvars - if (!Cvar_Command() && cl_warncmd.value) - Con_Printf("Unknown command \"%s\"\n", Cmd_Argv(0)); } /* diff --git a/common/cmd.h b/common/cmd.h index 50284e0c..5b2ff065 100644 --- a/common/cmd.h +++ b/common/cmd.h @@ -26,8 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // cmd.h -- Command buffer and command execution -extern cvar_t cl_warncmd; - //=========================================================================== /* From 7750e1c1deca526d431195c71cc74aa174076cad Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 17:51:22 +0200 Subject: [PATCH 26/48] Remove unused extern --- common/host.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/common/host.h b/common/host.h index 800f50dd..2f35c372 100644 --- a/common/host.h +++ b/common/host.h @@ -28,8 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern quakeparms_t host_parms; -extern cvar_t sys_nostdout; - extern qboolean host_initialized; // true if into command execution extern double host_frametime; extern byte *host_basepal; From ededcc5dfbad90c07802963514d63fa6cf4cec4c Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 17:57:29 +0200 Subject: [PATCH 27/48] Cleanups --- common/model.h | 11 +---------- common/pr_cmds.c | 33 +-------------------------------- 2 files changed, 2 insertions(+), 42 deletions(-) diff --git a/common/model.h b/common/model.h index 41ef3674..c1246281 100644 --- a/common/model.h +++ b/common/model.h @@ -458,16 +458,7 @@ mleaf_t *Mod_PointInLeaf(const model_t *model, const vec3_t point); const leafbits_t *Mod_LeafPVS(const model_t *model, const mleaf_t *leaf); const leafbits_t *Mod_FatPVS(const model_t *model, const vec3_t point); -#ifdef _WIN32 -static INLINE int __ERRORLONGSIZE(void) -{ - fprintf(stderr, "Error occurred.\n"); - return 0; -} -#else -int __ERRORLONGSIZE(void); /* to generate an error at link time */ -#endif -#define QBYTESHIFT(x) ((x) == 8 ? 6 : ((x) == 4 ? 5 : __ERRORLONGSIZE() )) +#define QBYTESHIFT(x) ((x) == 8 ? 6 : ((x) == 4 ? 5 : 0 )) #define LEAFSHIFT QBYTESHIFT(sizeof(leafblock_t)) #define LEAFMASK ((sizeof(leafblock_t) << 3) - 1UL) diff --git a/common/pr_cmds.c b/common/pr_cmds.c index 3a9dc8fa..bc1e3d64 100644 --- a/common/pr_cmds.c +++ b/common/pr_cmds.c @@ -1756,36 +1756,6 @@ PF_changelevel(void) } #ifdef QW_HACK -/* -============== -PF_logfrag - -logfrag (killer, killee) -============== -*/ -static void -PF_logfrag(void) -{ - const char *s; - edict_t *ent1 = G_EDICT(OFS_PARM0); - edict_t *ent2 = G_EDICT(OFS_PARM1); - int e1 = NUM_FOR_EDICT(ent1); - int e2 = NUM_FOR_EDICT(ent2); - - if (e1 < 1 || e1 > MAX_CLIENTS || e2 < 1 || e2 > MAX_CLIENTS) - return; - - s = va("\\%s\\%s\\\n", svs.clients[e1 - 1].name, - svs.clients[e2 - 1].name); - - SZ_Print(&svs.log[svs.logsequence & 1], s); - if (sv_fraglogfile) { - fprintf(sv_fraglogfile, "%s", s); - fflush(sv_fraglogfile); - } -} - - /* ============== PF_infokey @@ -1858,11 +1828,10 @@ PF_multicast(void) static void PF_Fixme(void) { - PR_RunError("unimplemented bulitin"); + PR_RunError("unimplemented builtin"); } - builtin_t pr_builtin[] = { PF_Fixme, PF_makevectors, // void(entity e) makevectors = #1; From 3ce2b42b7ae5c91a76db935209d87d068cb0a429 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 18:04:44 +0200 Subject: [PATCH 28/48] Cleanups in pr_exec.c --- common/pr_exec.c | 116 ++++------------------------------------------- 1 file changed, 9 insertions(+), 107 deletions(-) diff --git a/common/pr_exec.c b/common/pr_exec.c index 9232a3d0..e0462fe2 100644 --- a/common/pr_exec.c +++ b/common/pr_exec.c @@ -50,94 +50,6 @@ dfunction_t *pr_xfunction; int pr_xstatement; int pr_argc; -const char *pr_opnames[] = { - "DONE", - - "MUL_F", - "MUL_V", - "MUL_FV", - "MUL_VF", - - "DIV", - - "ADD_F", - "ADD_V", - - "SUB_F", - "SUB_V", - - "EQ_F", - "EQ_V", - "EQ_S", - "EQ_E", - "EQ_FNC", - - "NE_F", - "NE_V", - "NE_S", - "NE_E", - "NE_FNC", - - "LE", - "GE", - "LT", - "GT", - - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - "INDIRECT", - - "ADDRESS", - - "STORE_F", - "STORE_V", - "STORE_S", - "STORE_ENT", - "STORE_FLD", - "STORE_FNC", - - "STOREP_F", - "STOREP_V", - "STOREP_S", - "STOREP_ENT", - "STOREP_FLD", - "STOREP_FNC", - - "RETURN", - - "NOT_F", - "NOT_V", - "NOT_S", - "NOT_ENT", - "NOT_FNC", - - "IF", - "IFNOT", - - "CALL0", - "CALL1", - "CALL2", - "CALL3", - "CALL4", - "CALL5", - "CALL6", - "CALL7", - "CALL8", - - "STATE", - - "GOTO", - - "AND", - "OR", - - "BITAND", - "BITOR" -}; - /* ============ PR_RunError @@ -183,8 +95,7 @@ PR_EnterFunction Returns the new program statement counter ==================== */ -int -PR_EnterFunction(dfunction_t *f) +static int PR_EnterFunction(dfunction_t *f) { int i, j, c, o; @@ -226,18 +137,9 @@ PR_LeaveFunction int PR_LeaveFunction(void) { - int i, c; - - if (pr_depth <= 0) -#ifdef NQ_HACK - Sys_Error("prog stack underflow"); -#endif -#ifdef QW_HACK - SV_Error("prog stack underflow"); -#endif - -// restore locals from the stack - c = pr_xfunction->locals; + int i; + // restore locals from the stack + int c = pr_xfunction->locals; localstack_used -= c; if (localstack_used < 0) PR_RunError("PR_ExecuteProgram: locals stack underflow\n"); @@ -246,7 +148,7 @@ PR_LeaveFunction(void) ((int *)pr_globals)[pr_xfunction->parm_start + i] = localstack[localstack_used + i]; -// up stack + // up stack pr_depth--; pr_xfunction = pr_stack[pr_depth].f; return pr_stack[pr_depth].s; @@ -281,14 +183,14 @@ PR_ExecuteProgram(func_t fnum) #endif } - f = &pr_functions[fnum]; + f = &pr_functions[fnum]; - runaway = 1000000; + runaway = 1000000; -// make a stack frame + // make a stack frame exitdepth = pr_depth; - s = PR_EnterFunction(f); + s = PR_EnterFunction(f); while (1) { s++; // next statement From e98949c6e02fb8cc9806d04cb12aaef79089d486 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 18:12:12 +0200 Subject: [PATCH 29/48] Simplify code - get rid of unused net_win files --- common/cl_input.c | 155 ++++++----------- common/d_modech.c | 1 - common/net_win.c | 85 ---------- common/net_wins.c | 420 ---------------------------------------------- common/net_wins.h | 38 ----- 5 files changed, 49 insertions(+), 650 deletions(-) delete mode 100644 common/net_win.c delete mode 100644 common/net_wins.c delete mode 100644 common/net_wins.h diff --git a/common/cl_input.c b/common/cl_input.c index 4be64bd6..f6201339 100644 --- a/common/cl_input.c +++ b/common/cl_input.c @@ -66,9 +66,7 @@ void KeyDown(kbutton_t *b) { int k; - const char *c; - - c = Cmd_Argv(1); + const char *c = Cmd_Argv(1); if (c[0]) k = atoi(c); else @@ -95,9 +93,7 @@ void KeyUp(kbutton_t *b) { int k; - const char *c; - - c = Cmd_Argv(1); + const char *c = Cmd_Argv(1); if (c[0]) k = atoi(c); else { // typed manually at the console, assume for unsticking, so clear all @@ -121,166 +117,139 @@ KeyUp(kbutton_t *b) b->state |= 4; // impulse up } -void -IN_KLookDown(void) +static void IN_KLookDown(void) { KeyDown(&in_klook); } -void -IN_KLookUp(void) +static void IN_KLookUp(void) { KeyUp(&in_klook); } -void -IN_MLookDown(void) +static void IN_MLookDown(void) { KeyDown(&in_mlook); } -void -IN_MLookUp(void) +static void IN_MLookUp(void) { KeyUp(&in_mlook); if (!(in_mlook.state & 1) && lookspring.value) V_StartPitchDrift(); } -void -IN_UpDown(void) +static void IN_UpDown(void) { KeyDown(&in_up); } -void -IN_UpUp(void) +static void IN_UpUp(void) { KeyUp(&in_up); } -void -IN_DownDown(void) +static void IN_DownDown(void) { KeyDown(&in_down); } -void -IN_DownUp(void) +static void IN_DownUp(void) { KeyUp(&in_down); } -void -IN_LeftDown(void) +static void IN_LeftDown(void) { KeyDown(&in_left); } -void -IN_LeftUp(void) +static void IN_LeftUp(void) { KeyUp(&in_left); } -void -IN_RightDown(void) +static void IN_RightDown(void) { KeyDown(&in_right); } -void -IN_RightUp(void) +static void IN_RightUp(void) { KeyUp(&in_right); } -void -IN_ForwardDown(void) +static void IN_ForwardDown(void) { KeyDown(&in_forward); } -void -IN_ForwardUp(void) +static void IN_ForwardUp(void) { KeyUp(&in_forward); } -void -IN_BackDown(void) +static void IN_BackDown(void) { KeyDown(&in_back); } -void -IN_BackUp(void) +static void IN_BackUp(void) { KeyUp(&in_back); } -void -IN_LookupDown(void) +static void IN_LookupDown(void) { KeyDown(&in_lookup); } -void -IN_LookupUp(void) +static void IN_LookupUp(void) { KeyUp(&in_lookup); } -void -IN_LookdownDown(void) +static void IN_LookdownDown(void) { KeyDown(&in_lookdown); } -void -IN_LookdownUp(void) +static void IN_LookdownUp(void) { KeyUp(&in_lookdown); } -void -IN_MoveleftDown(void) +static void IN_MoveleftDown(void) { KeyDown(&in_moveleft); } -void -IN_MoveleftUp(void) +static void IN_MoveleftUp(void) { KeyUp(&in_moveleft); } -void -IN_MoverightDown(void) +static void IN_MoverightDown(void) { KeyDown(&in_moveright); } -void -IN_MoverightUp(void) +static void IN_MoverightUp(void) { KeyUp(&in_moveright); } -void -IN_SpeedDown(void) +static void IN_SpeedDown(void) { KeyDown(&in_speed); } -void -IN_SpeedUp(void) +static void IN_SpeedUp(void) { KeyUp(&in_speed); } -void -IN_TogglewalkDown(void) +static void IN_TogglewalkDown(void) { KeyDown(&in_togglewalk); if (walkstate == 1) @@ -289,64 +258,52 @@ IN_TogglewalkDown(void) walkstate = 1; } -void -IN_TogglewalkUp(void) +static void IN_TogglewalkUp(void) { KeyUp(&in_togglewalk); } - - -void -IN_StrafeDown(void) +static void IN_StrafeDown(void) { KeyDown(&in_strafe); } -void -IN_StrafeUp(void) +static void IN_StrafeUp(void) { KeyUp(&in_strafe); } -void -IN_AttackDown(void) +static void IN_AttackDown(void) { KeyDown(&in_attack); } -void -IN_AttackUp(void) +static void IN_AttackUp(void) { KeyUp(&in_attack); } -void -IN_UseDown(void) +static void IN_UseDown(void) { KeyDown(&in_use); } -void -IN_UseUp(void) +static void IN_UseUp(void) { KeyUp(&in_use); } -void -IN_JumpDown(void) +static void IN_JumpDown(void) { KeyDown(&in_jump); } -void -IN_JumpUp(void) +static void IN_JumpUp(void) { KeyUp(&in_jump); } -void -IN_Impulse(void) +static void IN_Impulse(void) { in_impulse = Q_atoi(Cmd_Argv(1)); } @@ -364,27 +321,18 @@ Returns 0.25 if a key was pressed and released during the frame, float CL_KeyState(kbutton_t *key) { - float val; - qboolean impulsedown, impulseup, down; - - impulsedown = key->state & 2; - impulseup = key->state & 4; - down = key->state & 1; - val = 0; + qboolean impulsedown = key->state & 2; + qboolean impulseup = key->state & 4; + qboolean down = key->state & 1; + float val = 0; if (impulsedown && !impulseup) { if (down) val = 0.5; // pressed and held this frame - else - val = 0; // I_Error (); } // FIXME: both alternatives zero? - if (impulseup && !impulsedown) { - if (down) - val = 0; // I_Error (); - else - val = 0; // released this frame - } + if (impulseup && !impulsedown) + val = 0; if (!impulsedown && !impulseup) { if (down) val = 1.0; // held the entire frame @@ -428,16 +376,13 @@ CL_AdjustAngles Moves the local angle positions ================ */ -void -CL_AdjustAngles(void) +static void CL_AdjustAngles(void) { - float speed; float up, down; + float speed = host_frametime; if (in_speed.state & 1) - speed = host_frametime * cl_anglespeedkey.value; - else - speed = host_frametime; + speed *= cl_anglespeedkey.value; if (!(in_strafe.state & 1)) { cl.viewangles[YAW] -= @@ -515,9 +460,7 @@ CL_BaseMove(usercmd_t *cmd) cmd->forwardmove -= cl_backspeed.value * CL_KeyState(&in_back) * walkstate; } } -// -// adjust for speed key -// + // adjust for speed key if (in_speed.state & 1) { cmd->forwardmove *= cl_movespeedkey.value; cmd->sidemove *= cl_movespeedkey.value; diff --git a/common/d_modech.c b/common/d_modech.c index 94394676..e87f5d29 100644 --- a/common/d_modech.c +++ b/common/d_modech.c @@ -22,7 +22,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" #include "d_local.h" #include "render.h" -#include "sys.h" /* Sys_MakeCodeWriteable() */ int d_vrectx, d_vrecty, d_vrectright_particle, d_vrectbottom_particle; diff --git a/common/net_win.c b/common/net_win.c deleted file mode 100644 index db6ac923..00000000 --- a/common/net_win.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "net.h" -#include "net_dgrm.h" -#include "net_loop.h" -#include "net_wins.h" - -#include "quakedef.h" - -net_driver_t net_drivers[] = { - { - .name = "Loopback", - .initialized = false, - .Init = Loop_Init, - .Listen = Loop_Listen, - .SearchForHosts = Loop_SearchForHosts, - .Connect = Loop_Connect, - .CheckNewConnections = Loop_CheckNewConnections, - .QGetMessage = Loop_GetMessage, - .QSendMessage = Loop_SendMessage, - .SendUnreliableMessage = Loop_SendUnreliableMessage, - .CanSendMessage = Loop_CanSendMessage, - .CanSendUnreliableMessage = Loop_CanSendUnreliableMessage, - .Close = Loop_Close, - .Shutdown = Loop_Shutdown - }, { - .name = "Datagram", - .initialized = false, - .Init = Datagram_Init, - .Listen = Datagram_Listen, - .SearchForHosts = Datagram_SearchForHosts, - .Connect = Datagram_Connect, - .CheckNewConnections = Datagram_CheckNewConnections, - .QGetMessage = Datagram_GetMessage, - .QSendMessage = Datagram_SendMessage, - .SendUnreliableMessage = Datagram_SendUnreliableMessage, - .CanSendMessage = Datagram_CanSendMessage, - .CanSendUnreliableMessage = Datagram_CanSendUnreliableMessage, - .Close = Datagram_Close, - .Shutdown = Datagram_Shutdown - } -}; - -int net_numdrivers = 2; - -net_landriver_t net_landrivers[] = { - { - .name = "Winsock TCPIP", - .initialized = false, - .controlSock = 0, - .Init = WINS_Init, - .Shutdown = WINS_Shutdown, - .Listen = WINS_Listen, - .OpenSocket = WINS_OpenSocket, - .CloseSocket = WINS_CloseSocket, - .CheckNewConnections = WINS_CheckNewConnections, - .Read = WINS_Read, - .Write = WINS_Write, - .Broadcast = WINS_Broadcast, - .GetSocketAddr = WINS_GetSocketAddr, - .GetNameFromAddr = WINS_GetNameFromAddr, - .GetAddrFromName = WINS_GetAddrFromName, - .GetDefaultMTU = WINS_GetDefaultMTU - } -}; - -int net_numlandrivers = 1; diff --git a/common/net_wins.c b/common/net_wins.c deleted file mode 100644 index b7001728..00000000 --- a/common/net_wins.c +++ /dev/null @@ -1,420 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include - -#include "console.h" -#include "net.h" -#include "net_wins.h" -#include "quakedef.h" -#include "sys.h" -#include "winquake.h" - -/* socket for fielding new connections */ -static int net_acceptsocket = -1; -static int net_controlsocket; -static int net_broadcastsocket = 0; -static netadr_t broadcastaddr; - -/* - * There are three addresses that we may use in different ways: - * myAddr - This is the "default" address returned by the OS - * localAddr - This is an address to advertise in CCREP_SERVER_INFO - * and CCREP_ACCEPT response packets, rather than the - * default address (sometimes the default address is not - * suitable for LAN clients; i.e. loopback address). Set - * on the command line using the "-localip" option. - * bindAddr - The address to which we bind our network socket. The - * default is INADDR_ANY, but in some cases we may want - * to only listen on a particular address. Set on the - * command line using the "-ip" option. - */ -static netadr_t myAddr; -static netadr_t localAddr; -static netadr_t bindAddr; - -int winsock_initialized = 0; -WSADATA winsockdata; - -static double blocktime; - - -static void -NetadrToSockadr(const netadr_t *a, struct sockaddr_in *s) -{ - memset(s, 0, sizeof(*s)); - s->sin_family = AF_INET; - - s->sin_addr.s_addr = a->ip.l; - s->sin_port = a->port; -} - -static void -SockadrToNetadr(const struct sockaddr_in *s, netadr_t *a) -{ - a->ip.l = s->sin_addr.s_addr; - a->port = s->sin_port; -} - -static BOOL PASCAL FAR -BlockingHook(void) -{ - MSG msg; - BOOL ret; - - if ((Sys_DoubleTime() - blocktime) > 2.0) { - WSACancelBlockingCall(); - return FALSE; - } - - /* get the next message, if any */ - ret = (BOOL)PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); - - /* if we got one, process it */ - if (ret) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - /* TRUE if we got a message */ - return ret; -} - - -int -WINS_Init(void) -{ - int i; - int err; - char buff[MAXHOSTNAMELEN]; - char *colon; - struct hostent *local; - netadr_t addr; - - if (COM_CheckParm("-noudp")) - return -1; - - if (!winsock_initialized) { - err = WSAStartup(MAKEWORD(1,1), &winsockdata); - if (err) - return -1; - } - winsock_initialized++; - - /* determine my name & address */ - myAddr.ip.l = htonl(INADDR_LOOPBACK); - myAddr.port = htons(DEFAULTnet_hostport); - err = gethostname(buff, MAXHOSTNAMELEN); - if (err) { - Con_Printf("%s: WARNING: gethostname failed.\n", __func__); - } else { - buff[MAXHOSTNAMELEN - 1] = 0; - blocktime = Sys_DoubleTime(); - WSASetBlockingHook(BlockingHook); - local = gethostbyname(buff); - WSAUnhookBlockingHook(); - if (!local) { - Con_Printf("%s: WARNING: gethostbyname timed out.\n", __func__); - } else if (local->h_addrtype != AF_INET) { - Con_Printf("%s: address from gethostbyname not IPv4\n", __func__); - } else { - struct in_addr *inaddr = (struct in_addr *)local->h_addr_list[0]; - myAddr.ip.l = inaddr->S_un.S_addr; - } - } - Con_Printf("UDP, Local address: %s\n", NET_AdrToString(&myAddr)); - - i = COM_CheckParm("-ip"); - if (i && i < com_argc - 1) { - bindAddr.ip.l = inet_addr(com_argv[i + 1]); - if (bindAddr.ip.l == INADDR_NONE) - Sys_Error("%s: %s is not a valid IP address", __func__, - com_argv[i + 1]); - Con_Printf("Binding to IP Interface Address of %s\n", com_argv[i + 1]); - } else { - bindAddr.ip.l = INADDR_NONE; - } - - i = COM_CheckParm("-localip"); - if (i && i < com_argc - 1) { - localAddr.ip.l = inet_addr(com_argv[i + 1]); - if (localAddr.ip.l == INADDR_NONE) - Sys_Error("%s: %s is not a valid IP address", __func__, - com_argv[i + 1]); - Con_Printf("Advertising %s as the local IP in response packets\n", - com_argv[i + 1]); - } else { - localAddr.ip.l = INADDR_NONE; - } - - net_controlsocket = WINS_OpenSocket(0); - if (net_controlsocket == -1) { - Con_Printf("%s: Unable to open control socket\n", __func__); - if (--winsock_initialized == 0) - WSACleanup(); - return -1; - } - - broadcastaddr.ip.l = INADDR_BROADCAST; - broadcastaddr.port = htons(net_hostport); - - WINS_GetSocketAddr(net_controlsocket, &addr); - strcpy(my_tcpip_address, NET_AdrToString(&addr)); - colon = strrchr(my_tcpip_address, ':'); - if (colon) - *colon = 0; - - Con_Printf("Winsock TCP/IP Initialized (%s)\n", my_tcpip_address); - tcpipAvailable = true; - - return net_controlsocket; -} - - -void -WINS_Shutdown(void) -{ - WINS_Listen(false); - WINS_CloseSocket(net_controlsocket); - if (--winsock_initialized == 0) - WSACleanup(); -} - - -void -WINS_Listen(qboolean state) -{ - /* enable listening */ - if (state) { - if (net_acceptsocket != -1) - return; - if ((net_acceptsocket = WINS_OpenSocket(net_hostport)) == -1) - Sys_Error("%s: Unable to open accept socket", __func__); - return; - } - - /* disable listening */ - if (net_acceptsocket == -1) - return; - - WINS_CloseSocket(net_acceptsocket); - net_acceptsocket = -1; -} - - -int -WINS_OpenSocket(int port) -{ - int newsocket; - struct sockaddr_in address; - netadr_t addr; - u_long _true = 1; - - if ((newsocket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) - return -1; - if (ioctlsocket(newsocket, FIONBIO, &_true) == -1) - goto ErrorReturn; - - address.sin_family = AF_INET; - if (bindAddr.ip.l != INADDR_NONE) - address.sin_addr.s_addr = bindAddr.ip.l; - else - address.sin_addr.s_addr = INADDR_ANY; - address.sin_port = htons((unsigned short)port); - if (bind(newsocket, (struct sockaddr *)&address, sizeof(address)) == 0) - return newsocket; - - SockadrToNetadr(&address, &addr); - if (tcpipAvailable) - Sys_Error("Unable to bind to %s", NET_AdrToString(&addr)); - else /* we are still in init phase, no need to error */ - Con_Printf("Unable to bind to %s\n", NET_AdrToString(&addr)); - - ErrorReturn: - closesocket(newsocket); - return -1; -} - - -int -WINS_CloseSocket(int socket) -{ - if (socket == net_broadcastsocket) - net_broadcastsocket = 0; - return closesocket(socket); -} - - -int -WINS_CheckNewConnections(void) -{ - char buf[4096]; - int ret; - - if (net_acceptsocket == -1) - return -1; - - ret = recvfrom(net_acceptsocket, buf, sizeof(buf), MSG_PEEK, NULL, NULL); - if (ret >= 0) - return net_acceptsocket; - - return -1; -} - - -int -WINS_Read(int socket, void *buf, int len, netadr_t *addr) -{ - struct sockaddr_in saddr; - int addrlen = sizeof(saddr); - int ret; - - ret = recvfrom(socket, (char *)buf, len, 0, (struct sockaddr *)&saddr, - &addrlen); - SockadrToNetadr(&saddr, addr); - if (ret == -1) { - int err = WSAGetLastError(); - - if (err == WSAEWOULDBLOCK || err == WSAECONNREFUSED) - return 0; - } - return ret; -} - - -static int -WINS_MakeSocketBroadcastCapable(int socket) -{ - int i = 1; - - /* make this socket broadcast capable */ - if (setsockopt - (socket, SOL_SOCKET, SO_BROADCAST, (char *)&i, sizeof(i)) < 0) - return -1; - net_broadcastsocket = socket; - - return 0; -} - - -int -WINS_Broadcast(int socket, const void *buf, int len) -{ - int ret; - - if (socket != net_broadcastsocket) { - if (net_broadcastsocket != 0) - Sys_Error("Attempted to use multiple broadcasts sockets"); - ret = WINS_MakeSocketBroadcastCapable(socket); - if (ret == -1) { - Con_Printf("Unable to make socket broadcast capable\n"); - return ret; - } - } - - return WINS_Write(socket, buf, len, &broadcastaddr); -} - - -int -WINS_Write(int socket, const void *buf, int len, const netadr_t *addr) -{ - struct sockaddr_in saddr; - int ret; - - NetadrToSockadr(addr, &saddr); - ret = sendto(socket, (char *)buf, len, 0, (struct sockaddr *)&saddr, - sizeof(saddr)); - if (ret == -1) - if (WSAGetLastError() == WSAEWOULDBLOCK) - return 0; - - return ret; -} - - -int -WINS_GetSocketAddr(int socket, netadr_t *addr) -{ - struct sockaddr_in saddr; - int len = sizeof(saddr); - - memset(&saddr, 0, len); - getsockname(socket, (struct sockaddr *)&saddr, &len); - - /* - * The returned IP is embedded in our repsonse to a broadcast request for - * server info from clients. The server admin may wish to advertise a - * specific IP for various reasons, so allow the "default" address - * returned by the OS to be overridden. - */ - if (localAddr.ip.l != INADDR_NONE) - saddr.sin_addr.s_addr = localAddr.ip.l; - else { - struct in_addr a = saddr.sin_addr; - if (!a.s_addr || a.s_addr == htonl(INADDR_LOOPBACK)) - saddr.sin_addr.s_addr = myAddr.ip.l; - } - SockadrToNetadr(&saddr, addr); - - return 0; -} - - -int -WINS_GetNameFromAddr(const netadr_t *addr, char *name) -{ - struct hostent *hostentry; - - hostentry = gethostbyaddr((char *)&addr->ip.l, sizeof(addr->ip.l), AF_INET); - if (hostentry) { - strncpy(name, (char *)hostentry->h_name, NET_NAMELEN - 1); - return 0; - } - strcpy(name, NET_AdrToString(addr)); - - return 0; -} - - -int -WINS_GetAddrFromName(const char *name, netadr_t *addr) -{ - struct hostent *hostentry; - - if (name[0] >= '0' && name[0] <= '9') - return NET_PartialIPAddress(name, &myAddr, addr); - - hostentry = gethostbyname(name); - if (!hostentry) - return -1; - - addr->ip.l = *(int *)hostentry->h_addr_list[0]; - addr->port = htons(net_hostport); - - return 0; -} - - -int -WINS_GetDefaultMTU(void) -{ - return 1400; -} diff --git a/common/net_wins.h b/common/net_wins.h deleted file mode 100644 index 63b5a39f..00000000 --- a/common/net_wins.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#ifndef NET_WINS_H -#define NET_WINS_H - -int WINS_Init(void); -void WINS_Shutdown(void); -void WINS_Listen(qboolean state); -int WINS_OpenSocket(int port); -int WINS_CloseSocket(int socket); -int WINS_CheckNewConnections(void); -int WINS_Read(int socket, void *buf, int len, netadr_t *addr); -int WINS_Write(int socket, const void *buf, int len, const netadr_t *addr); -int WINS_Broadcast(int socket, const void *buf, int len); -int WINS_GetSocketAddr(int socket, netadr_t *addr); -int WINS_GetNameFromAddr(const netadr_t *addr, char *name); -int WINS_GetAddrFromName(const char *name, netadr_t *addr); -int WINS_GetDefaultMTU(void); - -#endif /* NET_WINS_H */ From fb10716f6bd831e91e393c303b3d757baa3a84e6 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 18:39:11 +0200 Subject: [PATCH 30/48] Doesn't read or write to config.cfg anymore - options will be added from now on to core options --- common/host.c | 32 -------------------------------- common/libretro.c | 33 ++++++++++++--------------------- 2 files changed, 12 insertions(+), 53 deletions(-) diff --git a/common/host.c b/common/host.c index ce2ddd91..76c3749c 100644 --- a/common/host.c +++ b/common/host.c @@ -43,12 +43,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "r_local.h" #include "render.h" -#include - -/* forward declarations */ -RFILE* rfopen(const char *path, const char *mode); -int rfclose(RFILE* stream); - /* * A server can always be started, even if the system started out as a client * to a remote system. @@ -244,30 +238,6 @@ Host_InitLocal(void) } -/* -=============== -Host_WriteConfiguration - -Writes key bindings and archived cvars to config.cfg -=============== -*/ -void -Host_WriteConfiguration(void) -{ - // dedicated servers initialize the host but don't parse and set the - // config.cfg cvars - if (host_initialized & !isDedicated) { - RFILE *f = rfopen(va("%s/config.cfg", com_savedir), "w"); - if (!f) { - Con_Printf("Couldn't write config.cfg.\n"); - return; - } - Cvar_WriteVariables(f); - rfclose(f); - } -} - - /* ================= SV_ClientPrintf @@ -794,8 +764,6 @@ Host_Shutdown(void) /* keep Con_Printf from trying to update the screen */ scr_disabled_for_loading = true; - Host_WriteConfiguration(); - CDAudio_Shutdown(); NET_Shutdown(); BGM_Shutdown(); diff --git a/common/libretro.c b/common/libretro.c index 7ade4211..82b84897 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -984,7 +984,6 @@ bool retro_load_game(const struct retro_game_info *info) char g_rom_dir[PATH_MAX_LENGTH]; char g_pak_path[PATH_MAX_LENGTH]; char g_save_dir[PATH_MAX_LENGTH]; - char cfg_file[PATH_MAX_LENGTH]; char *path_lower = NULL; quakeparms_t parms; bool use_external_savedir = false; @@ -994,7 +993,6 @@ bool retro_load_game(const struct retro_game_info *info) g_rom_dir[0] = '\0'; g_pak_path[0] = '\0'; g_save_dir[0] = '\0'; - cfg_file[0] = '\0'; if (!info) return false; @@ -1142,28 +1140,21 @@ bool retro_load_game(const struct retro_game_info *info) return false; } - /* Override some default binds with more modern ones if we are booting the - * game for the first time. */ - fill_pathname_join(cfg_file, g_save_dir, "config.cfg", sizeof(cfg_file)); + Cvar_Set("gamma", "0.95"); + Cmd_ExecuteString("bind ' \"toggleconsole\"", src_command); + Cmd_ExecuteString("bind ~ \"toggleconsole\"", src_command); + Cmd_ExecuteString("bind ` \"toggleconsole\"", src_command); - if (!path_is_valid(cfg_file)) - { - Cvar_Set("gamma", "0.95"); - Cmd_ExecuteString("bind ' \"toggleconsole\"", src_command); - Cmd_ExecuteString("bind ~ \"toggleconsole\"", src_command); - Cmd_ExecuteString("bind ` \"toggleconsole\"", src_command); - - Cmd_ExecuteString("bind f \"+moveup\"", src_command); - Cmd_ExecuteString("bind c \"+movedown\"", src_command); + Cmd_ExecuteString("bind f \"+moveup\"", src_command); + Cmd_ExecuteString("bind c \"+movedown\"", src_command); - Cmd_ExecuteString("bind a \"+moveleft\"", src_command); - Cmd_ExecuteString("bind d \"+moveright\"", src_command); - Cmd_ExecuteString("bind w \"+forward\"", src_command); - Cmd_ExecuteString("bind s \"+back\"", src_command); + Cmd_ExecuteString("bind a \"+moveleft\"", src_command); + Cmd_ExecuteString("bind d \"+moveright\"", src_command); + Cmd_ExecuteString("bind w \"+forward\"", src_command); + Cmd_ExecuteString("bind s \"+back\"", src_command); - Cmd_ExecuteString("bind e \"impulse 10\"", src_command); - Cmd_ExecuteString("bind q \"impulse 12\"", src_command); - } + Cmd_ExecuteString("bind e \"impulse 10\"", src_command); + Cmd_ExecuteString("bind q \"impulse 12\"", src_command); Cmd_ExecuteString("bind AUX1 \"+moveright\"", src_command); Cmd_ExecuteString("bind AUX2 \"+moveleft\"", src_command); From 1f1c389f1a979c99f93c1a2480dcc8c6207b1b24 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 19:53:41 +0200 Subject: [PATCH 31/48] Cleanups --- QW/client/cl_main.c | 27 ---------------------- QW/client/cl_parse.c | 2 -- QW/client/client.h | 1 - common/cvar.c | 54 -------------------------------------------- common/cvar.h | 15 ------------ common/keys.h | 2 -- 6 files changed, 101 deletions(-) diff --git a/QW/client/cl_main.c b/QW/client/cl_main.c index 55833564..e427f348 100644 --- a/QW/client/cl_main.c +++ b/QW/client/cl_main.c @@ -1200,31 +1200,6 @@ Host_Error(const char *error, ...) } -/* -=============== -Host_WriteConfiguration - -Writes key bindings and archived cvars to config.cfg -=============== -*/ -void -Host_WriteConfiguration(void) -{ - RFILE *f; - - if (host_initialized) { - f = rfopen(va("%s/config.cfg", com_gamedir), "w"); - if (!f) { - Con_Printf("Couldn't write config.cfg.\n"); - return; - } - - Cvar_WriteVariables(f); - rfclose(f); - } -} - - //============================================================================ /* @@ -1406,8 +1381,6 @@ Host_Shutdown(void) return; isdown = true; - Host_WriteConfiguration(); - CDAudio_Shutdown(); NET_Shutdown(); S_Shutdown(); diff --git a/QW/client/cl_parse.c b/QW/client/cl_parse.c index dab98db7..a2a88459 100644 --- a/QW/client/cl_parse.c +++ b/QW/client/cl_parse.c @@ -548,8 +548,6 @@ CL_ParseServerData(void) str = MSG_ReadString(); if (strcasecmp(gamedirfile, str)) { - // save current config - Host_WriteConfiguration(); cflag = true; } diff --git a/QW/client/client.h b/QW/client/client.h index 61bbb137..90f32e01 100644 --- a/QW/client/client.h +++ b/QW/client/client.h @@ -369,7 +369,6 @@ void CL_DecayLights(void); void CL_RunParticles(void); void CL_Init(void); -void Host_WriteConfiguration(void); void CL_EstablishConnection(char *host); diff --git a/common/cvar.c b/common/cvar.c index afd6b3ca..5f44af46 100644 --- a/common/cvar.c +++ b/common/cvar.c @@ -42,11 +42,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #endif -#include - -/* forward declarations */ -int rfprintf(RFILE * stream, const char * format, ...); - #define cvar_entry(ptr) container_of(ptr, struct cvar_s, stree) DECLARE_STREE_ROOT(cvar_tree); @@ -325,52 +320,3 @@ void Cvar_SetCallback (cvar_t *var, cvar_callback func) var->flags |= CVAR_CALLBACK; else var->flags &= ~CVAR_CALLBACK; } - -/* -============ -Cvar_Command - -Handles variable inspection and changing from the console -============ -*/ -qboolean Cvar_Command(void) -{ - /* check variables */ - cvar_t *v = Cvar_FindVar(Cmd_Argv(0)); - if (!v) - return false; - - /* perform a variable print or set */ - if (Cmd_Argc() == 1) - { - if (v->flags & CVAR_OBSOLETE) - Con_Printf("%s is obsolete.\n", v->name); - else - Con_Printf("\"%s\" is \"%s\"\n", v->name, v->string); - return true; - } - - Cvar_Set(v->name, Cmd_Argv(1)); - return true; -} - - -/* -============ -Cvar_WriteVariables - -Writes lines containing "set variable value" for all variables -with the archive flag set to true. -============ -*/ -void Cvar_WriteVariables(RFILE *f) -{ - struct stree_node *n; - - STree_ForEach_After_NullStr(&cvar_tree, n) - { - cvar_t *var = cvar_entry(n); - if (var->archive) - rfprintf(f, "%s \"%s\"\n", var->name, var->string); - } -} diff --git a/common/cvar.h b/common/cvar.h index f63e0765..a4b5ba90 100644 --- a/common/cvar.h +++ b/common/cvar.h @@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef CVAR_H #define CVAR_H -#include - #include "shell.h" #include "qtypes.h" @@ -125,19 +123,6 @@ float Cvar_VariableValue(const char *var_name); /* returns an empty string if not defined */ const char *Cvar_VariableString(const char *var_name); -/* - * called by Cmd_ExecuteString when Cmd_Argv(0) doesn't match a known command. - * Returns true if the command was a variable reference that was - * handled. (print or change) - */ -qboolean Cvar_Command(void); - -/* - * Writes lines containing "set variable value" for all variables with the - * archive flag set to true. - */ -void Cvar_WriteVariables(RFILE *f); - /* */ cvar_t *Cvar_FindVar(const char *var_name); diff --git a/common/keys.h b/common/keys.h index cc2337da..7f554b40 100644 --- a/common/keys.h +++ b/common/keys.h @@ -21,8 +21,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef KEYS_H #define KEYS_H -#include - #include "qtypes.h" /* From 170a75e1a1494030c60d6447060bb0eb759f8002 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 19:54:47 +0200 Subject: [PATCH 32/48] Remove unused R_LeadingEdgeBackwards --- common/r_edge.c | 76 ------------------------------------------------- 1 file changed, 76 deletions(-) diff --git a/common/r_edge.c b/common/r_edge.c index f22abca1..35cd94ed 100644 --- a/common/r_edge.c +++ b/common/r_edge.c @@ -237,82 +237,6 @@ static void R_CleanupSpan(void) } while (surf != &surfaces[1]); } - -/* -============== -R_LeadingEdgeBackwards -============== -*/ -static void R_LeadingEdgeBackwards(edge_t *edge) -{ - espan_t *span; - surf_t *surf2; - int iu; - - // it's adding a new surface in, so find the correct place - surf_t *surf = &surfaces[edge->surfs[1]]; - - // don't start a span if this is an inverted span, with the end - // edge preceding the start edge (that is, we've already seen the - // end edge) - if (++surf->spanstate != 1) - return; - - surf2 = surfaces[1].next; - - if (surf->key > surf2->key) - goto newtop; - - // if it's two surfaces on the same plane, the one that's already - // active is in front, so keep going unless it's a bmodel - if (surf->insubmodel && (surf->key == surf2->key)) { - // must be two bmodels in the same leaf; don't care, because they'll - // never be farthest anyway - goto newtop; - } - -continue_search: - - do { - surf2 = surf2->next; - } while (surf->key < surf2->key); - - if (surf->key == surf2->key) { - // if it's two surfaces on the same plane, the one that's already - // active is in front, so keep going unless it's a bmodel - if (!surf->insubmodel) - goto continue_search; - - // must be two bmodels in the same leaf; don't care which is really - // in front, because they'll never be farthest anyway - } - - goto gotposition; - -newtop: - // emit a span (obscures current top) - iu = edge->u >> 20; - - if (iu > surf2->last_u) { - span = span_p++; - span->u = surf2->last_u; - span->count = iu - span->u; - span->v = current_iv; - span->pnext = surf2->spans; - surf2->spans = span; - } - // set last_u on the new span - surf->last_u = iu; - -gotposition: - // insert before surf2 - surf->next = surf2; - surf->prev = surf2->prev; - surf2->prev->next = surf; - surf2->prev = surf; -} - - /* ============== R_TrailingEdge From 36c4b0d1b1538f17ca36e34bf3ab25394ec626b4 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 20:04:08 +0200 Subject: [PATCH 33/48] * r_edge - don't go through function pointer * Get rid of r_vars.c --- Makefile.common | 1 - common/r_edge.c | 21 ++++----------------- common/r_local.h | 1 - common/r_vars.c | 34 ---------------------------------- 4 files changed, 4 insertions(+), 53 deletions(-) delete mode 100644 common/r_vars.c diff --git a/Makefile.common b/Makefile.common index ff3c49b6..d33dd44d 100644 --- a/Makefile.common +++ b/Makefile.common @@ -65,7 +65,6 @@ SOURCES_C := \ $(CORE_DIR)/common/r_part.c \ $(CORE_DIR)/common/r_sky.c \ $(CORE_DIR)/common/r_sprite.c \ - $(CORE_DIR)/common/r_vars.c \ $(CORE_DIR)/common/r_surf.c \ $(CORE_DIR)/common/rb_tree.c \ $(CORE_DIR)/common/sbar.c \ diff --git a/common/r_edge.c b/common/r_edge.c index 35cd94ed..d3a48097 100644 --- a/common/r_edge.c +++ b/common/r_edge.c @@ -46,8 +46,6 @@ int current_iv; int edge_head_u_shift20, edge_tail_u_shift20; -static void (*pdrawfunc) (void); - edge_t edge_head; edge_t edge_tail; edge_t edge_aftertail; @@ -55,8 +53,6 @@ edge_t edge_sentinel; float fv; -void R_GenerateSpans(void); - //============================================================================= /* @@ -77,9 +73,8 @@ void R_BeginEdgeFrame(void) surfaces[1].flags = SURF_DRAWBACKGROUND; // put the background behind everything in the world - pdrawfunc = R_GenerateSpans; surfaces[1].key = 0x7FFFFFFF; - r_currentkey = 0; + r_currentkey = 0; // FIXME: set with memset for (v = r_refdef.vrect.y; v < r_refdef.vrectbottom; v++) { @@ -253,9 +248,6 @@ static void R_TrailingEdge(surf_t *surf, edge_t *edge) if (--surf->spanstate != 0) return; - if (surf->insubmodel) - r_bmodelactive--; - if (surf == surfaces[1].next) { // emit a span (current top going away) iu = edge->u >> 20; @@ -298,9 +290,6 @@ static void R_LeadingEdge(edge_t *edge) if (++surf->spanstate != 1) return; - if (surf->insubmodel) - r_bmodelactive++; - surf2 = surfaces[1].next; if (surf->key < surf2->key) @@ -391,13 +380,11 @@ static void R_LeadingEdge(edge_t *edge) R_GenerateSpans ============== */ -void R_GenerateSpans(void) +static void R_GenerateSpans(void) { edge_t *edge; surf_t *surf; - r_bmodelactive = 0; - // clear active surfaces to just the background surface surfaces[1].next = surfaces[1].prev = &surfaces[1]; surfaces[1].last_u = edge_head_u_shift20; @@ -486,7 +473,7 @@ void R_ScanEdges(void) R_InsertNewEdges(newedges[iv], edge_head.next); } - (*pdrawfunc) (); + R_GenerateSpans(); // flush the span list if we can't be sure we have enough spans left // for the next scan @@ -521,7 +508,7 @@ void R_ScanEdges(void) if (newedges[iv]) R_InsertNewEdges(newedges[iv], edge_head.next); - (*pdrawfunc) (); + R_GenerateSpans(); // draw whatever's left in the span list D_DrawSurfaces(); diff --git a/common/r_local.h b/common/r_local.h index bb77b1be..867d1485 100644 --- a/common/r_local.h +++ b/common/r_local.h @@ -193,7 +193,6 @@ extern int screenwidth; extern edge_t edge_head; extern edge_t edge_tail; extern edge_t edge_aftertail; -extern int r_bmodelactive; extern float aliasxscale, aliasyscale, aliasxcenter, aliasycenter; extern float r_aliastransition, r_resfudge; diff --git a/common/r_vars.c b/common/r_vars.c deleted file mode 100644 index 3254795f..00000000 --- a/common/r_vars.c +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ -// r_vars.c: global refresh variables - -#include "quakedef.h" - -// all global and static refresh variables are collected in a contiguous block -// to avoid cache conflicts. - -//------------------------------------------------------- -// global refresh variables -//------------------------------------------------------- - -// FIXME: make into one big structure, like cl or sv -// FIXME: do separately for refresh engine and driver - -int r_bmodelactive; From c439cc6c57ab0faa32d68a2458814ebe5773c41a Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 20:06:08 +0200 Subject: [PATCH 34/48] Remove D_CheckCacheGuard debug function --- common/d_surf.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/common/d_surf.c b/common/d_surf.c index 6b8aaa1a..06acbfd1 100644 --- a/common/d_surf.c +++ b/common/d_surf.c @@ -58,15 +58,6 @@ int D_SurfaceCacheForRes(int width, int height) return size; } -void D_CheckCacheGuard(void) -{ - int i; - byte *s = (byte *)sc_base + sc_size; - for (i = 0; i < GUARDSIZE; i++) - if (s[i] != (byte)i) - Sys_Error("%s: failed", __func__); -} - void D_ClearCacheGuard(void) { int i; @@ -192,7 +183,6 @@ D_SCAlloc(int width, int size) d_roverwrapped = true; } - D_CheckCacheGuard(); // DEBUG return new_surf; } From 67bd25909d6a47398409ae553e28e3bd6c17595a Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Thu, 9 Jun 2022 20:12:31 +0200 Subject: [PATCH 35/48] remove unused R_LineGraph --- common/r_misc.c | 47 ++--------------------------------------------- 1 file changed, 2 insertions(+), 45 deletions(-) diff --git a/common/r_misc.c b/common/r_misc.c index 9c23c16e..2f2beb54 100644 --- a/common/r_misc.c +++ b/common/r_misc.c @@ -32,49 +32,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #include "sys.h" -/* -================ -R_LineGraph - -Only called by R_DisplayTime -================ -*/ -void -R_LineGraph(int x, int y, int h) -{ - int i; - byte *dest; - int s; - int color; - -// FIXME: should be disabled on no-buffer adapters, or should be in the driver - -#ifdef NQ_HACK - x += r_refdef.vrect.x; - y += r_refdef.vrect.y; -#endif - dest = vid.buffer + vid.rowbytes * y + x; - - s = r_graphheight.value; - - if (h == 10000) - color = 0x6f; // yellow - else if (h == 9999) - color = 0x4f; // red - else if (h == 9998) - color = 0xd0; // blue - else - color = 0xff; // pink - - if (h > s) - h = s; - - for (i = 0; i < h; i++, dest -= vid.rowbytes * 2) - dest[0] = color; -} - -#define MAX_TIMINGS 256 - void WarpPalette(void) { @@ -233,10 +190,10 @@ R_SetupFrame(void) r_viewchanged = false; } -// start off with just the four screen edge clip planes + // start off with just the four screen edge clip planes R_TransformFrustum(); -// save base values + // save base values VectorCopy(vpn, base_vpn); VectorCopy(vright, base_vright); VectorCopy(vup, base_vup); From c7d6d6d985a9e0278a6def60ccae747b2a018fb8 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 20:53:47 +0200 Subject: [PATCH 36/48] Remove unused code - DebugLog --- common/cd_null.c | 34 ---------------------------------- common/libretro.c | 4 ---- common/sys.h | 8 -------- 3 files changed, 46 deletions(-) delete mode 100644 common/cd_null.c diff --git a/common/cd_null.c b/common/cd_null.c deleted file mode 100644 index 3f6c75a6..00000000 --- a/common/cd_null.c +++ /dev/null @@ -1,34 +0,0 @@ -/* -Copyright (C) 1996-1997 Id Software, Inc. - -This program is free software; you can redistribute it and/or -modify it under the terms of the GNU General Public License -as published by the Free Software Foundation; either version 2 -of the License, or (at your option) any later version. - -This program 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -*/ - -#include "cdaudio_driver.h" - -int CDDrv_IsAudioTrack(byte track) { return 0; } -int CDDrv_PlayTrack(byte track) { return 1; } -int CDDrv_IsPlaying(byte track) { return 0; } -int CDDrv_InitDevice(void) { return -1; } -void CDDrv_CloseDevice(void) { } -void CDDrv_Eject(void) { } -void CDDrv_CloseDoor(void) { } -void CDDrv_Stop(void) { } -void CDDrv_Pause(void) { } -void CDDrv_Resume(byte track) { } -int CDDrv_GetMaxTrack(byte *track) { return 0; } -int CDDrv_SetVolume(byte volume) { return -1; } diff --git a/common/libretro.c b/common/libretro.c index 82b84897..1fc5f682 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -369,10 +369,6 @@ void Sys_mkdir(const char *path) path_mkdir(path); } -void Sys_DebugLog(const char *file, const char *fmt, ...) -{ -} - double Sys_DoubleTime(void) { static int first = true; diff --git a/common/sys.h b/common/sys.h index 7251bd70..b7466785 100644 --- a/common/sys.h +++ b/common/sys.h @@ -32,19 +32,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. int Sys_FileTime(const char *path); void Sys_mkdir(const char *path); -// -// memory protection -// -void Sys_MakeCodeWriteable(unsigned long startaddr, unsigned long length); - -// // system IO -// #define MAX_PRINTMSG 4096 void Sys_Printf(const char *fmt, ...); -void Sys_DebugLog(const char *file, const char *fmt, ...); bool Sys_Error(const char *error, ...); // send text to the console From e168696ee554a85a7e65b09d53210f0281c39918 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 21:00:59 +0200 Subject: [PATCH 37/48] Remove unused variables --- common/client.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/common/client.h b/common/client.h index 7849f5ea..0548addb 100644 --- a/common/client.h +++ b/common/client.h @@ -111,12 +111,8 @@ typedef struct { // demo recording info must be here, because record is started before // entering a map (and clearing client_state_t) qboolean demoplayback; - qboolean timedemo; int forcetrack; // -1 = use normal cd track RFILE *demofile; - int td_lastframe; // to meter out one message a frame - int td_startframe; // host_framecount at start - float td_starttime; // realtime at second frame of timedemo // connection information int signon; // 0 to SIGNONS From 8a3b5544efcbd294f5707c100129f44930202907 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 21:01:35 +0200 Subject: [PATCH 38/48] Remove pcx_t --- common/client.h | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/common/client.h b/common/client.h index 0548addb..a8ea903c 100644 --- a/common/client.h +++ b/common/client.h @@ -358,20 +358,4 @@ void CL_InitTEnts(void); void CL_ClearTEnts(void); void CL_SignonReply(void); -typedef struct { - char manufacturer; - char version; - char encoding; - char bits_per_pixel; - unsigned short xmin, ymin, xmax, ymax; - unsigned short hres, vres; - unsigned char palette[48]; - char reserved; - char color_planes; - unsigned short bytes_per_line; - unsigned short palette_type; - char filler[58]; - unsigned char data; // unbounded -} pcx_t; - #endif /* CLIENT_H */ From 8d94cd3aea711b49a34be7ea8512f2db37d4d830 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 21:19:58 +0200 Subject: [PATCH 39/48] =?UTF-8?q?Remove=20unused=20FPS=5F20=20code=20and?= =?UTF-8?q?=20other=20miscellaneous=20unused=20things=C2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/cl_parse.c | 3 +-- common/host.c | 52 ----------------------------------------------- common/host_cmd.c | 4 ---- 3 files changed, 1 insertion(+), 58 deletions(-) diff --git a/common/cl_parse.c b/common/cl_parse.c index 66e73478..684a7ac3 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -140,8 +140,7 @@ When the client is taking a long time to load stuff, send keepalive messages so the server doesn't disconnect. ================== */ -void -CL_KeepaliveMessage(void) +static void CL_KeepaliveMessage(void) { float time; static float lastmsg; diff --git a/common/host.c b/common/host.c index 76c3749c..a4c355ec 100644 --- a/common/host.c +++ b/common/host.c @@ -478,55 +478,6 @@ Host_ServerFrame ================== */ -#ifdef FPS_20 - -void -_Host_ServerFrame(void) -{ -// run the world state - pr_global_struct->frametime = host_frametime; - -// read client messages - SV_RunClients(); - -// move things around and think -// always pause in single player if in console or menus - if (!sv.paused && (svs.maxclients > 1 || key_dest == key_game)) - SV_Physics(); -} - -void -Host_ServerFrame(void) -{ - float save_host_frametime; - float temp_host_frametime; - -// run the world state - pr_global_struct->frametime = host_frametime; - -// set the time and clear the general datagram - SV_ClearDatagram(); - -// check for new clients - SV_CheckForNewClients(); - - temp_host_frametime = save_host_frametime = host_frametime; - while (temp_host_frametime > (1.0 / 72.0)) { - if (temp_host_frametime > 0.05) - host_frametime = 0.05; - else - host_frametime = temp_host_frametime; - temp_host_frametime -= host_frametime; - _Host_ServerFrame(); - } - host_frametime = save_host_frametime; - -// send all messages to the clients - SV_SendClientMessages(); -} - -#else - void Host_ServerFrame(void) { @@ -553,9 +504,6 @@ Host_ServerFrame(void) SV_SendClientMessages(); } -#endif - - /* ================== Host_Frame diff --git a/common/host_cmd.c b/common/host_cmd.c index c0519c3e..c1e4c16d 100644 --- a/common/host_cmd.c +++ b/common/host_cmd.c @@ -1036,10 +1036,6 @@ Host_Spawn_f(void) pr_global_struct->self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram(pr_global_struct->ClientConnect); - if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= - sv.time) - Sys_Printf("%s entered the game\n", host_client->name); - PR_ExecuteProgram(pr_global_struct->PutClientInServer); } From cfe5014c494333fc5536e1cc030df5fe621fea7d Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 21:55:45 +0200 Subject: [PATCH 40/48] Cleanups for pr_edict.c/cl_input.c --- common/cl_input.c | 9 ++--- common/pr_edict.c | 86 +++++++++++++++++++++-------------------------- 2 files changed, 41 insertions(+), 54 deletions(-) diff --git a/common/cl_input.c b/common/cl_input.c index f6201339..fa26154a 100644 --- a/common/cl_input.c +++ b/common/cl_input.c @@ -62,8 +62,7 @@ kbutton_t in_up, in_down; int in_impulse; int walkstate=1; -void -KeyDown(kbutton_t *b) +static void KeyDown(kbutton_t *b) { int k; const char *c = Cmd_Argv(1); @@ -89,8 +88,7 @@ KeyDown(kbutton_t *b) b->state |= 1 + 2; // down + impulse down } -void -KeyUp(kbutton_t *b) +static void KeyUp(kbutton_t *b) { int k; const char *c = Cmd_Argv(1); @@ -318,8 +316,7 @@ Returns 0.25 if a key was pressed and released during the frame, 1.0 if held for the entire time =============== */ -float -CL_KeyState(kbutton_t *key) +static float CL_KeyState(kbutton_t *key) { qboolean impulsedown = key->state & 2; qboolean impulseup = key->state & 4; diff --git a/common/pr_edict.c b/common/pr_edict.c index b82f55e4..220e6b00 100644 --- a/common/pr_edict.c +++ b/common/pr_edict.c @@ -19,6 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // sv_edict.c -- entity dictionary +#include + #include "cmd.h" #include "console.h" #include "crc.h" @@ -322,7 +324,7 @@ PR_UglyValueString(etype_t type, eval_t *val) switch (type) { case ev_string: - snprintf(line, sizeof(line), "%s", PR_GetString(val->string)); + strlcpy(line, PR_GetString(val->string), sizeof(line)); break; case ev_entity: snprintf(line, sizeof(line), "%i", @@ -330,14 +332,14 @@ PR_UglyValueString(etype_t type, eval_t *val) break; case ev_function: f = pr_functions + val->function; - snprintf(line, sizeof(line), "%s", PR_GetString(f->s_name)); + strlcpy(line, PR_GetString(f->s_name), sizeof(line)); break; case ev_field: def = ED_FieldAtOfs(val->_int); - snprintf(line, sizeof(line), "%s", PR_GetString(def->s_name)); + strlcpy(line, PR_GetString(def->s_name), sizeof(line)); break; case ev_void: - snprintf(line, sizeof(line), "void"); + strlcpy(line, "void", sizeof(line)); break; case ev_float: snprintf(line, sizeof(line), "%f", val->_float); @@ -363,11 +365,7 @@ For savegames */ void ED_Write(RFILE *f, edict_t *ed) { - ddef_t *d; - int *v; - int i, j; - const char *name; - int type; + int i; rfprintf(f, "{\n"); @@ -377,9 +375,11 @@ void ED_Write(RFILE *f, edict_t *ed) return; } - for (i = 1; i < progs->numfielddefs; i++) { - d = &pr_fielddefs[i]; - name = PR_GetString(d->s_name); + for (i = 1; i < progs->numfielddefs; i++) + { + int j, type, *v; + ddef_t *d = &pr_fielddefs[i]; + const char *name = PR_GetString(d->s_name); if (name[strlen(name) - 2] == '_') continue; // skip _x, _y, _z vars @@ -417,15 +417,14 @@ ED_WriteGlobals void ED_WriteGlobals(RFILE *f) { - ddef_t *def; int i; - const char *name; - int type; rfprintf(f, "{\n"); - for (i = 0; i < progs->numglobaldefs; i++) { - def = &pr_globaldefs[i]; - type = def->type; + for (i = 0; i < progs->numglobaldefs; i++) + { + const char *name; + ddef_t *def = &pr_globaldefs[i]; + int type = def->type; if (!(def->type & DEF_SAVEGLOBAL)) continue; type &= ~DEF_SAVEGLOBAL; @@ -497,12 +496,10 @@ ED_NewString static char * ED_NewString(const char *string) { - char *newobj, *new_p; - int i, l; - - l = strlen(string) + 1; - newobj = (char*)Hunk_Alloc(l); - new_p = newobj; + int i; + int l = strlen(string) + 1; + char *newobj = (char*)Hunk_Alloc(l); + char *new_p = newobj; for (i = 0; i < l; i++) { if (string[i] == '\\' && i < l - 1) { @@ -534,10 +531,8 @@ ED_ParseEpair(void *base, ddef_t *key, const char *s) char string[128]; ddef_t *def; char *v, *w; - void *d; dfunction_t *func; - - d = (void *)((int *)base + key->ofs); + void *d = (void *)((int *)base + key->ofs); switch (key->type & ~DEF_SAVEGLOBAL) { case ev_string: @@ -601,19 +596,17 @@ Used for initial level load and for savegames. const char * ED_ParseEdict(const char *data, edict_t *ent) { + int n; ddef_t *key; qboolean anglehack; - qboolean init; char keyname[256]; - int n; + qboolean init = false; - init = false; - -// clear it + // clear it if (ent != sv.edicts) // hack memset(&ent->v, 0, progs->entityfields * 4); -// go through all the dictionary pairs + // go through all the dictionary pairs while (1) { // parse key data = COM_Parse(data); @@ -622,15 +615,15 @@ ED_ParseEdict(const char *data, edict_t *ent) if (!data) SV_Error("%s: EOF without closing brace", __func__); -// anglehack is to allow QuakeEd to write single scalar angles -// and allow them to be turned into vectors. (FIXME...) + // anglehack is to allow QuakeEd to write single scalar angles + // and allow them to be turned into vectors. (FIXME...) if (!strcmp(com_token, "angle")) { strcpy(com_token, "angles"); anglehack = true; } else anglehack = false; -// FIXME: change light to _light to get rid of this hack + // FIXME: change light to _light to get rid of this hack if (!strcmp(com_token, "light")) strcpy(com_token, "light_lev"); // hack for single light def @@ -653,8 +646,8 @@ ED_ParseEdict(const char *data, edict_t *ent) init = true; -// keynames with a leading underscore are used for utility comments, -// and are immediately discarded by quake + // keynames with a leading underscore are used for utility comments, + // and are immediately discarded by quake if (keyname[0] == '_') continue; @@ -705,17 +698,16 @@ to call ED_CallSpawnFunctions () to let the objects initialize themselves. void ED_LoadFromFile(const char *data) { - edict_t *ent; - int inhibit; dfunction_t *func; + edict_t *ent = NULL; + int inhibit = 0; - ent = NULL; - inhibit = 0; pr_global_struct->time = sv.time; -// parse ents - while (1) { -// parse the opening brace + // parse ents + while (1) + { + // parse the opening brace data = COM_Parse(data); if (!data) break; @@ -947,9 +939,7 @@ EDICT_NUM(int n) int NUM_FOR_EDICT(const edict_t *e) { - int b = (byte *)e - (byte *)sv.edicts; - b = b / pr_edict_size; - + int b = ((byte *)e - (byte *)sv.edicts) / pr_edict_size; if (b < 0 || b >= sv.num_edicts) SV_Error("%s: bad pointer", __func__); return b; From a8ea1e1c1e499e2addcc86797cc7f6635d875609 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 22:03:11 +0200 Subject: [PATCH 41/48] Remove unused Sys_Printf --- QW/common/net_udp.c | 10 +------ QW/server/server.h | 2 -- QW/server/sv_ccmds.c | 67 -------------------------------------------- QW/server/sv_main.c | 36 ++---------------------- QW/server/sv_send.c | 6 ---- QW/server/sv_user.c | 9 ------ QW/server/sys_unix.c | 17 ----------- common/common.c | 1 - common/console.c | 3 -- common/host.c | 3 -- common/host_cmd.c | 2 -- common/libretro.c | 4 --- common/sv_user.c | 10 +------ common/sys.h | 1 - 14 files changed, 5 insertions(+), 166 deletions(-) diff --git a/QW/common/net_udp.c b/QW/common/net_udp.c index 87422e58..7eb51678 100644 --- a/QW/common/net_udp.c +++ b/QW/common/net_udp.c @@ -157,7 +157,6 @@ NET_GetPacket(void) return false; if (errno == ECONNREFUSED) return false; - Sys_Printf("%s: %s\n", __func__, strerror(errno)); return false; } @@ -176,15 +175,8 @@ NET_SendPacket(int length, void *data, netadr_t to) NetadrToSockadr(&to, &addr); - ret = sendto(net_socket, data, length, 0, (struct sockaddr *)&addr, + sendto(net_socket, data, length, 0, (struct sockaddr *)&addr, sizeof(addr)); - if (ret == -1) { - if (errno == EWOULDBLOCK) - return; - if (errno == ECONNREFUSED) - return; - Sys_Printf("%s: %s\n", __func__, strerror(errno)); - } } diff --git a/QW/server/server.h b/QW/server/server.h index fe10f8a0..fc681b33 100644 --- a/QW/server/server.h +++ b/QW/server/server.h @@ -365,8 +365,6 @@ extern char localmodels[MAX_MODELS][5]; // inline model names for precache extern char localinfo[MAX_LOCALINFO_STRING + 1]; extern int host_hunklevel; -extern FILE *sv_logfile; -extern FILE *sv_fraglogfile; extern int sv_nailmodel; extern int sv_supernailmodel; diff --git a/QW/server/sv_ccmds.c b/QW/server/sv_ccmds.c index b4e06962..466f60f5 100644 --- a/QW/server/sv_ccmds.c +++ b/QW/server/sv_ccmds.c @@ -97,70 +97,6 @@ SV_Quit_f(void) Sys_Quit(); } -/* -============ -SV_Logfile_f -============ -*/ -void -SV_Logfile_f(void) -{ - char name[MAX_OSPATH]; - - if (sv_logfile) { - Con_Printf("File logging off.\n"); - rfclose(sv_logfile); - sv_logfile = NULL; - return; - } - - sprintf(name, "%s/qconsole.log", com_gamedir); - Con_Printf("Logging text to %s.\n", name); - sv_logfile = rfopen(name, "w"); - if (!sv_logfile) - Con_Printf("failed.\n"); -} - - -/* -============ -SV_Fraglogfile_f -============ -*/ -void -SV_Fraglogfile_f(void) -{ - char name[MAX_OSPATH]; - int i; - - if (sv_fraglogfile) { - Con_Printf("Frag file logging off.\n"); - fclose(sv_fraglogfile); - sv_fraglogfile = NULL; - return; - } - // find an unused name - for (i = 0; i < 1000; i++) { - sprintf(name, "%s/frag_%i.log", com_gamedir, i); - sv_fraglogfile = rfopen(name, "r"); - if (!sv_fraglogfile) { // can't read it, so create this one - sv_fraglogfile = rfopen(name, "w"); - if (!sv_fraglogfile) - i = 1000; // give error - break; - } - fclose(sv_fraglogfile); - } - if (i == 1000) { - Con_Printf("Can't open any logfiles.\n"); - sv_fraglogfile = NULL; - return; - } - - Con_Printf("Logging frags to %s.\n", name); -} - - /* ================== SV_SetPlayer @@ -850,9 +786,6 @@ SV_InitOperatorCommands(void) MAX_SERVERINFO_STRING); } - Cmd_AddCommand("logfile", SV_Logfile_f); - Cmd_AddCommand("fraglogfile", SV_Fraglogfile_f); - Cmd_AddCommand("snap", SV_Snap_f); Cmd_AddCommand("snapall", SV_SnapAll_f); Cmd_AddCommand("kick", SV_Kick_f); diff --git a/QW/server/sv_main.c b/QW/server/sv_main.c index 1b265537..acb8e2c0 100644 --- a/QW/server/sv_main.c +++ b/QW/server/sv_main.c @@ -84,9 +84,6 @@ cvar_t watervis = { "watervis", "0", false, true }; cvar_t hostname = { "hostname", "unnamed", false, true }; -RFILE *sv_logfile; -RFILE *sv_fraglogfile; - static void Master_Heartbeat(void); static void Master_Shutdown(void); @@ -109,14 +106,6 @@ void SV_Shutdown(void) { Master_Shutdown(); - if (sv_logfile) { - rfclose(sv_logfile); - sv_logfile = NULL; - } - if (sv_fraglogfile) { - rfclose(sv_fraglogfile); - sv_logfile = NULL; - } NET_Shutdown(); } @@ -281,12 +270,8 @@ Writes all update values to a sizebuf void SV_FullClientUpdate(client_t *client, sizebuf_t *buf) { - int i; char info[MAX_INFO_STRING]; - - i = client - svs.clients; - -//Sys_Printf("SV_FullClientUpdate: Updated frags for client %d\n", i); + int i = client - svs.clients; MSG_WriteByte(buf, svc_updatefrags); MSG_WriteByte(buf, i); @@ -423,25 +408,10 @@ instead of the data. static void SVC_Log(void) { - int seq; char data[MAX_DATAGRAM + 64]; - - if (Cmd_Argc() == 2) - seq = atoi(Cmd_Argv(1)); - else - seq = -1; - /* they already have this data, or we aren't logging frags */ - if (seq == svs.logsequence - 1 || !sv_fraglogfile) { - data[0] = A2A_NACK; - NET_SendPacket(1, data, net_from); - return; - } - - sprintf(data, "stdlog %i\n", svs.logsequence - 1); - strcat(data, (char *)svs.log_buf[((svs.logsequence - 1) & 1)]); - - NET_SendPacket(strlen(data) + 1, data, net_from); + data[0] = A2A_NACK; + NET_SendPacket(1, data, net_from); } /* diff --git a/QW/server/sv_send.c b/QW/server/sv_send.c index 702c2205..a4fce7e1 100644 --- a/QW/server/sv_send.c +++ b/QW/server/sv_send.c @@ -119,10 +119,6 @@ Con_Printf(const char *fmt, ...) strcat(outputbuf, msg); return; } - - Sys_Printf("%s", msg); // also echo to debugging console - if (sv_logfile) - fprintf(sv_logfile, "%s", msg); } /* @@ -184,8 +180,6 @@ SV_BroadcastPrintf(int level, const char *fmt, ...) vsnprintf(string, sizeof(string), fmt, argptr); va_end(argptr); - Sys_Printf("%s", string); // print to the console - for (i = 0, cl = svs.clients; i < MAX_CLIENTS; i++, cl++) { if (level < cl->messagelevel) continue; diff --git a/QW/server/sv_user.c b/QW/server/sv_user.c index fdfcbbfd..38d54152 100644 --- a/QW/server/sv_user.c +++ b/QW/server/sv_user.c @@ -571,14 +571,11 @@ SV_NextUpload(void) if (!host_client->upload) { host_client->upload = fopen(host_client->uploadfn, "wb"); if (!host_client->upload) { - Sys_Printf("Can't create %s\n", host_client->uploadfn); ClientReliableWrite_Begin(host_client, svc_stufftext, 8); ClientReliableWrite_String(host_client, "stopul"); *host_client->uploadfn = 0; return; } - Sys_Printf("Receiving %s from %d...\n", host_client->uploadfn, - host_client->userid); if (host_client->remote_snap) OutofBandPrintf(host_client->snap_from, "Server receiving %s from %d...\n", @@ -595,8 +592,6 @@ SV_NextUpload(void) fclose(host_client->upload); host_client->upload = NULL; - Sys_Printf("%s upload completed.\n", host_client->uploadfn); - if (host_client->remote_snap) { char *p; @@ -666,7 +661,6 @@ SV_BeginDownload_f(void) host_client->download = NULL; } - Sys_Printf("Couldn't upload %s to %s\n", name, host_client->name); ClientReliableWrite_Begin(host_client, svc_download, 4); ClientReliableWrite_Short(host_client, -1); ClientReliableWrite_Byte(host_client, 0); @@ -674,7 +668,6 @@ SV_BeginDownload_f(void) } SV_NextDownload_f(); - Sys_Printf("Uploading %s to %s\n", name, host_client->name); } //============================================================================= @@ -751,8 +744,6 @@ SV_Say(qboolean team) } strcat(text, "\n"); - Sys_Printf("%s", text); - for (i = 0, client = svs.clients; i < MAX_CLIENTS; i++, client++) { if (client->state != cs_spawned) continue; diff --git a/QW/server/sys_unix.c b/QW/server/sys_unix.c index eb3a25b0..10fc4eec 100644 --- a/QW/server/sys_unix.c +++ b/QW/server/sys_unix.c @@ -120,23 +120,6 @@ Sys_Error(const char *error, ...) exit(1); } -/* -================ -Sys_Printf -================ -*/ -void -Sys_Printf(const char *fmt, ...) -{ - va_list argptr; - static char text[MAX_PRINTMSG]; - - va_start(argptr, fmt); - vsnprintf(text, sizeof(text), fmt, argptr); - va_end(argptr); -} - - /* ================ Sys_Quit diff --git a/common/common.c b/common/common.c index 7f99c769..3bfc15a3 100644 --- a/common/common.c +++ b/common/common.c @@ -1342,7 +1342,6 @@ qboolean COM_FileExists (const char *filename) } } - Sys_Printf("FindFile: can't find %s\n", filename); com_filesize = -1; return false; diff --git a/common/console.c b/common/console.c index 7aeae8bc..6af0bd3f 100644 --- a/common/console.c +++ b/common/console.c @@ -315,9 +315,6 @@ void Con_Printf(const char *fmt, ...) vsnprintf(msg, sizeof(msg), fmt, argptr); va_end(argptr); - /* also echo to debugging console */ - Sys_Printf("%s", msg); // also echo to debugging console - if (!con_initialized) return; diff --git a/common/host.c b/common/host.c index a4c355ec..0c84180f 100644 --- a/common/host.c +++ b/common/host.c @@ -328,8 +328,6 @@ SV_DropClient(qboolean crash) PR_ExecuteProgram(pr_global_struct->ClientDisconnect); pr_global_struct->self = saveSelf; } - - Sys_Printf("Client %s removed\n", host_client->name); } // break the net connection NET_Close(host_client->netconnection); @@ -680,7 +678,6 @@ Host_Init(quakeparms_t *parms) host_hunklevel = Hunk_LowMark(); host_initialized = true; - Sys_Printf("========Quake Initialized=========\n"); /* In case exec of quake.rc fails */ if (!setjmp(host_abort)) { diff --git a/common/host_cmd.c b/common/host_cmd.c index c1e4c16d..f79d03a1 100644 --- a/common/host_cmd.c +++ b/common/host_cmd.c @@ -793,8 +793,6 @@ Host_Say(qboolean teamonly) SV_ClientPrintf("%s", text); } host_client = save; - - Sys_Printf("%s", &text[1]); } diff --git a/common/libretro.c b/common/libretro.c index 1fc5f682..275fa5b0 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -314,10 +314,6 @@ retro_environment_t environ_cb; static retro_input_poll_t poll_cb; static retro_input_state_t input_cb; -void Sys_Printf(const char *fmt, ...) -{ -} - void Sys_Quit(void) { Host_Shutdown(); diff --git a/common/sv_user.c b/common/sv_user.c index 5539c56e..6dac53ef 100644 --- a/common/sv_user.c +++ b/common/sv_user.c @@ -556,10 +556,7 @@ qboolean SV_ReadClientMessage(void) nextmsg: ret = NET_GetMessage(host_client->netconnection); if (ret == -1) - { - Sys_Printf("%s: NET_GetMessage failed\n", __func__); return false; - } if (!ret) return true; @@ -570,10 +567,8 @@ qboolean SV_ReadClientMessage(void) if (!host_client->active) return false; // a command caused an error - if (msg_badread) { - Sys_Printf("%s: badread\n", __func__); + if (msg_badread) return false; - } cmd = MSG_ReadChar(); @@ -582,11 +577,9 @@ qboolean SV_ReadClientMessage(void) goto nextmsg; // end of message default: - Sys_Printf("%s: unknown command char\n", __func__); return false; case clc_nop: - //Sys_Printf ("clc_nop\n"); break; case clc_stringcmd: @@ -652,7 +645,6 @@ qboolean SV_ReadClientMessage(void) break; case clc_disconnect: - //Sys_Printf ("%s: client disconnected\n", __func__); return false; case clc_move: diff --git a/common/sys.h b/common/sys.h index b7466785..44d5feec 100644 --- a/common/sys.h +++ b/common/sys.h @@ -36,7 +36,6 @@ void Sys_mkdir(const char *path); #define MAX_PRINTMSG 4096 -void Sys_Printf(const char *fmt, ...); bool Sys_Error(const char *error, ...); // send text to the console From a273599a89e76c8b851025f6fffb5f4cacc0b1b4 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sat, 11 Jun 2022 22:44:40 +0200 Subject: [PATCH 42/48] Get rid of unused BOPS_Error --- common/mathlib.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-) diff --git a/common/mathlib.c b/common/mathlib.c index c1b2ba14..be4689c3 100644 --- a/common/mathlib.c +++ b/common/mathlib.c @@ -170,18 +170,6 @@ SignbitsForPlane(const mplane_t *plane) return bits; } -/* -================== -BOPS_Error - -Split out like this for ASM to call. -================== -*/ -void BOPS_Error(void) -{ - Sys_Error("%s: Bad signbits", __func__); -} - /* ================== BoxOnPlaneSide @@ -263,7 +251,6 @@ BoxOnPlaneSide(const vec3_t mins, const vec3_t maxs, const mplane_t *p) p->normal[2] * maxs[2]; break; default: - BOPS_Error(); break; } @@ -386,14 +373,10 @@ double sqrt(double x); vec_t Length(vec3_t v) { int i; - float length; - - length = 0; + float length = 0.0f; for (i = 0; i < 3; i++) length += v[i] * v[i]; - length = sqrt(length); // FIXME - - return length; + return sqrtf(length); } float VectorNormalize(vec3_t v) @@ -558,12 +541,9 @@ GreatestCommonDivisor(int i1, int i2) return (i1); return GreatestCommonDivisor(i2, i1 % i2); } - else - { - if (i1 == 0) - return (i2); - return GreatestCommonDivisor(i1, i2 % i1); - } + if (i1 == 0) + return (i2); + return GreatestCommonDivisor(i1, i2 % i1); } From e04da403f7bd7e8643e29a6c1bbd500a96932258 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 12 Jun 2022 15:57:16 +0200 Subject: [PATCH 43/48] * Use fill_pathname_join where possible instead of snprintf * Use strlcpy where possible instead of snprintf * Get rid of 'bad CDRIP'warning whenever an audio track cannot be found --- common/bgmusic.c | 69 ++++++++++++-------------- common/cl_parse.c | 13 ++--- common/common.c | 35 ++++--------- common/host_cmd.c | 54 -------------------- common/libretro.c | 18 +++---- common/net_dgrm.c | 124 ++-------------------------------------------- common/pr_cmds.c | 3 +- 7 files changed, 63 insertions(+), 253 deletions(-) diff --git a/common/bgmusic.c b/common/bgmusic.c index e2fdb96a..bcc74794 100644 --- a/common/bgmusic.c +++ b/common/bgmusic.c @@ -32,13 +32,12 @@ #include "snd_codec.h" #include "bgmusic.h" -#define MUSIC_DIRNAME "music" +#include +#include qboolean bgmloop; cvar_t bgm_extmusic = {"bgm_extmusic", "1", false}; -static qboolean no_extmusic= false; -static float old_volume = -1.0f; typedef enum _bgm_player { @@ -60,16 +59,16 @@ typedef struct music_handler_s static music_handler_t wanted_handlers[] = { - { CODECTYPE_VORBIS,BGM_STREAMER,-1, "ogg", MUSIC_DIRNAME, NULL }, - { CODECTYPE_OPUS, BGM_STREAMER, -1, "opus", MUSIC_DIRNAME, NULL }, - { CODECTYPE_MP3, BGM_STREAMER, -1, "mp3", MUSIC_DIRNAME, NULL }, - { CODECTYPE_FLAC, BGM_STREAMER, -1, "flac", MUSIC_DIRNAME, NULL }, - { CODECTYPE_WAV, BGM_STREAMER, -1, "wav", MUSIC_DIRNAME, NULL }, - { CODECTYPE_MOD, BGM_STREAMER, -1, "it", MUSIC_DIRNAME, NULL }, - { CODECTYPE_MOD, BGM_STREAMER, -1, "s3m", MUSIC_DIRNAME, NULL }, - { CODECTYPE_MOD, BGM_STREAMER, -1, "xm", MUSIC_DIRNAME, NULL }, - { CODECTYPE_MOD, BGM_STREAMER, -1, "mod", MUSIC_DIRNAME, NULL }, - { CODECTYPE_UMX, BGM_STREAMER, -1, "umx", MUSIC_DIRNAME, NULL }, + { CODECTYPE_VORBIS,BGM_STREAMER,-1, "ogg", "music", NULL }, + { CODECTYPE_OPUS, BGM_STREAMER, -1, "opus", "music", NULL }, + { CODECTYPE_MP3, BGM_STREAMER, -1, "mp3", "music", NULL }, + { CODECTYPE_FLAC, BGM_STREAMER, -1, "flac", "music", NULL }, + { CODECTYPE_WAV, BGM_STREAMER, -1, "wav", "music", NULL }, + { CODECTYPE_MOD, BGM_STREAMER, -1, "it", "music", NULL }, + { CODECTYPE_MOD, BGM_STREAMER, -1, "s3m", "music", NULL }, + { CODECTYPE_MOD, BGM_STREAMER, -1, "xm", "music", NULL }, + { CODECTYPE_MOD, BGM_STREAMER, -1, "mod", "music", NULL }, + { CODECTYPE_UMX, BGM_STREAMER, -1, "umx", "music", NULL }, { CODECTYPE_NONE, BGM_NONE, -1, NULL, NULL, NULL } }; @@ -141,9 +140,6 @@ qboolean BGM_Init (void) Cmd_AddCommand("music_loop", BGM_Loop_f); Cmd_AddCommand("music_stop", BGM_Stop_f); - if (COM_CheckParm("-noextmusic") != 0) - no_extmusic = true; - bgmloop = true; for (i = 0; wanted_handlers[i].type != CODECTYPE_NONE; i++) @@ -261,7 +257,7 @@ void BGM_Play (const char *filename) Con_Printf("Unhandled extension for %s\n", filename); return; } - snprintf(tmp, sizeof(tmp), "%s/%s", handler->dir, filename); + fill_pathname_join(tmp, handler->dir, filename, sizeof(tmp)); switch (handler->player) { case BGM_MIDIDRV: @@ -300,11 +296,11 @@ void BGM_PlayCDtrack (byte track, qboolean looping) return; /* success */ if (music_handlers == NULL) return; - if (no_extmusic || !bgm_extmusic.value) + if (!bgm_extmusic.value) return; - type = 0; - ext = NULL; + type = 0; + ext = NULL; handler = music_handlers; while (handler) { @@ -312,21 +308,19 @@ void BGM_PlayCDtrack (byte track, qboolean looping) goto _next; if (! CDRIPTYPE(handler->type)) goto _next; - snprintf(tmp, sizeof(tmp), "%s/track%02d.%s", - MUSIC_DIRNAME, (int)track, handler->ext); + snprintf(tmp, sizeof(tmp), "music/track%02d.%s", + (int)track, handler->ext); if (! COM_FileExists(tmp)) goto _next; - type = handler->type; - ext = handler->ext; - _next: + type = handler->type; + ext = handler->ext; +_next: handler = handler->next; } - if (ext == NULL) - Con_Printf("Couldn't find a cdrip for track %d\n", (int)track); - else + if (ext) { - snprintf(tmp, sizeof(tmp), "%s/track%02d.%s", - MUSIC_DIRNAME, (int)track, ext); + snprintf(tmp, sizeof(tmp), "music/track%02d.%s", + (int)track, ext); bgmstream = S_CodecOpenStreamType(tmp, type); if (! bgmstream) Con_Printf("Couldn't handle music file %s\n", tmp); @@ -394,9 +388,9 @@ static void BGM_UpdateStream (void) fileBytes = fileSamples * (bgmstream->info.width * bgmstream->info.channels); if (fileBytes > (int) sizeof(raw)) { - fileBytes = (int) sizeof(raw); + fileBytes = (int) sizeof(raw); fileSamples = fileBytes / - (bgmstream->info.width * bgmstream->info.channels); + (bgmstream->info.width * bgmstream->info.channels); } /* Read */ @@ -409,10 +403,11 @@ static void BGM_UpdateStream (void) if (res > 0) /* data: add to raw buffer */ { - S_RawSamples(fileSamples, bgmstream->info.rate, - bgmstream->info.width, - bgmstream->info.channels, - raw, bgmvolume.value); + S_RawSamples(fileSamples, + bgmstream->info.rate, + bgmstream->info.width, + bgmstream->info.channels, + raw, bgmvolume.value); } else if (res == 0) /* EOF */ { @@ -443,6 +438,8 @@ static void BGM_UpdateStream (void) void BGM_Update (void) { + static float old_volume = -1.0f; + if (old_volume != bgmvolume.value) { if (bgmvolume.value < 0) diff --git a/common/cl_parse.c b/common/cl_parse.c index 684a7ac3..780e2ff6 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -35,6 +35,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "bgmusic.h" #include "sys.h" +#include + //============================================================================= /* @@ -200,7 +202,7 @@ CL_ParseServerInfo(void) { char *level; const char *mapname; - int i, maxlen; + int i; int nummodels, numsounds; char **model_precache = malloc(sizeof(char*) * MAX_MODELS); char **sound_precache = malloc(sizeof(char*) * MAX_SOUNDS); @@ -235,8 +237,7 @@ CL_ParseServerInfo(void) /* parse signon message */ level = cl.levelname; - maxlen = sizeof(cl.levelname); - snprintf(level, maxlen, "%s", MSG_ReadString()); + strlcpy(level, MSG_ReadString(), sizeof(cl.levelname)); /* seperate the printfs so the server message can have a color */ Con_Printf("\n\n\35\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36\36" @@ -285,7 +286,7 @@ CL_ParseServerInfo(void) /* copy the naked name of the map file to the cl structure */ mapname = COM_SkipPath(model_precache[1]); - snprintf(cl.mapname, sizeof(cl.mapname), "%s", mapname); + strlcpy(cl.mapname, mapname, sizeof(cl.mapname)); COM_StripExtension(cl.mapname); /* now we try to load everything else until a cache allocation fails */ @@ -953,7 +954,7 @@ CL_ParseServerMessage(void) if (i >= MAX_LIGHTSTYLES) Sys_Error("svc_lightstyle > MAX_LIGHTSTYLES"); s = MSG_ReadString(); - snprintf(cl_lightstyle[i].map, MAX_STYLESTRING, "%s", s); + strlcpy(cl_lightstyle[i].map, s, MAX_STYLESTRING); cl_lightstyle[i].length = strlen(cl_lightstyle[i].map); break; @@ -972,7 +973,7 @@ CL_ParseServerMessage(void) if (i >= cl.maxclients) Host_Error("%s: svc_updatename > MAX_SCOREBOARD", __func__); s = MSG_ReadString(); - snprintf(cl.players[i].name, MAX_SCOREBOARDNAME, "%s", s); + strlcpy(cl.players[i].name, s, MAX_SCOREBOARDNAME); break; case svc_updatefrags: diff --git a/common/common.c b/common/common.c index 3bfc15a3..acb0da17 100644 --- a/common/common.c +++ b/common/common.c @@ -28,6 +28,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include +#include +#include + #ifdef NQ_HACK #include "quakedef.h" #include "host.h" @@ -72,10 +75,6 @@ int rfgetc(RFILE* stream); static const char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1]; static const char *argvdummy = " "; -static const char *safeargvs[NUM_SAFE_ARGVS] = { - "-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse", "-dibonly" -}; - cvar_t registered = { "registered", "0" }; #ifdef NQ_HACK static cvar_t cmdline = { "cmdline", "0", false, true }; @@ -1008,7 +1007,6 @@ COM_InitArgv */ void COM_InitArgv(int argc, const char **argv) { - qboolean safe; int i; #ifdef NQ_HACK int j, n = 0; @@ -1027,22 +1025,9 @@ void COM_InitArgv(int argc, const char **argv) com_cmdline[n] = 0; #endif - safe = false; - for (com_argc = 0; (com_argc < MAX_NUM_ARGVS) && (com_argc < argc); com_argc++) { largv[com_argc] = argv[com_argc]; - if (!strcmp("-safe", argv[com_argc])) - safe = true; - } - - if (safe) { - // force all the safe-mode switches. Note that we reserved extra space in - // case we need to add these, so we don't need an overflow check - for (i = 0; i < NUM_SAFE_ARGVS; i++) { - largv[com_argc] = safeargvs[i]; - com_argc++; - } } largv[com_argc] = argvdummy; @@ -1244,7 +1229,6 @@ int COM_FOpenFile(const char *filename, RFILE **file) char path[MAX_OSPATH]; pack_t *pak; int i; - int findtime; file_from_pak = 0; @@ -1276,9 +1260,8 @@ int COM_FOpenFile(const char *filename, RFILE **file) if (strchr(filename, '/') || strchr(filename, '\\')) continue; } - snprintf(path, sizeof(path), "%s/%s", search->filename, filename); - findtime = Sys_FileTime(path); - if (findtime == -1) + fill_pathname_join(path, search->filename, filename, sizeof(path)); + if (Sys_FileTime(path) == -1) continue; *file = rfopen(path, "rb"); @@ -1333,7 +1316,7 @@ qboolean COM_FileExists (const char *filename) if (strchr(filename, '/') || strchr(filename, '\\')) continue; } - snprintf(path, sizeof(path), "%s/%s", search->filename, filename); + fill_pathname_join(path, search->filename, filename, sizeof(path)); findtime = Sys_FileTime(path); if (findtime == -1) continue; @@ -1445,7 +1428,7 @@ void COM_ScanDir(struct stree_root *root, const char *path, const char *pfx, COM_ScanDirPak(root, search->pack, path, pfx, ext, stripext); else { - snprintf(fullpath, MAX_OSPATH, "%s/%s", search->filename, path); + fill_pathname_join(fullpath, search->filename, path, MAX_OSPATH); fullpath[MAX_OSPATH - 1] = '\0'; dir = retro_opendir(fullpath); @@ -1597,7 +1580,7 @@ static pack_t *COM_LoadPackFile(const char *packfile) /* parse the directory */ for (i = 0; i < numfiles; i++) { - snprintf(mfiles[i].name, sizeof(mfiles[i].name), "%s", dfiles[i].name); + strlcpy(mfiles[i].name, dfiles[i].name, sizeof(mfiles[i].name)); #ifdef MSB_FIRST mfiles[i].filepos = LittleLong(dfiles[i].filepos); mfiles[i].filelen = LittleLong(dfiles[i].filelen); @@ -1619,7 +1602,7 @@ static pack_t *COM_LoadPackFile(const char *packfile) if (!pack) goto error; - snprintf(pack->filename, sizeof(pack->filename), "%s", packfile); + strlcpy(pack->filename, packfile, sizeof(pack->filename)); strcpy(pack->filename, packfile); pack->numfiles = numfiles; pack->files = mfiles; diff --git a/common/host_cmd.c b/common/host_cmd.c index f79d03a1..b9ed2c6a 100644 --- a/common/host_cmd.c +++ b/common/host_cmd.c @@ -62,61 +62,8 @@ Host_Quit_f(void) } CL_Disconnect(); Host_ShutdownServer(false); - - //Sys_Quit(); -} - - -/* -================== -Host_Status_f -================== -*/ -void -Host_Status_f(void) -{ - client_t *client; - int seconds; - int minutes; - int hours = 0; - int j; - void (*print)(const char *fmt, ...); - - if (cmd_source == src_command) { - if (!sv.active) { - Cmd_ForwardToServer(); - return; - } - print = Con_Printf; - } else - print = SV_ClientPrintf; - - print("host: %s\n", Cvar_VariableString("hostname")); - print("version: TyrQuake-%s\n", stringify(TYR_VERSION)); - if (tcpipAvailable) - print("tcp/ip: %s\n", my_tcpip_address); - print("map: %s\n", sv.name); - print("players: %i active (%i max)\n\n", net_activeconnections, - svs.maxclients); - for (j = 0, client = svs.clients; j < svs.maxclients; j++, client++) { - if (!client->active) - continue; - seconds = (int)(net_time - client->netconnection->connecttime); - minutes = seconds / 60; - if (minutes) { - seconds -= (minutes * 60); - hours = minutes / 60; - if (hours) - minutes -= (hours * 60); - } else - hours = 0; - print("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j + 1, client->name, - (int)client->edict->v.frags, hours, minutes, seconds); - print(" %s\n", client->netconnection->address); - } } - /* ================== Host_God_f @@ -1436,7 +1383,6 @@ Host_InitCommands void Host_InitCommands(void) { - Cmd_AddCommand("status", Host_Status_f); Cmd_AddCommand("quit", Host_Quit_f); Cmd_AddCommand("god", Host_God_f); Cmd_AddCommand("notarget", Host_Notarget_f); diff --git a/common/libretro.c b/common/libretro.c index 275fa5b0..c98ab4da 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -840,13 +840,10 @@ static void update_variables(bool startup) { char *pch; char str[100]; - snprintf(str, sizeof(str), "%s", var.value); - - pch = strtok(str, "x"); - if (pch) + strlcpy(str, var.value, sizeof(str)); + if ((pch = strtok(str, "x"))) width = strtoul(pch, NULL, 0); - pch = strtok(NULL, "x"); - if (pch) + if ((pch = strtok(NULL, "x"))) height = strtoul(pch, NULL, 0); if (log_cb) @@ -1123,10 +1120,11 @@ bool retro_load_game(const struct retro_game_info *info) Host_Shutdown(); - snprintf(msg_local, sizeof(msg_local), - "PAK archive loading failed..."); - msg.msg = msg_local; - msg.frames = 360; + msg_local[0] = '\0'; + strlcpy(msg_local, + "PAK archive loading failed...", sizeof(msg_local)); + msg.msg = msg_local; + msg.frames = 360; if (environ_cb) environ_cb(RETRO_ENVIRONMENT_SET_MESSAGE, (void*)&msg); return false; diff --git a/common/net_dgrm.c b/common/net_dgrm.c index 4188cce1..4d806c35 100644 --- a/common/net_dgrm.c +++ b/common/net_dgrm.c @@ -44,14 +44,6 @@ extern int m_state; #include "screen.h" #include "sys.h" -/* statistic counters */ -static int packetsSent = 0; -static int packetsReSent = 0; -static int packetsReceived = 0; -static int receivedDuplicateCount = 0; -static int shortPacketCount = 0; -static int droppedDatagrams; - static net_driver_t *dgrm_driver; static struct { @@ -60,19 +52,6 @@ static struct { byte data[NET_MAXMESSAGE]; } packetBuffer; -#ifdef DEBUG -static const char * -StrAddr(netadr_t *addr) -{ - static char buf[32]; - - snprintf(buf, sizeof(buf), "%d.%d.%d.%d:%d", - addr->ip.b[0], addr->ip.b[1], addr->ip.b[2], addr->ip.b[3], - ntohs(addr->port)); - return buf; -} -#endif - static netadr_t banAddr = { INADDR_ANY, 0, 0 }; static netadr_t banMask = { INADDR_NONE, 0, 0 }; @@ -81,20 +60,17 @@ NET_Ban_f(void) { char addrStr[32]; char maskStr[32]; - void (*print)(const char *fmt, ...); if (cmd_source == src_command) { if (!sv.active) { Cmd_ForwardToServer(); return; } - print = Con_Printf; } else { if (pr_global_struct->deathmatch) return; - print = SV_ClientPrintf; } switch (Cmd_Argc()) @@ -104,9 +80,7 @@ NET_Ban_f(void) { strcpy(addrStr, NET_AdrToString(&banAddr)); strcpy(maskStr, NET_AdrToString(&banMask)); - print("Banning %s [%s]\n", addrStr, maskStr); - } else - print("Banning not active\n"); + } break; case 2: @@ -123,7 +97,6 @@ NET_Ban_f(void) break; default: - print("BAN ip_address [mask]\n"); break; } } @@ -153,7 +126,6 @@ SendPacket(qsocket_t *sock) return -1; sock->lastSendTime = net_time; - packetsSent++; return 1; } @@ -161,17 +133,6 @@ SendPacket(qsocket_t *sock) int Datagram_SendMessage(qsocket_t *sock, sizebuf_t *data) { -#ifdef DEBUG - if (data->cursize == 0) - Sys_Error("%s: zero length message", __func__); - - if (data->cursize > NET_MAXMESSAGE) - Sys_Error("%s: message too big %u", __func__, data->cursize); - - if (sock->canSend == false) - Sys_Error("%s: called with canSend == false", __func__); -#endif - memcpy(sock->sendMessage, data->data, data->cursize); sock->sendMessageLength = data->cursize; sock->canSend = false; @@ -212,21 +173,10 @@ Datagram_CanSendUnreliableMessage(qsocket_t *sock) return true; } - int Datagram_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data) { - int packetLen; - -#ifdef DEBUG - if (data->cursize == 0) - Sys_Error("%s: zero length message", __func__); - - if (data->cursize > sock->mtu) - Sys_Error("%s: message too big %u", __func__, data->cursize); -#endif - - packetLen = NET_HEADERSIZE + data->cursize; + int packetLen = NET_HEADERSIZE + data->cursize; packetBuffer.length = BigLong(packetLen | NETFLAG_UNRELIABLE); packetBuffer.sequence = BigLong(sock->unreliableSendSequence++); @@ -236,7 +186,6 @@ Datagram_SendUnreliableMessage(qsocket_t *sock, sizebuf_t *data) &sock->addr) == -1) return -1; - packetsSent++; return 1; } @@ -249,7 +198,6 @@ Datagram_GetMessage(qsocket_t *sock) int ret = 0; netadr_t readaddr; unsigned int sequence; - unsigned int count; if (!sock->canSend) if ((net_time - sock->lastSendTime) > 1.0) @@ -269,10 +217,8 @@ Datagram_GetMessage(qsocket_t *sock) if (NET_AddrCompare(&readaddr, &sock->addr) != 0) continue; - if (length < NET_HEADERSIZE) { - shortPacketCount++; + if (length < NET_HEADERSIZE) continue; - } length = BigLong(packetBuffer.length); flags = length & (~NETFLAG_LENGTH_MASK); @@ -282,17 +228,12 @@ Datagram_GetMessage(qsocket_t *sock) continue; sequence = BigLong(packetBuffer.sequence); - packetsReceived++; if (flags & NETFLAG_UNRELIABLE) { if (sequence < sock->unreliableReceiveSequence) { ret = 0; break; } - if (sequence != sock->unreliableReceiveSequence) { - count = sequence - sock->unreliableReceiveSequence; - droppedDatagrams += count; - } sock->unreliableReceiveSequence = sequence + 1; length -= NET_HEADERSIZE; @@ -329,10 +270,8 @@ Datagram_GetMessage(qsocket_t *sock) sock->landriver->Write(sock->socket, &packetBuffer, NET_HEADERSIZE, &readaddr); - if (sequence != sock->receiveSequence) { - receivedDuplicateCount++; + if (sequence != sock->receiveSequence) continue; - } sock->receiveSequence++; length -= NET_HEADERSIZE; @@ -361,54 +300,6 @@ Datagram_GetMessage(qsocket_t *sock) return ret; } -static void -PrintStats(qsocket_t *s) -{ - Con_Printf("canSend = %4u \n", s->canSend); - Con_Printf("sendSeq = %4u ", s->sendSequence); - Con_Printf("recvSeq = %4u \n", s->receiveSequence); - Con_Printf("\n"); -} - -void -NET_Stats_f(void) -{ - qsocket_t *s; - - if (Cmd_Argc() == 1) { - Con_Printf("unreliable messages sent = %i\n", - unreliableMessagesSent); - Con_Printf("unreliable messages recv = %i\n", - unreliableMessagesReceived); - Con_Printf("reliable messages sent = %i\n", messagesSent); - Con_Printf("reliable messages received = %i\n", messagesReceived); - Con_Printf("packetsSent = %i\n", packetsSent); - Con_Printf("packetsReSent = %i\n", packetsReSent); - Con_Printf("packetsReceived = %i\n", packetsReceived); - Con_Printf("receivedDuplicateCount = %i\n", - receivedDuplicateCount); - Con_Printf("shortPacketCount = %i\n", shortPacketCount); - Con_Printf("droppedDatagrams = %i\n", droppedDatagrams); - } else if (strcmp(Cmd_Argv(1), "*") == 0) { - for (s = net_activeSockets; s; s = s->next) - PrintStats(s); - for (s = net_freeSockets; s; s = s->next) - PrintStats(s); - } else { - for (s = net_activeSockets; s; s = s->next) - if (strcasecmp(Cmd_Argv(1), s->address) == 0) - break; - if (s == NULL) - for (s = net_freeSockets; s; s = s->next) - if (strcasecmp(Cmd_Argv(1), s->address) == 0) - break; - if (s == NULL) - return; - PrintStats(s); - } -} - - struct test_poll_state { qboolean inProgress; @@ -691,7 +582,6 @@ Datagram_Init(void) int i, csock, num_inited; dgrm_driver = net_driver; - Cmd_AddCommand("net_stats", NET_Stats_f); if (COM_CheckParm("-nolan")) return -1; @@ -1179,12 +1069,6 @@ _Datagram_Connect(const char *host, net_landriver_t *driver) if (ret > 0) { // is it from the right place? if (NET_AddrCompare(&readaddr, &sendaddr) != 0) { -#ifdef DEBUG - Con_Printf("wrong reply address\n"); - Con_Printf("Expected: %s\n", StrAddr(&sendaddr)); - Con_Printf("Received: %s\n", StrAddr(&readaddr)); - SCR_UpdateScreen(); -#endif ret = 0; continue; } diff --git a/common/pr_cmds.c b/common/pr_cmds.c index bc1e3d64..6e144dbd 100644 --- a/common/pr_cmds.c +++ b/common/pr_cmds.c @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include +#include #include "cmd.h" #include "console.h" @@ -1778,7 +1779,7 @@ PF_infokey(void) } else if (e1 <= MAX_CLIENTS) { if (!strcmp(key, "ip")) { netadr_t addr = svs.clients[e1 - 1].netchan.remote_address; - snprintf(buf, sizeof(buf), "%s", NET_BaseAdrToString(addr)); + strlcpy(buf, NET_BaseAdrToString(addr), sizeof(buf)); value = buf; } else if (!strcmp(key, "ping")) { int ping = SV_CalcPing(&svs.clients[e1 - 1]); From 10a70d6dfd83979ad709216d3556690f45bc9328 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 12 Jun 2022 18:22:26 +0200 Subject: [PATCH 44/48] No return value for Sys_Error --- common/host.c | 25 ++++++++++++------------- common/libretro.c | 4 +--- common/sys.h | 2 +- common/wad.c | 22 ++++++++++------------ 4 files changed, 24 insertions(+), 29 deletions(-) diff --git a/common/host.c b/common/host.c index 0c84180f..20da383a 100644 --- a/common/host.c +++ b/common/host.c @@ -109,9 +109,6 @@ Host_EndGame(const char *message, ...) if (sv.active) Host_ShutdownServer(false); - if (cls.state == ca_dedicated) - Sys_Error("%s: %s", __func__, string); // dedicated servers exit - if (cls.demonum != -1) CL_NextDemo(); else @@ -134,8 +131,6 @@ Host_Error(const char *error, ...) char string[MAX_PRINTMSG]; static qboolean inerror = false; - if (inerror) - Sys_Error("%s: recursively entered", __func__); inerror = true; SCR_EndLoadingPlaque(); // reenable screen updates @@ -148,9 +143,6 @@ Host_Error(const char *error, ...) if (sv.active) Host_ShutdownServer(false); - if (cls.state == ca_dedicated) - Sys_Error("%s: %s", __func__, string); // dedicated servers exit - CL_Disconnect(); cls.demonum = -1; @@ -183,8 +175,6 @@ Host_FindMaxClients(void) i = COM_CheckParm("-listen"); if (i) { - if (cls.state == ca_dedicated) - Sys_Error("Only one of -dedicated or -listen can be specified"); if (i != (com_argc - 1)) svs.maxclients = Q_atoi(com_argv[i + 1]); else @@ -617,8 +607,11 @@ Host_Init(quakeparms_t *parms) host_parms = *parms; if (parms->memsize < minimum_memory) - return Sys_Error("Only %4.1f megs of memory reported, can't execute game", + { + Sys_Error("Only %4.1f megs of memory reported, can't execute game", parms->memsize / (float)0x100000); + return false; + } com_argc = parms->argc; com_argv = parms->argv; @@ -649,10 +642,16 @@ Host_Init(quakeparms_t *parms) if (cls.state != ca_dedicated) { host_basepal = (byte*)COM_LoadHunkFile("gfx/palette.lmp"); if (!host_basepal) - return Sys_Error("Couldn't load gfx/palette.lmp"); + { + Sys_Error("Couldn't load gfx/palette.lmp"); + return false; + } host_colormap = (byte*)COM_LoadHunkFile("gfx/colormap.lmp"); if (!host_colormap) - return Sys_Error("Couldn't load gfx/colormap.lmp"); + { + Sys_Error("Couldn't load gfx/colormap.lmp"); + return false; + } if (coloredlights) diff --git a/common/libretro.c b/common/libretro.c index c98ab4da..8a2a0b37 100644 --- a/common/libretro.c +++ b/common/libretro.c @@ -329,7 +329,7 @@ void Sys_Init(void) } } -bool Sys_Error(const char *error, ...) +void Sys_Error(const char *error, ...) { char buffer[256]; va_list ap; @@ -339,8 +339,6 @@ bool Sys_Error(const char *error, ...) if (log_cb) log_cb(RETRO_LOG_ERROR, "%s\n", buffer); va_end(ap); - - return false; } /* diff --git a/common/sys.h b/common/sys.h index 44d5feec..9e42e633 100644 --- a/common/sys.h +++ b/common/sys.h @@ -36,7 +36,7 @@ void Sys_mkdir(const char *path); #define MAX_PRINTMSG 4096 -bool Sys_Error(const char *error, ...); +void Sys_Error(const char *error, ...); // send text to the console // an error will cause the entire program to exit diff --git a/common/wad.c b/common/wad.c index a6e93660..5e44f4a2 100644 --- a/common/wad.c +++ b/common/wad.c @@ -75,9 +75,11 @@ bool W_LoadWadFile(const char *filename) unsigned i; int infotableofs; - wad_base = (byte*)COM_LoadHunkFile(filename); - if (!wad_base) - return Sys_Error("%s: couldn't load %s", __func__, filename); + if (!(wad_base = (byte*)COM_LoadHunkFile(filename))) + { + Sys_Error("%s: couldn't load %s", __func__, filename); + return false; + } header = (wadinfo_t *)wad_base; @@ -85,7 +87,10 @@ bool W_LoadWadFile(const char *filename) || header->identification[1] != 'A' || header->identification[2] != 'D' || header->identification[3] != '2') - return Sys_Error("Wad file %s doesn't have WAD2 id", filename); + { + Sys_Error("Wad file %s doesn't have WAD2 id", filename); + return false; + } #ifdef MSB_FIRST wad_numlumps = LittleLong(header->numlumps); @@ -132,7 +137,6 @@ lumpinfo_t * W_GetLumpinfo(const char *name) return lump_p; } - Sys_Error("%s: %s not found", __func__, name); return NULL; } @@ -144,13 +148,7 @@ void * W_GetLumpName(const char *name) void *W_GetLumpNum(int num) { - lumpinfo_t *lump; - - if (num < 0 || num > wad_numlumps) - Sys_Error("%s: bad number: %i", __func__, num); - - lump = wad_lumps + num; - + lumpinfo_t *lump = wad_lumps + num; return (void *)(wad_base + lump->filepos); } From 9911d91fe27428860c5c81a73834d2ef28ae19b9 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Sun, 12 Jun 2022 18:29:46 +0200 Subject: [PATCH 45/48] Cleanups --- common/snd_dma.c | 27 ++---------- common/snd_mem.c | 22 +++------- common/snd_mix.c | 104 ++++++++++++++++++++++------------------------- common/sound.h | 1 - 4 files changed, 58 insertions(+), 96 deletions(-) diff --git a/common/snd_dma.c b/common/snd_dma.c index 3584fd3d..cca0a898 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -98,8 +98,7 @@ static void SND_Callback_sfxvolume (cvar_t *var) * ================ */ -void -S_Startup(void) +static void S_Startup(void) { if (!SNDDMA_Init(&sn)) { @@ -173,19 +172,11 @@ S_FindName(const char *name) int i; sfx_t *sfx; - if (!name) - Sys_Error("%s: NULL", __func__); - if (strlen(name) >= MAX_QPATH) - Sys_Error("%s: name too long: %s", __func__, name); - /* see if already loaded */ for (i = 0; i < num_sfx; i++) if (!strcmp(known_sfx[i].name, name)) return &known_sfx[i]; - if (num_sfx == MAX_SFX) - Sys_Error("%s: out of sfx_t", __func__); - sfx = &known_sfx[i]; strcpy(sfx->name, name); @@ -761,13 +752,9 @@ static void S_Play(void) { sfx_t *sfx; + strcpy(name, Cmd_Argv(i)); if (!strrchr(Cmd_Argv(i), '.')) - { - strcpy(name, Cmd_Argv(i)); strcat(name, ".wav"); - } - else - strcpy(name, Cmd_Argv(i)); sfx = S_PrecacheSound(name); S_StartSound(hash++, 0, sfx, listener_origin, 1.0, 1.0); i++; @@ -785,13 +772,9 @@ static void S_PlayVol(void) float vol; sfx_t *sfx; + strcpy(name, Cmd_Argv(i)); if (!strrchr(Cmd_Argv(i), '.')) - { - strcpy(name, Cmd_Argv(i)); strcat(name, ".wav"); - } - else - strcpy(name, Cmd_Argv(i)); sfx = S_PrecacheSound(name); vol = Q_atof(Cmd_Argv(i + 1)); S_StartSound(hash++, 0, sfx, listener_origin, vol, 1.0); @@ -807,10 +790,8 @@ void S_LocalSound(const char *sound) return; sfx = S_PrecacheSound(sound); - if (!sfx) { - Con_Printf("%s: can't cache %s\n", __func__, sound); + if (!sfx) return; - } #ifdef NQ_HACK S_StartSound(cl.viewentity, -1, sfx, vec3_origin, 1, 1); #endif diff --git a/common/snd_mem.c b/common/snd_mem.c index 41676168..5a4ae98f 100644 --- a/common/snd_mem.c +++ b/common/snd_mem.c @@ -38,9 +38,7 @@ ResampleSfx(sfx_t *sfx, int inrate, int inwidth, const byte *data) float stepscale; int i; int sample, samplefrac, fracstep; - sfxcache_t *sc; - - sc = (sfxcache_t*)Cache_Check(&sfx->cache); + sfxcache_t *sc = (sfxcache_t*)Cache_Check(&sfx->cache); if (!sc) return; @@ -115,21 +113,16 @@ S_LoadSound(sfx_t *s) wavinfo_t *info; int len; float stepscale; - sfxcache_t *sc; byte stackbuf[1024]; // avoid dirtying the cache heap - -// see if still in memory - sc = (sfxcache_t*)Cache_Check(&s->cache); + // see if still in memory + sfxcache_t *sc = (sfxcache_t*)Cache_Check(&s->cache); if (sc) return sc; -//Con_Printf ("S_LoadSound: %x\n", (int)stackbuf); -// load it in + // load it in strcpy(namebuffer, "sound/"); strcat(namebuffer, s->name); -// Con_Printf ("loading %s\n",namebuffer); - data = (byte*)COM_LoadStackFile(namebuffer, stackbuf, sizeof(stackbuf), NULL); if (!data) { @@ -317,12 +310,7 @@ wavinfo_t *GetWavinfo (const char *name, byte *wav, int wavlength) data_p += 4; samples = GetLittleLong() / info.width; - if (info.samples) - { - if (samples < info.samples) - Sys_Error("Sound %s has a bad loop length", name); - } - else + if (!info.samples) info.samples = samples; info.dataofs = data_p - wav; diff --git a/common/snd_mix.c b/common/snd_mix.c index 17f4215d..d3fe5479 100644 --- a/common/snd_mix.c +++ b/common/snd_mix.c @@ -33,20 +33,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define PAINTBUFFER_SIZE 16384 portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE]; -int snd_scaletable[32][256]; -int *snd_p, snd_linear_count; -short *snd_out; +static int snd_scaletable[32][256]; +static int *snd_p, snd_linear_count; +static short *snd_out; static int snd_vol; static void Snd_WriteLinearBlastStereo16 (void) { int i; - int val; for (i = 0; i < snd_linear_count; i += 2) { - val = snd_p[i] >> 8; + int val = snd_p[i] >> 8; if (val > 0x7fff) snd_out[i] = 0x7fff; else if (val < (short)0x8000) @@ -100,8 +99,51 @@ CHANNEL MIXING =============================================================================== */ -static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int endtime, int paintbufferstart); -static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int endtime, int paintbufferstart); +static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) +{ + int *lscale, *rscale; + unsigned char *sfx; + int i; + + if (ch->leftvol > 255) + ch->leftvol = 255; + if (ch->rightvol > 255) + ch->rightvol = 255; + + lscale = snd_scaletable[ch->leftvol >> 3]; + rscale = snd_scaletable[ch->rightvol >> 3]; + sfx = (unsigned char *)sc->data + ch->pos; + + for (i = 0; i < count; i++) + { + int data = sfx[i]; + paintbuffer[paintbufferstart + i].left += lscale[data]; + paintbuffer[paintbufferstart + i].right += rscale[data]; + } + + ch->pos += count; +} + +static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) +{ + int i; + int leftvol = (ch->leftvol * snd_vol) >> 8; + int rightvol = (ch->rightvol * snd_vol) >> 8; + signed short *sfx = (signed short *)sc->data + ch->pos; + + for (i = 0; i < count; i++) + { + int data = sfx[i]; + // this was causing integer overflow as observed in quakespasm + // with the warpspasm mod moved >>8 to left/right volume above. + int left = data * leftvol; + int right = data * rightvol; + paintbuffer[paintbufferstart + i].left += left; + paintbuffer[paintbufferstart + i].right += right; + } + + ch->pos += count; +} void S_PaintChannels (int endtime) { @@ -221,51 +263,3 @@ void SND_InitScaletable (void) } } } - - -static void SND_PaintChannelFrom8 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) -{ - int *lscale, *rscale; - unsigned char *sfx; - int i; - - if (ch->leftvol > 255) - ch->leftvol = 255; - if (ch->rightvol > 255) - ch->rightvol = 255; - - lscale = snd_scaletable[ch->leftvol >> 3]; - rscale = snd_scaletable[ch->rightvol >> 3]; - sfx = (unsigned char *)sc->data + ch->pos; - - for (i = 0; i < count; i++) - { - int data = sfx[i]; - paintbuffer[paintbufferstart + i].left += lscale[data]; - paintbuffer[paintbufferstart + i].right += rscale[data]; - } - - ch->pos += count; -} - -static void SND_PaintChannelFrom16 (channel_t *ch, sfxcache_t *sc, int count, int paintbufferstart) -{ - int i; - int leftvol = (ch->leftvol * snd_vol) >> 8; - int rightvol = (ch->rightvol * snd_vol) >> 8; - signed short *sfx = (signed short *)sc->data + ch->pos; - - for (i = 0; i < count; i++) - { - int data = sfx[i]; - // this was causing integer overflow as observed in quakespasm - // with the warpspasm mod moved >>8 to left/right volume above. - int left = data * leftvol; - int right = data * rightvol; - paintbuffer[paintbufferstart + i].left += left; - paintbuffer[paintbufferstart + i].right += right; - } - - ch->pos += count; -} - diff --git a/common/sound.h b/common/sound.h index 43069fac..7fa32856 100644 --- a/common/sound.h +++ b/common/sound.h @@ -104,7 +104,6 @@ typedef struct } wavinfo_t; void S_Init(void); -void S_Startup(void); void S_Shutdown(void); void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); From 2169d02977d3dffe46dce4d0cd84ef4416c0b981 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 13 Jun 2022 15:52:10 +0200 Subject: [PATCH 46/48] S_StopAllSounds - argument is always true --- common/cl_main.c | 2 +- common/screen.c | 2 +- common/snd_dma.c | 169 +++++++++++++++++++++++------------------------ common/sound.h | 2 +- 4 files changed, 85 insertions(+), 90 deletions(-) diff --git a/common/cl_main.c b/common/cl_main.c index b6f6a25c..fe6352b7 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -144,7 +144,7 @@ void CL_Disconnect(void) int i; /* stop sounds (especially looping!) */ - S_StopAllSounds(true); + S_StopAllSounds(); BGM_Stop(); CDAudio_Stop(); diff --git a/common/screen.c b/common/screen.c index 384aefa6..6c4c145d 100644 --- a/common/screen.c +++ b/common/screen.c @@ -512,7 +512,7 @@ SCR_BeginLoadingPlaque */ void SCR_BeginLoadingPlaque(void) { - S_StopAllSounds(true); + S_StopAllSounds(); if (cls.state != ca_active) return; diff --git a/common/snd_dma.c b/common/snd_dma.c index cca0a898..41388ddc 100644 --- a/common/snd_dma.c +++ b/common/snd_dma.c @@ -51,8 +51,6 @@ static void S_StopAllSoundsC(void); channel_t channels[MAX_CHANNELS]; int total_channels; -static qboolean snd_ambient = 1; - #define CHANNELS 2 /* pointer should go away (JC?) */ @@ -63,7 +61,7 @@ static vec3_t listener_origin; static vec3_t listener_forward; static vec3_t listener_right; static vec3_t listener_up; -static vec_t sound_nominal_clip_dist = 1000.0; +#define SOUND_NOMINAL_CLIP_DIST 1000.0f static int soundtime; /* sample PAIRS */ int paintedtime; /* sample PAIRS */ @@ -144,7 +142,7 @@ S_Init(void) S_CodecInit(); - S_StopAllSounds(true); + S_StopAllSounds(); } @@ -349,7 +347,7 @@ S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, /* spatialize */ memset(target_chan, 0, sizeof(*target_chan)); VectorCopy(origin, target_chan->origin); - target_chan->dist_mult = attenuation / sound_nominal_clip_dist; + target_chan->dist_mult = attenuation / SOUND_NOMINAL_CLIP_DIST; target_chan->master_vol = vol; target_chan->entnum = entnum; target_chan->entchannel = entchannel; @@ -405,7 +403,7 @@ S_StopSound(int entnum, int entchannel) } void -S_StopAllSounds(qboolean clear) +S_StopAllSounds(void) { int i; @@ -420,14 +418,14 @@ S_StopAllSounds(qboolean clear) channels[i].sfx = NULL; memset(channels, 0, MAX_CHANNELS * sizeof(channel_t)); - if (clear) - S_ClearBuffer(); + if (shm) + memset(shm->buffer, 0, SHM_SAMPLES * 16 / 8); } static void S_StopAllSoundsC(void) { - S_StopAllSounds(true); + S_StopAllSounds(); } void S_ClearBuffer(void) @@ -451,7 +449,7 @@ Expects data in signed 16 bit, or unsigned void S_RawSamples (int samples, int rate, int width, int channels, byte *data, float volume) { int i; - int src, dst; + int dst; float scale; int intVolume; @@ -461,60 +459,66 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f scale = (float) rate / shm->speed; intVolume = (int) (256 * volume); - if (channels == 2 && width == 2) + if (channels == 2) { - for (i = 0; ; i++) + if (width == 1) { - src = i * scale; - if (src >= samples) - break; - dst = s_rawend & (MAX_RAW_SAMPLES - 1); - s_rawend++; - s_rawsamples [dst].left = ((short *) data)[src * 2] * intVolume; - s_rawsamples [dst].right = ((short *) data)[src * 2 + 1] * intVolume; + intVolume *= 256; + + for (i = 0; ; i++) + { + int src = i * scale; + if (src >= samples) + break; + dst = s_rawend & (MAX_RAW_SAMPLES - 1); + s_rawend++; + s_rawsamples [dst].left = (((byte *) data)[src * 2] - 128) * intVolume; + s_rawsamples [dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume; + } } - } - else if (channels == 1 && width == 2) - { - for (i = 0; ; i++) + else if (width == 2) { - src = i * scale; - if (src >= samples) - break; - dst = s_rawend & (MAX_RAW_SAMPLES - 1); - s_rawend++; - s_rawsamples [dst].left = ((short *) data)[src] * intVolume; - s_rawsamples [dst].right = ((short *) data)[src] * intVolume; + for (i = 0; ; i++) + { + int src = i * scale; + if (src >= samples) + break; + dst = s_rawend & (MAX_RAW_SAMPLES - 1); + s_rawend++; + s_rawsamples [dst].left = ((short *) data)[src * 2] * intVolume; + s_rawsamples [dst].right = ((short *) data)[src * 2 + 1] * intVolume; + } } } - else if (channels == 2 && width == 1) + else if (channels == 1) { - intVolume *= 256; - - for (i = 0; ; i++) + if (width == 1) { - src = i * scale; - if (src >= samples) - break; - dst = s_rawend & (MAX_RAW_SAMPLES - 1); - s_rawend++; - s_rawsamples [dst].left = (((byte *) data)[src * 2] - 128) * intVolume; - s_rawsamples [dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume; + intVolume *= 256; + + for (i = 0; ; i++) + { + int src = i * scale; + if (src >= samples) + break; + dst = s_rawend & (MAX_RAW_SAMPLES - 1); + s_rawend++; + s_rawsamples [dst].left = (((byte *) data)[src] - 128) * intVolume; + s_rawsamples [dst].right = (((byte *) data)[src] - 128) * intVolume; + } } - } - else if (channels == 1 && width == 1) - { - intVolume *= 256; - - for (i = 0; ; i++) + else if (width == 2) { - src = i * scale; - if (src >= samples) - break; - dst = s_rawend & (MAX_RAW_SAMPLES - 1); - s_rawend++; - s_rawsamples [dst].left = (((byte *) data)[src] - 128) * intVolume; - s_rawsamples [dst].right = (((byte *) data)[src] - 128) * intVolume; + for (i = 0; ; i++) + { + int src = i * scale; + if (src >= samples) + break; + dst = s_rawend & (MAX_RAW_SAMPLES - 1); + s_rawend++; + s_rawsamples [dst].left = ((short *) data)[src] * intVolume; + s_rawsamples [dst].right = ((short *) data)[src] * intVolume; + } } } } @@ -553,8 +557,8 @@ S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation) ss->sfx = sfx; VectorCopy(origin, ss->origin); ss->master_vol = vol; - ss->dist_mult = (attenuation / 64) / sound_nominal_clip_dist; - ss->end = paintedtime + sc->length; + ss->dist_mult = (attenuation / 64) / SOUND_NOMINAL_CLIP_DIST; + ss->end = paintedtime + sc->length; SND_Spatialize(ss); } @@ -631,35 +635,13 @@ static void GetSoundtime(void) /* time to chop things off to avoid 32 bit limits */ if (paintedtime > 0x40000000) { - buffers = 0; + buffers = 0; paintedtime = fullsamples; - S_StopAllSounds(true); + S_StopAllSounds(); } } oldsamplepos = samplepos; - - soundtime = buffers * fullsamples + samplepos / CHANNELS; -} - -static void S_Update_(void) -{ - unsigned endtime; - int samps; - - /* Updates DMA time */ - GetSoundtime(); - - /* check to make sure that we haven't overshot */ - /* FIXME - handle init & wrap properly and report actual overflow */ - if (paintedtime < soundtime) - paintedtime = soundtime; - /* mix ahead of current position */ - endtime = soundtime + _snd_mixahead.value * shm->speed; - samps = SHM_SAMPLES >> 1; - if (endtime - soundtime > samps) - endtime = soundtime + samps; - - S_PaintChannels(endtime); + soundtime = buffers * fullsamples + samplepos / CHANNELS; } /* @@ -672,8 +654,10 @@ static void S_Update_(void) void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) { int i, j; + int samps; + unsigned endtime; channel_t *ch; - channel_t *combine; + channel_t *combine = NULL; if (!sound_started) return; @@ -684,10 +668,7 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) VectorCopy(up, listener_up); /* update general area ambient sound sources */ - if (snd_ambient) - S_UpdateAmbientSounds(); - - combine = NULL; + S_UpdateAmbientSounds(); /* update spatialization for static and dynamic sounds */ ch = channels + NUM_AMBIENTS; @@ -731,7 +712,21 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up) } /* mix some sound */ - S_Update_(); + + /* Updates DMA time */ + GetSoundtime(); + + /* check to make sure that we haven't overshot */ + /* FIXME - handle init & wrap properly and report actual overflow */ + if (paintedtime < soundtime) + paintedtime = soundtime; + /* mix ahead of current position */ + endtime = soundtime + _snd_mixahead.value * shm->speed; + samps = SHM_SAMPLES >> 1; + if (endtime - soundtime > samps) + endtime = soundtime + samps; + + S_PaintChannels(endtime); } /* diff --git a/common/sound.h b/common/sound.h index 7fa32856..e9b548ef 100644 --- a/common/sound.h +++ b/common/sound.h @@ -109,7 +109,7 @@ void S_StartSound(int entnum, int entchannel, sfx_t *sfx, vec3_t origin, float fvol, float attenuation); void S_StaticSound(sfx_t *sfx, vec3_t origin, float vol, float attenuation); void S_StopSound(int entnum, int entchannel); -void S_StopAllSounds(qboolean clear); +void S_StopAllSounds(void); void S_ClearBuffer(void); void S_Update(vec3_t origin, vec3_t v_forward, vec3_t v_right, vec3_t v_up); From 1947981f958d58802053834ff59bf1b8e2b84cd3 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Mon, 13 Jun 2022 21:45:48 +0200 Subject: [PATCH 47/48] General cleanups --- common/cl_main.c | 13 ++-- common/cl_parse.c | 43 +++++------- common/cl_tent.c | 6 +- common/cmd.c | 171 +++++----------------------------------------- common/cmd.h | 11 --- 5 files changed, 41 insertions(+), 203 deletions(-) diff --git a/common/cl_main.c b/common/cl_main.c index fe6352b7..bb230b0e 100644 --- a/common/cl_main.c +++ b/common/cl_main.c @@ -80,11 +80,9 @@ entity_t cl_visedicts[MAX_VISEDICTS]; int CL_PlayerEntity(const entity_t *e) { - ptrdiff_t offset; int i; - /* might be a pointer directly into cl_entities... */ - offset = e - cl_entities; + ptrdiff_t offset = e - cl_entities; if (offset >= 1 && offset <= cl.maxclients) return offset; @@ -422,16 +420,15 @@ CL_RelinkEntities */ void CL_RelinkEntities(void) { + int i; entity_t *ent; - int i, j; - float frac, f, d; + float f, d; vec3_t delta; float bobjrotate; vec3_t oldorg; dlight_t *dl; - /* determine partial update time */ - frac = CL_LerpPoint(); + float frac = CL_LerpPoint(); cl_numvisedicts = 0; @@ -442,6 +439,7 @@ void CL_RelinkEntities(void) if (cls.demoplayback) { + int j; /* interpolate the angles */ for (j = 0; j < 3; j++) { @@ -493,6 +491,7 @@ void CL_RelinkEntities(void) } else { + uint8_t j; f = frac; for (j = 0; j < 3; j++) { diff --git a/common/cl_parse.c b/common/cl_parse.c index 780e2ff6..8b0f13cf 100644 --- a/common/cl_parse.c +++ b/common/cl_parse.c @@ -66,17 +66,16 @@ static int CL_ReadSoundNum(int field_mask) { switch (cl.protocol) { + case PROTOCOL_VERSION_FITZ: + if (field_mask & SND_FITZ_LARGESOUND) + return (unsigned short)MSG_ReadShort(); + /* fall-through */ case PROTOCOL_VERSION_NQ: case PROTOCOL_VERSION_BJP: return MSG_ReadByte(); case PROTOCOL_VERSION_BJP2: case PROTOCOL_VERSION_BJP3: return (unsigned short)MSG_ReadShort(); - case PROTOCOL_VERSION_FITZ: - if (field_mask & SND_FITZ_LARGESOUND) - return (unsigned short)MSG_ReadShort(); - else - return MSG_ReadByte(); default: Host_Error("%s: Unknown protocol version (%d)\n", __func__, cl.protocol); @@ -96,20 +95,16 @@ CL_ParseStartSoundPacket(void) vec3_t pos; int channel, ent; int sound_num; - int volume; - float attenuation; int i; - int field_mask = MSG_ReadByte(); + int field_mask = MSG_ReadByte(); + int volume = DEFAULT_SOUND_PACKET_VOLUME; + float attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; if (field_mask & SND_VOLUME) volume = MSG_ReadByte(); - else - volume = DEFAULT_SOUND_PACKET_VOLUME; if (field_mask & SND_ATTENUATION) attenuation = MSG_ReadByte() / 64.0; - else - attenuation = DEFAULT_SOUND_PACKET_ATTENUATION; if (cl.protocol == PROTOCOL_VERSION_FITZ && (field_mask & SND_FITZ_LARGEENTITY)) { @@ -335,16 +330,16 @@ static int CL_ReadModelIndex(unsigned int bits) { switch (cl.protocol) { + case PROTOCOL_VERSION_FITZ: + if (bits & B_FITZ_LARGEMODEL) + return MSG_ReadShort(); + /* fall-through */ case PROTOCOL_VERSION_NQ: return MSG_ReadByte(); case PROTOCOL_VERSION_BJP: case PROTOCOL_VERSION_BJP2: case PROTOCOL_VERSION_BJP3: return MSG_ReadShort(); - case PROTOCOL_VERSION_FITZ: - if (bits & B_FITZ_LARGEMODEL) - return MSG_ReadShort(); - return MSG_ReadByte(); default: break; } @@ -358,15 +353,15 @@ static int CL_ReadModelFrame(unsigned int bits) { switch (cl.protocol) { + case PROTOCOL_VERSION_FITZ: + if (bits & B_FITZ_LARGEFRAME) + return MSG_ReadShort(); + /* fall-through */ case PROTOCOL_VERSION_NQ: case PROTOCOL_VERSION_BJP: case PROTOCOL_VERSION_BJP2: case PROTOCOL_VERSION_BJP3: return MSG_ReadByte(); - case PROTOCOL_VERSION_FITZ: - if (bits & B_FITZ_LARGEFRAME) - return MSG_ReadShort(); - return MSG_ReadByte(); default: break; } @@ -502,9 +497,6 @@ CL_ParseUpdate(unsigned int bits) ent->msg_angles[0][2] = ent->baseline.angles[2]; if (cl.protocol == PROTOCOL_VERSION_FITZ) { - if (bits & U_NOLERP) { - // FIXME - TODO (called U_STEP in FQ) - } if (bits & U_FITZ_ALPHA) { MSG_ReadByte(); // FIXME - TODO } @@ -744,8 +736,9 @@ CL_NewTranslation(int slot) top = cl.players[slot].topcolor; bottom = cl.players[slot].bottomcolor; - for (i = 0; i < VID_GRADES; i++, dest += 256, source += 256) { - if (top < 128) // the artists made some backwards ranges. sigh. + for (i = 0; i < VID_GRADES; i++, dest += 256, source += 256) + { + if (top < 128) // the artists made some backwards ranges. sigh. memcpy(dest + TOP_RANGE, source + top, 16); else for (j = 0; j < 16; j++) diff --git a/common/cl_tent.c b/common/cl_tent.c index 2535da60..20033b16 100644 --- a/common/cl_tent.c +++ b/common/cl_tent.c @@ -120,7 +120,6 @@ CL_ParseBeam(model_t *m) return; } } - Con_Printf("beam list overflow!\n"); } /* @@ -131,14 +130,11 @@ CL_ParseTEnt void CL_ParseTEnt(void) { - int type; vec3_t pos; - dlight_t *dl; int rnd; int colorStart, colorLength; - - type = MSG_ReadByte(); + int type = MSG_ReadByte(); switch (type) { case TE_WIZSPIKE: // spike hitting wall diff --git a/common/cmd.c b/common/cmd.c index ebcaae2d..fff684c5 100644 --- a/common/cmd.c +++ b/common/cmd.c @@ -51,25 +51,8 @@ typedef struct cmdalias_s { #define cmdalias_entry(ptr) container_of(ptr, struct cmdalias_s, stree) static DECLARE_STREE_ROOT(cmdalias_tree); -static qboolean cmd_wait; - //============================================================================= -/* -============ -Cmd_Wait_f - -Causes execution of the remainder of the command buffer to be delayed until -next frame. This allows commands like: -bind g "impulse 5 ; +attack ; wait ; -attack ; impulse 2" -============ -*/ -void -Cmd_Wait_f(void) -{ - cmd_wait = true; -} - /* ============================================================================= @@ -113,19 +96,15 @@ void Cbuf_AddText(const char *fmt, ...) { va_list ap; - int len, maxlen; - char *buf; - - buf = (char *)cmd_text.data + cmd_text.cursize; - maxlen = cmd_text.maxsize - cmd_text.cursize; + int len; + char *buf = (char *)cmd_text.data + cmd_text.cursize; + int maxlen = cmd_text.maxsize - cmd_text.cursize; va_start(ap, fmt); len = vsnprintf(buf, maxlen, fmt, ap); va_end(ap); if (cmd_text.cursize + len < cmd_text.maxsize) cmd_text.cursize += len; - else - Con_Printf("%s: overflow\n", __func__); } @@ -140,21 +119,17 @@ of the command buffer). Adds a \n to the text. void Cbuf_InsertText(const char *text) { - int len; - - len = strlen(text); - if (cmd_text.cursize) { - if (cmd_text.cursize + len + 1 > cmd_text.maxsize) - Sys_Error("%s: overflow", __func__); - + size_t len = strlen(text); + if (cmd_text.cursize) + { /* move any commands still remaining in the exec buffer */ memmove(cmd_text.data + len + 1, cmd_text.data, cmd_text.cursize); memcpy(cmd_text.data, text, len); cmd_text.data[len] = '\n'; cmd_text.cursize += len + 1; - } else { - Cbuf_AddText("%s\n", text); } + else + Cbuf_AddText("%s\n", text); } /* @@ -210,16 +185,6 @@ void Cbuf_Execute(void) #ifdef QW_HACK Cmd_ExecuteString(line); #endif - - if (cmd_wait) - { - /* - * skip out while text still remains in buffer, leaving it for - * next frame - */ - cmd_wait = false; - break; - } } } @@ -472,7 +437,6 @@ Cmd_Init(void) Cmd_AddCommand("exec", Cmd_Exec_f); Cmd_AddCommand("echo", Cmd_Echo_f); Cmd_AddCommand("alias", Cmd_Alias_f); - Cmd_AddCommand("wait", Cmd_Wait_f); #ifdef NQ_HACK Cmd_AddCommand("cmd", Cmd_ForwardToServer); #elif defined(QW_HACK) && !defined(SERVERONLY) @@ -520,7 +484,6 @@ Cmd_Args(void) return cmd_args; } - /* ============ Cmd_TokenizeString @@ -534,7 +497,7 @@ Cmd_TokenizeString(const char *text) int i; char *arg; -// clear the args from the last string + // clear the args from the last string for (i = 0; i < cmd_argc; i++) Z_Free(cmd_argv[i]); @@ -543,9 +506,8 @@ Cmd_TokenizeString(const char *text) while (1) { // skip whitespace up to a /n - while (*text && *text <= ' ' && *text != '\n') { + while (*text && *text <= ' ' && *text != '\n') text++; - } if (*text == '\n') { // a newline seperates commands in the buffer text++; @@ -574,14 +536,10 @@ Cmd_TokenizeString(const char *text) static struct cmd_function_s * Cmd_FindCommand(const char *name) { - struct cmd_function_s *ret = NULL; - struct stree_node *n; - - n = STree_Find(&cmd_tree, name); + struct stree_node *n = STree_Find(&cmd_tree, name); if (n) - ret = cmd_entry(n); - - return ret; + return cmd_entry(n); + return NULL; } /* @@ -597,12 +555,12 @@ Cmd_AddCommand(const char *cmd_name, xcommand_t function) if (host_initialized) // because hunk allocation would get stomped Sys_Error("%s: called after host_initialized", __func__); -// fail if the command is a variable name + // fail if the command is a variable name if (Cvar_VariableString(cmd_name)[0]) { Con_Printf("%s: %s already defined as a var\n", __func__, cmd_name); return; } -// fail if the command already exists + // fail if the command already exists cmd = Cmd_FindCommand(cmd_name); if (cmd) { Con_Printf("%s: %s already defined\n", __func__, cmd_name); @@ -620,13 +578,9 @@ Cmd_AddCommand(const char *cmd_name, xcommand_t function) void Cmd_SetCompletion(const char *cmd_name, cmd_arg_f completion) { - cmd_function_t *cmd; - - cmd = Cmd_FindCommand(cmd_name); + cmd_function_t *cmd = Cmd_FindCommand(cmd_name); if (cmd) cmd->completion = completion; - else - Sys_Error("%s: no such command - %s", __func__, cmd_name); } /* @@ -784,96 +738,3 @@ Cmd_ExecuteString(const char *text) return; } } - -/* - * Return a string tree with all possible argument completions of the given - * buffer for the given command. - */ -struct stree_root * -Cmd_ArgCompletions(const char *name, const char *buf) -{ - cmd_function_t *cmd; - struct stree_root *root = NULL; - - cmd = Cmd_FindCommand(name); - if (cmd && cmd->completion) - root = cmd->completion(buf); - - return root; -} - -/* - * Call the argument completion function for cmd "name". - * Returned result should be Z_Free'd after use. - */ -const char * -Cmd_ArgComplete(const char *name, const char *buf) -{ - char *result = NULL; - struct stree_root *root; - - root = Cmd_ArgCompletions(name, buf); - if (root) { - result = STree_MaxMatch(root, buf); - Z_Free(root); - } - - return result; -} - - -/* -================ -Cmd_CheckParm - -Returns the position (1 to argc-1) in the command's argument list -where the given parameter apears, or 0 if not present -================ -*/ -int -Cmd_CheckParm(const char *parm) -{ - int i; - - if (!parm) - Sys_Error("Cmd_CheckParm: NULL"); - - for (i = 1; i < Cmd_Argc(); i++) - if (!strcasecmp(parm, Cmd_Argv(i))) - return i; - - return 0; -} - -struct stree_root *Cmd_CommandCompletions(const char *buf) -{ - struct stree_root *root_tree; - - root_tree = (struct stree_root*)Z_Malloc(sizeof(struct stree_root)); - - root_tree->entries = 0; - root_tree->maxlen = 0; - root_tree->minlen = -1; - //root_tree->root = {NULL}; - root_tree->stack = NULL; - - STree_AllocInit(); - - STree_Completions(root_tree, &cmd_tree, buf); - STree_Completions(root_tree, &cmdalias_tree, buf); - STree_Completions(root_tree, &cvar_tree, buf); - - return root_tree; -} - -const char *Cmd_CommandComplete(const char *buf) -{ - struct stree_root *root; - char *ret; - - root = Cmd_CommandCompletions(buf); - ret = STree_MaxMatch(root, buf); - Z_Free(root); - - return ret; -} diff --git a/common/cmd.h b/common/cmd.h index 5b2ff065..56fa3145 100644 --- a/common/cmd.h +++ b/common/cmd.h @@ -114,11 +114,6 @@ void Cmd_Init(void); void Cmd_AddCommand(const char *cmd_name, xcommand_t function); void Cmd_SetCompletion(const char *cmd_name, cmd_arg_f completion); -const char *Cmd_ArgComplete(const char *name, const char *buf); -struct stree_root *Cmd_ArgCompletions(const char *name, const char *buf); - -struct stree_root *Cmd_CommandCompletions(const char *buf); -const char *Cmd_CommandComplete(const char *buf); // called by the init functions of other parts of the program to // register commands and functions to call for them. @@ -132,12 +127,6 @@ int Cmd_Argc(void); const char *Cmd_Argv(int arg); const char *Cmd_Args(void); -// The functions that execute commands get their parameters with these -// functions. Cmd_Argv () will return an empty string, not a NULL -// if arg > argc, so string operations are allways safe. - -int Cmd_CheckParm(const char *parm); - // Returns the position (1 to argc-1) in the command's argument list // where the given parameter apears, or 0 if not present From 1e2464b57fa5611b4ea064f29ac5f3f7146068c5 Mon Sep 17 00:00:00 2001 From: libretroadmin Date: Fri, 22 Jul 2022 15:25:14 +0200 Subject: [PATCH 48/48] Cut down on some strlens --- common/host_cmd.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/common/host_cmd.c b/common/host_cmd.c index b9ed2c6a..3c9e7c93 100644 --- a/common/host_cmd.c +++ b/common/host_cmd.c @@ -691,7 +691,7 @@ Host_Say(qboolean teamonly) client_t *client; client_t *save; int i; - size_t len, space; + size_t len, space, p_len; const char *p; char text[64]; qboolean fromServer = false; @@ -717,16 +717,17 @@ Host_Say(qboolean teamonly) else sprintf(text, "%c<%s> ", 1, hostname.string); - len = strlen(text); + len = strlen(text); space = sizeof(text) - len - 2; // -2 for \n and null terminator - p = Cmd_Args(); + p = Cmd_Args(); + p_len = strlen(p); if (*p == '"') { /* remove quotes */ - strncat(text, p + 1, qmin(strlen(p) - 2, space)); - text[len + qmin(strlen(p) - 2, space)] = 0; + strncat(text, p + 1, qmin(p_len - 2, space)); + text[len + qmin(p_len - 2, space)] = 0; } else { strncat(text, p, space); - text[len + qmin(strlen(p), space)] = 0; + text[len + qmin(p_len, space)] = 0; } strcat(text, "\n"); @@ -759,6 +760,7 @@ Host_Say_Team_f(void) void Host_Tell_f(void) { + size_t p_len; client_t *client; client_t *save; int i, len, space; @@ -776,16 +778,17 @@ void Host_Tell_f(void) strcpy(text, host_client->name); strcat(text, ": "); - len = strlen(text); + len = strlen(text); space = sizeof(text) - len - 2; // -2 for \n and null terminator - p = Cmd_Args(); + p = Cmd_Args(); + p_len = strlen(p); if (*p == '"') { /* remove quotes */ - strncat(text, p + 1, qmin((int)strlen(p) - 2, space)); - text[len + qmin((int)strlen(p) - 2, space)] = 0; + strncat(text, p + 1, qmin((int)p_len - 2, space)); + text[len + qmin((int)p_len - 2, space)] = 0; } else { strncat(text, p, space); - text[len + qmin((int)strlen(p), space)] = 0; + text[len + qmin((int)p_len, space)] = 0; } strcat(text, "\n");