diff --git a/Doxyfile b/Doxyfile index 1b48ef3a..58548cd9 100644 --- a/Doxyfile +++ b/Doxyfile @@ -879,6 +879,7 @@ INPUT = src/ \ Documentation/Building.md \ Documentation/Launching.md \ Documentation/Filesystem.md \ + Documentation/Classes.md \ Documentation/Materials/mat_overview.md \ Documentation/Materials/mat_commands.md \ Documentation/Materials/mat_vmap.md \ diff --git a/src/gs-entbase/server/button_target.qc b/src/gs-entbase/server/button_target.qc index 5a2d29be..b1da6a13 100644 --- a/src/gs-entbase/server/button_target.qc +++ b/src/gs-entbase/server/button_target.qc @@ -30,15 +30,17 @@ BUTTA_TEXON : Texture choices will be inverted in case multiple frames exist. This entity was introduced in Quake (1996). */ -enumflags +/** Spawnflags that button_target supports. */ +typedef enumflags { - BUTTA_USE, - BUTTA_TEXON -}; + BUTTA_USE, /**< Button has to be used by a player to trigger, instead of being shot. */ + BUTTA_TEXON /**< Button texture starts in the **ON** state. */ +} sf_button_target_t; class button_target:NSSurfacePropEntity { +public: void(void) button_target; virtual void(void) Respawn; diff --git a/src/gs-entbase/shared.src b/src/gs-entbase/shared.src index daf598d2..93824deb 100644 --- a/src/gs-entbase/shared.src +++ b/src/gs-entbase/shared.src @@ -5,7 +5,6 @@ #includelist shared/ambient_generic.qc shared/decals.qc -shared/spraylogo.qc shared/func_friction.qc shared/env_sprite.qc shared/env_bubbles.qc diff --git a/src/server/gamerules.h b/src/server/NSGameRules.h similarity index 99% rename from src/server/gamerules.h rename to src/server/NSGameRules.h index fe1b4144..c1e51d53 100644 --- a/src/server/gamerules.h +++ b/src/server/NSGameRules.h @@ -103,4 +103,4 @@ public: /* our currently running mode */ NSGameRules g_grMode; -#define CGameRules NSGamerules +#define CGameRules NSGameRules diff --git a/src/server/gamerules.qc b/src/server/NSGameRules.qc similarity index 100% rename from src/server/gamerules.qc rename to src/server/NSGameRules.qc diff --git a/src/server/traceattack.h b/src/server/NSTraceAttack.h similarity index 100% rename from src/server/traceattack.h rename to src/server/NSTraceAttack.h diff --git a/src/server/traceattack.qc b/src/server/NSTraceAttack.qc similarity index 100% rename from src/server/traceattack.qc rename to src/server/NSTraceAttack.qc diff --git a/src/server/defs.h b/src/server/defs.h index e0bff716..1a61da3e 100644 --- a/src/server/defs.h +++ b/src/server/defs.h @@ -15,7 +15,7 @@ */ #include "NSOutput.h" -#include "gamerules.h" +#include "NSGameRules.h" #include "sentences.h" #include "skill.h" #include "logging.h" @@ -23,7 +23,7 @@ #include "spawn.h" #include "weapons.h" #include "plugins.h" -#include "traceattack.h" +#include "NSTraceAttack.h" #include "footsteps.h" #include "route.h" diff --git a/src/server/include.src b/src/server/include.src index 908a8191..7e49d314 100644 --- a/src/server/include.src +++ b/src/server/include.src @@ -6,10 +6,10 @@ nodes.qc skill.qc sentences.qc spawn.qc -gamerules.qc +NSGameRules.qc client.qc server.qc -traceattack.qc +NSTraceAttack.qc footsteps.qc vote.qc weapons.qc diff --git a/src/shared/NSSpraylogo.h b/src/shared/NSSpraylogo.h new file mode 100644 index 00000000..f5f3c9a1 --- /dev/null +++ b/src/shared/NSSpraylogo.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2016-2022 Vera Visions LLC. + * + * 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. +*/ + +#ifdef CLIENT +/** This entity class represents a NSClientPlayer their spraylogo. */ +class NSSpraylogo:NSEntity +{ +private: + vector m_vecColor; + vector m_vecPosition; + vector m_vecAngles; + int m_iOwnerID; + string m_strName; + string m_m_strPath; + bool m_bInitialized; + bool m_bMonochrome; + +public: + void NSSpraylogo(void); + + virtual float predraw(void); + virtual void RendererRestarted(void); +}; + +void Spray_Parse(void); + + +const string g_spray_mat_1 = \ + "{\n" \ + "cull disable\n" \ + "polygonOffset\n" \ + "{\n" \ + "map $rt:%s\n" \ + "blendfunc GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR\n" \ + "rgbGen vertex\n" \ + "}\n" \ + "}"; + +const string g_spray_mat_0 = \ + "{\n" \ + "cull disable\n" \ + "polygonOffset\n" \ + "{\n" \ + "map $rt:%s\n" \ + "blendfunc blend\n" \ + "rgbGen vertex\n" \ + "}\n" \ + "}"; + +#else + +void Spray_RemoveAll(entity entOwner); +float Spray_SendEntity(entity ePEnt, float fChanged); +void CSEv_Spraylogo(void); +#endif diff --git a/src/gs-entbase/shared/spraylogo.qc b/src/shared/NSSpraylogo.qc similarity index 85% rename from src/gs-entbase/shared/spraylogo.qc rename to src/shared/NSSpraylogo.qc index 7d8119dd..ff75f305 100644 --- a/src/gs-entbase/shared/spraylogo.qc +++ b/src/shared/NSSpraylogo.qc @@ -14,123 +14,7 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#ifdef SERVER -void -Spray_RemoveAll(entity entOwner) -{ - for (entity eFind = world;(eFind = find(eFind, classname, "Spray"));) { - if (eFind.owner == entOwner) { - remove(eFind); - } - } -} - -float -Spray_SendEntity(entity ePEnt, float fChanged) -{ - if (clienttype(ePEnt) != CLIENTTYPE_REAL) - return (0); - - WriteByte(MSG_ENTITY, ENT_SPRAY); - WriteCoord(MSG_ENTITY, self.origin[0]); - WriteCoord(MSG_ENTITY, self.origin[1]); - WriteCoord(MSG_ENTITY, self.origin[2]); - WriteCoord(MSG_ENTITY, self.angles[0]); - WriteCoord(MSG_ENTITY, self.angles[1]); - WriteCoord(MSG_ENTITY, self.angles[2]); - WriteEntity(MSG_ENTITY, self.owner); - return (1); -} - -void -CSEv_Spraylogo(void) -{ - entity spray; - vector src; - vector co; - - src = self.origin + self.view_ofs; - - makevectors(self.v_angle); - traceline(src, src + v_forward * 128, FALSE, self); - - if (trace_fraction >= 1.0f) { - return; - } - - /* we only allow one active spray */ - Spray_RemoveAll(self); - - /* spawn the new one */ - spray = spawn(); - spray.classname = "Spray"; - spray.owner = self; - spray.solid = SOLID_NOT; - setorigin(spray, trace_endpos); - - /* calculate the rotation by taking our current view and mapping it - * against the surface we're looking at */ - makevectors([self.v_angle[0] * -1, self.v_angle[1], self.v_angle[2]]); - co = v_forward -(v_forward * trace_plane_normal) * trace_plane_normal; - - /* quick fix */ - if (trace_plane_normal[2] == 0) { - co = '0 0 1'; - } - - /* apply the angles and apply networking */ - spray.angles = vectoangles(co, trace_plane_normal); - spray.SendEntity = Spray_SendEntity; - spray.SendFlags = 1; - - Sound_Play(self, CHAN_VOICE, "player.spraylogo"); -} -#endif - #ifdef CLIENT -/** This entity class represents a NSClientPlayer their spraylogo. */ -class NSSpraylogo:NSEntity -{ -private: - vector m_vecColor; - vector m_vecPosition; - vector m_vecAngles; - int m_iOwnerID; - string m_strName; - string m_m_strPath; - bool m_bInitialized; - bool m_bMonochrome; - -public: - void NSSpraylogo(void); - - virtual float predraw(void); - virtual void RendererRestarted(void); -}; - - -const string g_spray_mat_1 = \ - "{\n" \ - "cull disable\n" \ - "polygonOffset\n" \ - "{\n" \ - "map $rt:%s\n" \ - "blendfunc GL_SRC_COLOR GL_ONE_MINUS_SRC_COLOR\n" \ - "rgbGen vertex\n" \ - "}\n" \ - "}"; - -const string g_spray_mat_0 = \ - "{\n" \ - "cull disable\n" \ - "polygonOffset\n" \ - "{\n" \ - "map $rt:%s\n" \ - "blendfunc blend\n" \ - "rgbGen vertex\n" \ - "}\n" \ - "}"; - void NSSpraylogo::RendererRestarted(void) { @@ -215,4 +99,77 @@ Spray_Parse(void) spSelf.m_m_strPath = sprintf("simg_%i_%d", spSelf.m_iOwnerID, spSelf.m_bMonochrome); spSelf.m_vecColor = stov(getplayerkeyvalue(spSelf.m_iOwnerID, "spraycolor")); } + +#else + +void +Spray_RemoveAll(entity entOwner) +{ + for (entity eFind = world;(eFind = find(eFind, classname, "Spray"));) { + if (eFind.owner == entOwner) { + remove(eFind); + } + } +} + +float +Spray_SendEntity(entity ePEnt, float fChanged) +{ + if (clienttype(ePEnt) != CLIENTTYPE_REAL) + return (0); + + WriteByte(MSG_ENTITY, ENT_SPRAY); + WriteCoord(MSG_ENTITY, self.origin[0]); + WriteCoord(MSG_ENTITY, self.origin[1]); + WriteCoord(MSG_ENTITY, self.origin[2]); + WriteCoord(MSG_ENTITY, self.angles[0]); + WriteCoord(MSG_ENTITY, self.angles[1]); + WriteCoord(MSG_ENTITY, self.angles[2]); + WriteEntity(MSG_ENTITY, self.owner); + return (1); +} + +void +CSEv_Spraylogo(void) +{ + entity spray; + vector src; + vector co; + + src = self.origin + self.view_ofs; + + makevectors(self.v_angle); + traceline(src, src + v_forward * 128, FALSE, self); + + if (trace_fraction >= 1.0f) { + return; + } + + /* we only allow one active spray */ + Spray_RemoveAll(self); + + /* spawn the new one */ + spray = spawn(); + spray.classname = "Spray"; + spray.owner = self; + spray.solid = SOLID_NOT; + setorigin(spray, trace_endpos); + + /* calculate the rotation by taking our current view and mapping it + * against the surface we're looking at */ + makevectors([self.v_angle[0] * -1, self.v_angle[1], self.v_angle[2]]); + co = v_forward -(v_forward * trace_plane_normal) * trace_plane_normal; + + /* quick fix */ + if (trace_plane_normal[2] == 0) { + co = '0 0 1'; + } + + /* apply the angles and apply networking */ + spray.angles = vectoangles(co, trace_plane_normal); + spray.SendEntity = Spray_SendEntity; + spray.SendFlags = 1; + + Sound_Play(self, CHAN_VOICE, "player.spraylogo"); +} #endif diff --git a/src/shared/defs.h b/src/shared/defs.h index fb9e3b6e..ad1e464e 100644 --- a/src/shared/defs.h +++ b/src/shared/defs.h @@ -59,6 +59,7 @@ string __fullspawndata; #include "NSMonster.h" #include "NSTalkMonster.h" #include "NSProjectile.h" +#include "NSSpraylogo.h" #include "../xr/defs.h" #include "NSClient.h" diff --git a/src/shared/include.src b/src/shared/include.src index 00a46b8e..48eb0fc1 100644 --- a/src/shared/include.src +++ b/src/shared/include.src @@ -27,6 +27,7 @@ player_pmove.qc propdata.qc surfaceproperties.qc NSMaterial.qc +NSSpraylogo.qc util.qc weapons.qc