From c1e4070b612b54c3055eeb4de395ff36571dc4da Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Sat, 2 May 2020 05:57:36 +0200 Subject: [PATCH] Made obituary code game-specific. --- src/client/cstrike/defs.h | 1 + src/client/cstrike/game_event.c | 3 ++ src/client/cstrike/hud.c | 1 + src/client/cstrike/init.c | 4 +++ src/client/cstrike/progs.src | 12 ++++---- src/client/entry.c | 6 ---- src/client/events.c | 4 --- src/client/gearbox/init.c | 3 ++ src/client/gearbox/progs.src | 9 +++--- src/client/hunger/init.c | 3 ++ src/client/hunger/progs.src | 5 ++-- src/client/poke646/init.c | 3 ++ src/client/poke646/progs.src | 6 ++-- src/client/rewolf/hud.c | 3 +- src/client/rewolf/init.c | 3 ++ src/client/rewolf/progs.src | 13 ++++----- src/client/scihunt/init.c | 3 ++ src/client/scihunt/progs.src | 3 +- src/client/tfc/init.c | 3 ++ src/client/tfc/progs.src | 2 +- src/client/valve/defs.h | 2 ++ src/client/valve/game_event.c | 3 ++ src/client/valve/hud.c | 1 + src/client/valve/init.c | 3 ++ src/client/{ => valve}/obituary.c | 40 +++++++------------------- src/client/valve/obituary.h | 48 +++++++++++++++++++++++++++++++ src/client/valve/progs.src | 3 +- src/shared/scihunt/w_cannon.c | 2 +- 28 files changed, 123 insertions(+), 69 deletions(-) rename src/client/{ => valve}/obituary.c (86%) create mode 100644 src/client/valve/obituary.h diff --git a/src/client/cstrike/defs.h b/src/client/cstrike/defs.h index 1b4dd24f..dadd491d 100644 --- a/src/client/cstrike/defs.h +++ b/src/client/cstrike/defs.h @@ -15,6 +15,7 @@ */ #include "hud.h" +#include "../valve/obituary.h" var int autocvar_cl_autoweaponswitch = TRUE; diff --git a/src/client/cstrike/game_event.c b/src/client/cstrike/game_event.c index 0b7c5340..ad7e8eb3 100644 --- a/src/client/cstrike/game_event.c +++ b/src/client/cstrike/game_event.c @@ -18,6 +18,9 @@ void Game_Parse_Event(float fHeader) { switch (fHeader) { + case EV_OBITUARY: + Obituary_Parse(); + break; case EV_SPARK: vector vSparkPos, vSparkAngle; vSparkPos[0] = readcoord(); diff --git a/src/client/cstrike/hud.c b/src/client/cstrike/hud.c index 5c89892b..2a549afc 100644 --- a/src/client/cstrike/hud.c +++ b/src/client/cstrike/hud.c @@ -619,6 +619,7 @@ HUD_Draw(void) /* little point in not drawing these, even if you don't have a suit */ Weapons_DrawCrosshair(); HUD_DrawWeaponSelect(); + Obituary_Draw(); Textmenu_Draw(); diff --git a/src/client/cstrike/init.c b/src/client/cstrike/init.c index 2be84bd2..1f41dd15 100644 --- a/src/client/cstrike/init.c +++ b/src/client/cstrike/init.c @@ -105,6 +105,8 @@ Client_Init(float apilevel, string enginename, float engineversion) registercommand("getout"); registercommand("negative"); registercommand("enemydown"); + + Obituary_Init(); } void @@ -116,6 +118,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/cstrike/progs.src b/src/client/cstrike/progs.src index 13cf1790..8b242eca 100644 --- a/src/client/cstrike/progs.src +++ b/src/client/cstrike/progs.src @@ -38,7 +38,7 @@ ../player.c ../../shared/cstrike/pmove.c ../../shared/pmove.c -predict.c +../cstrike/predict.c ../predict.c ../../shared/valve/fx_blood.c ../../shared/valve/fx_breakmodel.c @@ -83,7 +83,7 @@ predict.c ../../shared/cstrike/weapons.c ../../shared/valve/weapon_common.c ../cstrike/player.c -entities.c +../cstrike/entities.c ../entities.c ../fx_gunsmoke.c ../cstrike/cmds.c @@ -92,7 +92,6 @@ entities.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c @@ -101,9 +100,10 @@ entities.c ../cstrike/textmenu.c ../cstrike/init.c -crosshair.c -hud.c -hud_weaponselect.c +../cstrike/crosshair.c +../valve/obituary.c +../cstrike/hud.c +../cstrike/hud_weaponselect.c ../valve/scoreboard.c ../valve/input.c ../entry.c diff --git a/src/client/entry.c b/src/client/entry.c index c3cfbd97..40b91a18 100644 --- a/src/client/entry.c +++ b/src/client/entry.c @@ -81,7 +81,6 @@ CSQC_Init(float apilevel, string enginename, float engineversion) Titles_Init(); Sentences_Init(); Decals_Init(); - Obituary_Init(); } /* Rendering Caches */ @@ -112,7 +111,6 @@ CSQC_RendererRestarted(string rstr) Decal_Reload(); Game_RendererRestarted(rstr); FX_Init(); - Obituary_Precache(); } void @@ -315,7 +313,6 @@ CSQC_UpdateView(float w, float h, float focus) HUD_Draw(); } - Obituary_Draw(); Voice_DrawHUD(); Chat_Draw(); Print_Draw(); @@ -476,9 +473,6 @@ CSQC_Parse_Event(void) case EV_MUSICLOOP: Music_ParseLoop(); break; - case EV_OBITUARY: - Obituary_Parse(); - break; case EV_SPEAK: string msg; float pit; diff --git a/src/client/events.c b/src/client/events.c index e8f37e2a..de2461a9 100644 --- a/src/client/events.c +++ b/src/client/events.c @@ -68,27 +68,23 @@ Event_ProcessModel(float fTimeStamp, int iCode, string sData) pSeat->m_eMuzzleflash.alpha = 1.0f; pSeat->m_eMuzzleflash.scale = 0.25; pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones; - FX_Gunsmoke(gettaginfo(pSeat->m_eMuzzleflash, pSeat->m_eMuzzleflash.skin)); Event_EjectShell(); } else if(iCode == 5011) { pSeat->m_eMuzzleflash.alpha = 1.0f; pSeat->m_eMuzzleflash.scale = 0.25; pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 1; - FX_Gunsmoke(gettaginfo(pSeat->m_eMuzzleflash, pSeat->m_eMuzzleflash.skin)); //setmodel(pSeat->m_eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1))); Event_EjectShell(); } else if (iCode == 5021) { pSeat->m_eMuzzleflash.alpha = 1.0f; pSeat->m_eMuzzleflash.scale = 0.25; pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 2; - FX_Gunsmoke(gettaginfo(pSeat->m_eMuzzleflash, pSeat->m_eMuzzleflash.skin)); //setmodel(pSeat->m_eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1))); Event_EjectShell(); } else if (iCode == 5031) { pSeat->m_eMuzzleflash.alpha = 1.0f; pSeat->m_eMuzzleflash.scale = 0.25; pSeat->m_eMuzzleflash.skin = pSeat->m_iVMBones + 3; - FX_Gunsmoke(gettaginfo(pSeat->m_eMuzzleflash, pSeat->m_eMuzzleflash.skin)); //setmodel(pSeat->m_eMuzzleflash, sprintf("sprites/muzzleflash%s.spr", substring(sData, 1, 1))); Event_EjectShell(); } diff --git a/src/client/gearbox/init.c b/src/client/gearbox/init.c index e93bb549..0c9d6d90 100644 --- a/src/client/gearbox/init.c +++ b/src/client/gearbox/init.c @@ -27,6 +27,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -37,6 +38,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/gearbox/progs.src b/src/client/gearbox/progs.src index 61d0de7f..9830e016 100644 --- a/src/client/gearbox/progs.src +++ b/src/client/gearbox/progs.src @@ -43,7 +43,7 @@ ../../shared/valve/fx_spark.c ../../shared/valve/fx_impact.c ../npc.c -init.c +../gearbox/init.c ../../shared/gearbox/items.h ../../shared/valve/weapon_common.h ../../shared/gearbox/weapons.h @@ -76,19 +76,20 @@ init.c ../valve/player.c ../valve/entities.c ../entities.c -../fx_gunsmoke.c + ../valve/cmds.c ../valve/game_event.c ../events.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp + +../valve/obituary.c ../valve/hud.c -hud_weaponselect.c +../gearbox/hud_weaponselect.c ../valve/scoreboard.c ../valve/input.c ../entry.c diff --git a/src/client/hunger/init.c b/src/client/hunger/init.c index 2c29b0c6..527fd3cf 100644 --- a/src/client/hunger/init.c +++ b/src/client/hunger/init.c @@ -27,6 +27,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -37,6 +38,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/hunger/progs.src b/src/client/hunger/progs.src index fab6fc99..4a3787e2 100644 --- a/src/client/hunger/progs.src +++ b/src/client/hunger/progs.src @@ -77,17 +77,18 @@ init.c ../valve/player.c ../valve/entities.c ../entities.c -../fx_gunsmoke.c + ../valve/cmds.c ../valve/game_event.c ../events.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp + +../valve/obituary.c ../valve/hud.c ../valve/hud_weaponselect.c ../valve/scoreboard.c diff --git a/src/client/poke646/init.c b/src/client/poke646/init.c index 93ca42e3..208519f4 100644 --- a/src/client/poke646/init.c +++ b/src/client/poke646/init.c @@ -27,6 +27,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -37,6 +38,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/poke646/progs.src b/src/client/poke646/progs.src index 4813c88c..71db9489 100644 --- a/src/client/poke646/progs.src +++ b/src/client/poke646/progs.src @@ -61,18 +61,18 @@ init.c ../valve/player.c entities.c ../entities.c -../fx_gunsmoke.c + ../valve/cmds.c ../valve/game_event.c ../events.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp -../valve/hud.h + +../valve/obituary.c ../valve/hud.c ../valve/hud_weaponselect.c ../valve/scoreboard.c diff --git a/src/client/rewolf/hud.c b/src/client/rewolf/hud.c index 2e87aad3..5b15e8bc 100644 --- a/src/client/rewolf/hud.c +++ b/src/client/rewolf/hud.c @@ -273,7 +273,8 @@ void HUD_Draw(void) { g_hud_color = autocvar_con_color * (1 / 255); - + + Obituary_Draw(); Damage_Draw(); HUD_DrawHealth(); Weapons_DrawCrosshair(); diff --git a/src/client/rewolf/init.c b/src/client/rewolf/init.c index bcea2f04..a04b3db1 100644 --- a/src/client/rewolf/init.c +++ b/src/client/rewolf/init.c @@ -24,6 +24,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -34,6 +35,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/rewolf/progs.src b/src/client/rewolf/progs.src index 412a5085..32a6afbe 100755 --- a/src/client/rewolf/progs.src +++ b/src/client/rewolf/progs.src @@ -26,7 +26,7 @@ ../../gs-entbase/client.src ../../gs-entbase/shared.src -decore.cpp +../rewolf/decore.cpp ../sky.c ../music.c @@ -49,7 +49,7 @@ decore.cpp ../../shared/valve/fx_spark.c ../../shared/valve/fx_impact.c ../npc.c -init.c +../rewolf/init.c ../../shared/rewolf/items.h ../../shared/valve/weapon_common.h @@ -67,9 +67,8 @@ init.c ../../shared/valve/weapon_common.c ../valve/player.c -entities.c +../rewolf/entities.c ../entities.c -../fx_gunsmoke.c ../valve/cmds.c ../valve/game_event.c @@ -77,13 +76,13 @@ entities.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp -hud.c -hud_weaponselect.c +../valve/obituary.c +../rewolf/hud.c +../rewolf/hud_weaponselect.c ../valve/scoreboard.c ../valve/input.c diff --git a/src/client/scihunt/init.c b/src/client/scihunt/init.c index 7267cb82..4cb7a67a 100644 --- a/src/client/scihunt/init.c +++ b/src/client/scihunt/init.c @@ -24,6 +24,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -34,6 +35,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/scihunt/progs.src b/src/client/scihunt/progs.src index a1577641..f85a1276 100644 --- a/src/client/scihunt/progs.src +++ b/src/client/scihunt/progs.src @@ -75,7 +75,6 @@ init.c ../valve/player.c ../valve/entities.c ../entities.c -../fx_gunsmoke.c ../valve/cmds.c ../valve/game_event.c @@ -83,11 +82,11 @@ init.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp +../valve/obituary.c ../valve/hud.c ../valve/hud_weaponselect.c ../valve/scoreboard.c diff --git a/src/client/tfc/init.c b/src/client/tfc/init.c index ea066356..da3005bd 100644 --- a/src/client/tfc/init.c +++ b/src/client/tfc/init.c @@ -24,6 +24,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -35,6 +36,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/tfc/progs.src b/src/client/tfc/progs.src index 2dfe3ae3..faa5eb06 100755 --- a/src/client/tfc/progs.src +++ b/src/client/tfc/progs.src @@ -88,10 +88,10 @@ entities.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c +../valve/obituary.c ../valve/hud.c ../valve/hud_weaponselect.c ../valve/scoreboard.c diff --git a/src/client/valve/defs.h b/src/client/valve/defs.h index d95d25c8..08d267e3 100644 --- a/src/client/valve/defs.h +++ b/src/client/valve/defs.h @@ -14,6 +14,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include "obituary.h" + var int autocvar_cl_autoweaponswitch = TRUE; vector g_hud_color; diff --git a/src/client/valve/game_event.c b/src/client/valve/game_event.c index ec859501..274f87a3 100644 --- a/src/client/valve/game_event.c +++ b/src/client/valve/game_event.c @@ -18,6 +18,9 @@ void Game_Parse_Event(float fHeader) { switch (fHeader) { + case EV_OBITUARY: + Obituary_Parse(); + break; case EV_SPARK: vector vSparkPos, vSparkAngle; vSparkPos[0] = readcoord(); diff --git a/src/client/valve/hud.c b/src/client/valve/hud.c index e5cb7e4e..ce89e5a7 100644 --- a/src/client/valve/hud.c +++ b/src/client/valve/hud.c @@ -402,6 +402,7 @@ HUD_Draw(void) /* little point in not drawing these, even if you don't have a suit */ Weapons_DrawCrosshair(); HUD_DrawWeaponSelect(); + Obituary_Draw(); if (!(pl.g_items & ITEM_SUIT)) { return; diff --git a/src/client/valve/init.c b/src/client/valve/init.c index db391cab..7713ddd1 100644 --- a/src/client/valve/init.c +++ b/src/client/valve/init.c @@ -24,6 +24,7 @@ Comparable to worldspawn in SSQC in that it's mostly used for precaches void Client_Init(float apilevel, string enginename, float engineversion) { + Obituary_Init(); } void @@ -34,6 +35,8 @@ Client_InitDone(void) void Game_RendererRestarted(string rstr) { + Obituary_Precache(); + FX_Blood_Init(); FX_BreakModel_Init(); FX_Explosion_Init(); diff --git a/src/client/obituary.c b/src/client/valve/obituary.c similarity index 86% rename from src/client/obituary.c rename to src/client/valve/obituary.c index 0dcba486..cae469ae 100644 --- a/src/client/obituary.c +++ b/src/client/valve/obituary.c @@ -14,34 +14,6 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#define OBITUARY_LINES 4 -#define OBITUARY_TIME 5 - -/* imagery */ -typedef struct { - string name; /* name of the weapon/type, e.g. d_crowbar */ - string sprite; /* name of the spritesheet it's from */ - float size[2]; /* on-screen size in pixels */ - float src_pos[2]; /* normalized position in the sprite sheet */ - float src_size[2]; /* normalized size in the sprite sheet */ - string src_sprite; /* precaching reasons */ -} obituaryimg_t; - -obituaryimg_t *g_obtypes; -int g_obtype_count; - -/* actual obituary storage */ -typedef struct -{ - string attacker; - string victim; - int icon; -} obituary_t; - -static obituary_t g_obituary[OBITUARY_LINES]; -static int g_obituary_count; -static float g_obituary_time; - void Obituary_Init(void) { @@ -51,6 +23,11 @@ Obituary_Init(void) string line; vector tmp; + if (g_obtype_count > 0) { + return; + } + + print("Init Obituaries\n"); g_obtype_count = 0; i = 0; @@ -83,6 +60,7 @@ Obituary_Init(void) if (c == 7 && argv(1) == "640") { g_obtypes[i].name = substring(argv(0), 2, -1); g_obtypes[i].src_sprite = sprintf("sprites/%s.spr", argv(2)); + precache_model(g_obtypes[i].src_sprite); g_obtypes[i].sprite = sprintf("sprites/%s.spr_0.tga", argv(2)); g_obtypes[i].size[0] = stof(argv(5)); g_obtypes[i].size[1] = stof(argv(6)); @@ -99,8 +77,11 @@ Obituary_Init(void) fclose(fh); } -void Obituary_Precache(void) +void +Obituary_Precache(void) { + print("Precache Obituaries\n"); + for (int i = 0; i < g_obtype_count; i++) precache_model(g_obtypes[i].src_sprite); } @@ -231,5 +212,4 @@ Obituary_Parse(void) } Obituary_Add(attacker, victim, weapon, flags); - //print("Obituary received\n"); } diff --git a/src/client/valve/obituary.h b/src/client/valve/obituary.h new file mode 100644 index 00000000..e6b80c1a --- /dev/null +++ b/src/client/valve/obituary.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2016-2020 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. + */ + +#define OBITUARY_LINES 4 +#define OBITUARY_TIME 5 + +/* imagery */ +typedef struct { + string name; /* name of the weapon/type, e.g. d_crowbar */ + string sprite; /* name of the spritesheet it's from */ + float size[2]; /* on-screen size in pixels */ + float src_pos[2]; /* normalized position in the sprite sheet */ + float src_size[2]; /* normalized size in the sprite sheet */ + string src_sprite; /* precaching reasons */ +} obituaryimg_t; + +obituaryimg_t *g_obtypes; +int g_obtype_count; + +/* actual obituary storage */ +typedef struct +{ + string attacker; + string victim; + int icon; +} obituary_t; + +obituary_t g_obituary[OBITUARY_LINES]; +int g_obituary_count; +float g_obituary_time; + +void Obituary_Init(void); +void Obituary_Precache(void); +void Obituary_Draw(void); +void Obituary_Parse(void); diff --git a/src/client/valve/progs.src b/src/client/valve/progs.src index de8d19e4..6ca1a76c 100755 --- a/src/client/valve/progs.src +++ b/src/client/valve/progs.src @@ -73,18 +73,17 @@ ../valve/player.c ../valve/entities.c ../entities.c -../fx_gunsmoke.c ../valve/cmds.c ../valve/game_event.c ../events.c ../valve/view.c ../view.c ../damage.c -../obituary.c ../chat.c ../textmenu.c ../vgui.cpp +../valve/obituary.c ../valve/hud.c ../valve/hud_weaponselect.c ../valve/scoreboard.c diff --git a/src/shared/scihunt/w_cannon.c b/src/shared/scihunt/w_cannon.c index f61f7777..613f71f1 100644 --- a/src/shared/scihunt/w_cannon.c +++ b/src/shared/scihunt/w_cannon.c @@ -230,7 +230,7 @@ void w_cannon_hudpic(int s, vector pos, float a) weapon_t w_cannon = { - .name = "cannon", + .name = "handcannon", .id = ITEM_CANNON, .slot = 2, .slot_pos = 3,