Minor cleanups to some point entities and replace various usage of whichpack().

This commit is contained in:
Marco Cawthorne 2024-03-04 18:51:07 -08:00
parent 50cc1b6198
commit e2239a236f
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
13 changed files with 70 additions and 29 deletions

View File

@ -196,6 +196,8 @@ light::Spawned(void)
void
light::Respawn(void)
{
InitPointTrigger();
switch (serverkeyfloat("*bspversion")) {
case BSPVER_PREREL:
case BSPVER_Q1:

View File

@ -83,7 +83,7 @@ path_corner::path_corner(void)
m_iFired = 0i;
m_flSpeed = 0.0f;
m_flYawSpeed = 0.0f;
m_flWait = 1.0f;
m_flWait = 0.0f;
m_strOnPass = __NULL__;
}
@ -232,9 +232,13 @@ path_corner::PathPassTrigger(entity activatingEntity, triggermode_t triggerMode)
return;
}
EntLog("%S (%d) has passed us.", \
activatingEntity.classname, num_for_edict(activatingEntity));
UseOutput(this, m_strOnPass);
if (!m_strMessage)
/* never trigger "" */
if (!m_strMessage || m_strMessage == "")
return;
for (entity f = world; (f = find(f, ::targetname, m_strMessage));) {

View File

@ -212,7 +212,7 @@ path_track::GetPathTarget(void)
return targetname;
}
if (!target) {
if (HasTriggerTarget() == false) {
theTarget = targetname;
}

View File

@ -197,6 +197,8 @@ scripted_sequence::SpawnKey(string strKey, string strValue)
void
scripted_sequence::Respawn(void)
{
InitPointTrigger();
m_iEnabled = TRUE;
target = m_oldstrTarget;

View File

@ -108,6 +108,7 @@ trigger_relay::SpawnKey(string strKey, string strValue)
void
trigger_relay::Respawn(void)
{
InitPointTrigger();
m_iEnabled = TRUE;
m_iValue = FALSE;
}
@ -116,15 +117,15 @@ void
trigger_relay::Trigger(entity act, triggermode_t state)
{
if (m_iEnabled == FALSE) {
EntLog("trigger_relay (%s) has already been triggered", targetname);
EntLog("trigger_relay %S has already been triggered", targetname);
return;
}
if (HasSpawnFlags(TRLY_ONCE)) {
if (HasSpawnFlags(TRLY_ONCE) == true) {
m_iEnabled = FALSE;
}
m_iValue = TRUE;
EntLog("trigger_relay (%s) will trigger %s with state %d", targetname, target, m_iTriggerState);
EntLog("trigger_relay %S will trigger %S with state %d", targetname, target, m_iTriggerState);
UseTargets(act, m_iTriggerState, m_flDelay);
}

View File

@ -288,7 +288,8 @@ ambient_generic::UseNormal(entity act, triggermode_t state)
msg_entity = this;
multicast(origin, MULTICAST_PHS);
} else {
if not (whichpack(strcat("sound/", m_strActivePath))) {
/* if the file doesn't exist, assume it's a SoundDef */
if (FileExists(strcat("sound/", m_strActivePath)) == false) {
Sound_Play(this, CHAN_BODY, m_strActivePath);
} else {
sound(this, CHAN_BODY, m_strActivePath, m_flVolume, m_flRadius, m_flPitch);

View File

@ -90,20 +90,12 @@ void
NSGameRules::PlayerConnect(NSClientPlayer pl)
{
if (Plugin_PlayerConnect(pl) == FALSE)
bprint(PRINT_HIGH, sprintf("%s connected\n", pl.netname));
bprint(PRINT_HIGH, sprintf("%s^d connected.\n", pl.netname));
}
void
NSGameRules::PlayerDisconnect(NSClientPlayer pl)
{
bprint(PRINT_HIGH, sprintf("%s disconnected\n", pl.netname));
/* make the client 'unusable' */
pl.SetSolid(SOLID_NOT);
pl.SetMovetype(MOVETYPE_NONE);
pl.SetModelindex(0);
pl.SetHealth(0);
pl.SetTakedamage(DAMAGE_NO);
pl.SetTeam(0);
bprint(PRINT_HIGH, sprintf("%s^d disconnected.\n", pl.netname));
}
void

View File

@ -69,11 +69,6 @@ ClientConnect(void)
for (entity a = world; (a = find(a, ::classname, "player"));)
playercount++;
/* Force node init */
if (playercount == 1) {
Nodes_Init();
}
}
/** Called when a player leaves the server. At the end of the function the
@ -88,9 +83,16 @@ ClientDisconnect(void)
/* this will hide/remove the player from other clients */
player pl = (player)self;
pl.SetSolid(SOLID_NOT);
pl.SetMovetype(MOVETYPE_NONE);
pl.SetModelindex(0);
pl.SetHealth(0);
pl.SetTakedamage(DAMAGE_NO);
pl.SetTeam(0);
pl.Disappear();
pl.classname = "";
pl.flags = 0;
}
/** Called by the `kill` console command.
@ -148,7 +150,7 @@ PutClientInServer(void)
g_grMode.PlayerSpawn((NSClientPlayer)self);
/* handle transitions */
if (whichpack("data/trans.dat")) {
if (FileExists("data/trans.dat")) {
for (entity a = world; (a = findfloat(a, ::identity, 1));) {
NSEntity levelEnt = (NSEntity)a;
@ -159,6 +161,7 @@ PutClientInServer(void)
}
Plugin_PlayerEntered((NSClientPlayer)self);
bprint(PRINT_HIGH, sprintf("%s^d entered the game.\n", self.netname));
/* activate all game_playerspawn entities */
for (entity a = world; (a = find(a, ::targetname, "game_playerspawn"));) {
@ -402,6 +405,8 @@ init_respawn(void)
InitEnd();
Nodes_Init();
remove(self);
}
@ -695,7 +700,12 @@ SV_PerformLoad(float fh, float entcount, float playerslots)
#ifdef REEDICT
while ((e=nextent(e))) {
if (edict_num(1) != e)
remove(e);
NSEntity toRemove = (NSEntity)e;
if (toRemove.Destroy) {
toRemove.Destroy();
} else {
remove(e);
}
}
#else
e = world;
@ -738,8 +748,13 @@ SV_PerformLoad(float fh, float entcount, float playerslots)
loadent = (NSEntity)e;
self = eold;
} else {
NSEntity toRemove = (NSEntity)e;
NSError("Could not spawn %s", cname);
remove(e);
if (toRemove.Destroy) {
toRemove.Destroy();
} else {
remove(e);
}
self = eold;
continue;
}

View File

@ -34,7 +34,7 @@ Mapcycle_Load(string filename)
/* read the lines in, see if the map exists and define an enumerated alias */
while ((temp = fgets(fs_mapcycle))) {
if not (whichpack(strcat("maps/", temp, ".bsp")))
if (FileExists(strcat("maps/", temp, ".bsp")) == false)
continue;
localcmd(sprintf("alias m%i \"map %s;alias nextmap m%i\"\n", mapcount, temp, mapcount + 1i));

View File

@ -258,7 +258,7 @@ CSEv_CallVote_s(string text)
tokenize(text);
switch (argv(0)) {
case "map":
if not (whichpack(sprintf("maps/%s.bsp", argv(1)))) {
if (FileExists(sprintf("maps/%s.bsp", argv(1))) == false) {
sprint(self, PRINT_CHAT, sprintf("Map '%s' not available on server.\n", argv(1)));
break;
}

View File

@ -27,4 +27,11 @@ public:
/** Sets up a point entity trigger with no size. */
nonvirtual void InitPointTrigger(void);
virtual void DebugDraw(void);
#ifdef SERVER
private:
string m_strDebugTexture;
#endif
};

View File

@ -14,6 +14,14 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
NSPointTrigger::NSPointTrigger(void)
{
#ifdef SERVER
m_strDebugTexture = __NULL__;
#endif
}
void
NSPointTrigger::InitPointTrigger(void)
{
@ -22,11 +30,19 @@ NSPointTrigger::InitPointTrigger(void)
#ifdef SERVER
m_bEnabled = (m_bStartDisabled) ? false : true;
m_strDebugTexture = strcat("textures/editor/", classname);
#endif
}
void
NSPointTrigger::NSPointTrigger(void)
NSPointTrigger::DebugDraw(void)
{
#ifdef SERVER
R_BeginPolygon(m_strDebugTexture, 0, 0);
R_PolygonVertex(GetOrigin() + v_right * 16 - v_up * 16, [1,1], [1,1,1], 1.0f);
R_PolygonVertex(GetOrigin() - v_right * 16 - v_up * 16, [0,1], [1,1,1], 1.0f);
R_PolygonVertex(GetOrigin() - v_right * 16 + v_up * 16, [0,0], [1,1,1], 1.0f);
R_PolygonVertex(GetOrigin() + v_right * 16 + v_up * 16, [1,0], [1,1,1], 1.0f);
R_EndPolygon();
#endif
}

View File

@ -360,6 +360,7 @@ NSSurfacePropEntity::SpawnKey(string keyName, string setValue)
}
}
void
NSSurfacePropEntity::Pain(void)
{