From 9765f4662bf7b597caa283aa915b5803e8c7dcb6 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Thu, 3 Mar 2022 16:13:30 -0800 Subject: [PATCH] Organize cmd.qc and fix centerprints from being 'font ambigious'. Use the console font for now (like GoldSrc would, for example) --- src/client/cmd.qc | 180 +++++++++++++++++++++++++++++++------------ src/client/damage.qc | 14 +++- src/client/event.qc | 16 ++++ src/client/prints.qc | 2 +- 4 files changed, 156 insertions(+), 56 deletions(-) diff --git a/src/client/cmd.qc b/src/client/cmd.qc index 89268371..28e6bd49 100644 --- a/src/client/cmd.qc +++ b/src/client/cmd.qc @@ -14,6 +14,122 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +void +CMD_testPointLight(void) +{ + makevectors(getproperty(VF_ANGLES)); + traceline(getproperty(VF_ORIGIN), getproperty(VF_ORIGIN) + v_forward * 4096, FALSE, pSeat->m_ePlayer); + dynamiclight_spawnstatic(trace_endpos + (v_forward * -16), 1024, [1,1,1]); +} + +void +CMD_dev_modeltest(void) +{ + entity mt = spawn(); + mt.drawmask = MASK_ENGINE; + setmodel(mt, argv(1)); + setsize(mt, [0,0,0], [0,0,0]); + setorigin(mt, getproperty(VF_ORIGIN)); + mt.angles = getproperty(VF_ANGLES); + mt.angles[0] = mt.angles[2] = 0; +} + +void +CMD_dev_explode(void) +{ + makevectors(getproperty(VF_ANGLES)); + traceline(getproperty(VF_ORIGIN), getproperty(VF_ORIGIN) + v_forward * 4096, FALSE, pSeat->m_ePlayer); + FX_Explosion(trace_endpos); +} + +void +CMD_dev_sunpos(void) +{ + vector sunpos, sunang; + vector lepos, leang; + + makevectors(getproperty(VF_ANGLES)); + sunpos = v_forward * -1; + sunang = vectoangles(sunpos); + + makevectors(getproperty(VF_ANGLES)); + lepos = v_forward * -1; + leang = vectoangles(lepos); + leang[1] -= 180; + leang[0] *= -1; + + localcmd(sprintf("r_shadows_throwdirection %v\n", sunpos)); + print(sprintf("env_sun: pitch: %d; angle: %d\n", -sunang[0], sunang[1])); + print(sprintf("light_environment: sunangle: %d; pitch: %d\n", leang[1], leang[0])); +} + +void +CMD_dev_measure(void) +{ + static vector measurepos; + if (!vlen(measurepos)) { + measurepos = getproperty(VF_ORIGIN); + CSQC_Parse_CenterPrint(sprintf( "First marker set at\n%v", measurepos)); + } else { + CSQC_Parse_CenterPrint(sprintf("Distance: %d\n", vlen(measurepos - getproperty(VF_ORIGIN)))); + measurepos = [0,0,0]; + } +} + +void +CMD_vote(void) +{ + if (argv(1) == "yes") { + sendevent("VoteY", ""); + } else if (argv(1) == "no") { + sendevent("VoteN", ""); + } +} + +void +CMD_getpos(void) +{ + print(sprintf("setpos %v;setang -%v\n", getproperty(VF_ORIGIN), getproperty(VF_ANGLES))); +} + +void +CMD_setpos(void) +{ + localcmd(sprintf("cmd setpos \"%s\"\n", argv(1))); +} + +void +CMD_setang(void) +{ + setproperty(VF_CL_VIEWANGLES, stov(argv(1))); + setproperty(VF_ANGLES, stov(argv(1))); +} + +void +CMD_titles_test(void) +{ + GameMessage_Setup(argv(1), 0); +} + +void +CMD_way_menu(void) +{ + Way_Autoload(); + Textmenu_Call("WAY_MENU"); +} + +void +CMD_view_geomtest(void) +{ + Weapons_SetGeomset(sprintf("geomset %s %s\n", argv(1), argv(2))); +} + +void +CMD_player_geomtest(void) +{ + setcustomskin(pSeat->m_ePlayer, "", sprintf("geomset %s %s\n", argv(1), argv(2))); +} + /* ================= Cmd_Parse @@ -29,68 +145,31 @@ Cmd_Parse(string sCMD) { switch (argv(0)) { case "testPointLight": - makevectors(getproperty(VF_ANGLES)); - traceline(getproperty(VF_ORIGIN), getproperty(VF_ORIGIN) + v_forward * 4096, FALSE, pSeat->m_ePlayer); - dynamiclight_spawnstatic(trace_endpos + (v_forward * -16), 1024, [1,1,1]); + CMD_testPointLight(); break; case "dev_modeltest": - entity mt = spawn(); - mt.drawmask = MASK_ENGINE; - setmodel(mt, argv(1)); - setsize(mt, [0,0,0], [0,0,0]); - setorigin(mt, getproperty(VF_ORIGIN)); - mt.angles = getproperty(VF_ANGLES); - mt.angles[0] = mt.angles[2] = 0; + CMD_dev_modeltest(); break; case "dev_explode": - makevectors(getproperty(VF_ANGLES)); - traceline(getproperty(VF_ORIGIN), getproperty(VF_ORIGIN) + v_forward * 4096, FALSE, pSeat->m_ePlayer); - FX_Explosion(trace_endpos); + CMD_dev_explode(); break; case "dev_sunpos": - vector sunpos, sunang; - vector lepos, leang; - - makevectors(getproperty(VF_ANGLES)); - sunpos = v_forward * -1; - sunang = vectoangles(sunpos); - - makevectors(getproperty(VF_ANGLES)); - lepos = v_forward * -1; - leang = vectoangles(lepos); - leang[1] -= 180; - leang[0] *= -1; - - localcmd(sprintf("r_shadows_throwdirection %v\n", sunpos)); - print(sprintf("env_sun: pitch: %d; angle: %d\n", -sunang[0], sunang[1])); - print(sprintf("light_environment: sunangle: %d; pitch: %d\n", leang[1], leang[0])); + CMD_dev_sunpos(); break; case "dev_measure": - static vector measurepos; - if (!vlen(measurepos)) { - measurepos = getproperty(VF_ORIGIN); - CSQC_Parse_CenterPrint(sprintf( "First marker set at\n%v", measurepos)); - } else { - CSQC_Parse_CenterPrint(sprintf("Distance: %d\n", vlen(measurepos - getproperty(VF_ORIGIN)))); - measurepos = [0,0,0]; - } + CMD_dev_measure(); break; case "vote": - if (argv(1) == "yes") { - sendevent("VoteY", ""); - } else if (argv(1) == "no") { - sendevent("VoteN", ""); - } + CMD_vote(); break; case "getpos": - print(sprintf("setpos %v;setang -%v\n", getproperty(VF_ORIGIN), getproperty(VF_ANGLES))); + CMD_getpos(); break; case "setpos": - localcmd(sprintf("cmd setpos \"%s\"\n", argv(1))); + CMD_setpos(); break; case "setang": - setproperty(VF_CL_VIEWANGLES, stov(argv(1))); - setproperty(VF_ANGLES, stov(argv(1))); + CMD_setang(); break; case "callvote": sendevent("CallVote", "s", substring(sCMD, 9, strlen(sCMD)-9)); @@ -105,7 +184,7 @@ Cmd_Parse(string sCMD) CMap_Build(); break; case "titles_test": - GameMessage_Setup(argv(1), 0); + CMD_titles_test(); break; case "+attack2": pSeat->m_iInputAttack2 = TRUE; @@ -177,17 +256,16 @@ Cmd_Parse(string sCMD) HUD_SlotSelect(9); break; case "way_menu": - Way_Autoload(); - Textmenu_Call("WAY_MENU"); + CMD_way_menu(); break; case "_fnchat_msg": CSQC_Parse_Print(argv(1), PRINT_CHAT); break; case "view_geomtest": - Weapons_SetGeomset(sprintf("geomset %s %s\n", argv(1), argv(2))); + CMD_view_geomtest(); break; case "player_geomtest": - setcustomskin(pSeat->m_ePlayer, "", sprintf("geomset %s %s\n", argv(1), argv(2))); + CMD_player_geomtest(); break; default: return (0); diff --git a/src/client/damage.qc b/src/client/damage.qc index bf166751..7562bf3d 100644 --- a/src/client/damage.qc +++ b/src/client/damage.qc @@ -15,10 +15,16 @@ */ /* - * engine specific callback for when dmg_ fields are set on the client side. - * might want to replace it at some point? probably not... - * hence why 'take' is unused. - */ +================= +CSQC_Parse_Damage_New + +Our replacement for CSQC_Parse_Damage, which is now ignored. +We needed to be able to handle extra flags for damagetypes +and others. Can be overridden by mods by handling the EV_DAMAGE +event. +Currently will always return 1. +================= +*/ float CSQC_Parse_Damage_New(vector abs_pos, int take, int flags) { diff --git a/src/client/event.qc b/src/client/event.qc index b8a3c5cd..a5ab1361 100644 --- a/src/client/event.qc +++ b/src/client/event.qc @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2016-2022 Marco Hladik + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER + * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + void Event_Parse(float type) { diff --git a/src/client/prints.qc b/src/client/prints.qc index 5fd58a50..d1bb104e 100644 --- a/src/client/prints.qc +++ b/src/client/prints.qc @@ -58,7 +58,7 @@ Print_DrawCenterprint(void) for (int i = 0; i < (pSeat->m_iCenterprintLines); i++) { vecPos[0] = g_hudmins[0] + (g_hudres[0] / 2) - (stringwidth(pSeat->m_strCenterprintBuffer[i], TRUE, '12 12') / 2); - drawstring(vecPos, pSeat->m_strCenterprintBuffer[i], '12 12', [1,1,1], pSeat->m_flCenterprintAlpha, 0); + Font_DrawText_A(vecPos, pSeat->m_strCenterprintBuffer[i], pSeat->m_flCenterprintAlpha, FONT_CON); vecPos[1] += 8; } }