Make it easier to parse Input/Output entity data by adding PrepareOutput()
to the NSIO class
This commit is contained in:
parent
9e2b89e386
commit
24b00565e3
10 changed files with 31 additions and 42 deletions
|
@ -465,24 +465,19 @@ func_button::SpawnKey(string strKey, string strValue)
|
|||
break;
|
||||
/* input/output */
|
||||
case "OnPressed":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnPressed = strcat(m_strOnPressed, ",_", strValue);
|
||||
m_strOnPressed = PrepareOutput(m_strOnPressed, strValue);
|
||||
break;
|
||||
case "OnDamaged":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnDamaged = strcat(m_strOnDamaged, ",_", strValue);
|
||||
m_strOnDamaged = PrepareOutput(m_strOnDamaged, strValue);
|
||||
break;
|
||||
case "OnUseLocked":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnUseLocked = strcat(m_strOnUseLocked, ",_", strValue);
|
||||
m_strOnUseLocked = PrepareOutput(m_strOnUseLocked, strValue);
|
||||
break;
|
||||
case "OnIn":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnIn = strcat(m_strOnIn, ",_", strValue);
|
||||
m_strOnIn = PrepareOutput(m_strOnIn, strValue);
|
||||
break;
|
||||
case "OnOut":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnOut = strcat(m_strOnOut, ",_", strValue);
|
||||
m_strOnOut = PrepareOutput(m_strOnOut, strValue);
|
||||
break;
|
||||
/* compatibility */
|
||||
case "sounds":
|
||||
|
|
|
@ -241,8 +241,7 @@ func_guntarget::SpawnKey(string strKey, string strValue)
|
|||
m_strOnDeathLegacy = strValue;
|
||||
break;
|
||||
case "OnDeath":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnDeath = strcat(m_strOnDeath, ",_", strValue);
|
||||
m_strOnDeath = PrepareOutput(m_strOnDeath, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -258,8 +258,7 @@ trigger_changelevel::SpawnKey(string strKey, string strValue)
|
|||
break;
|
||||
case "OnLevelChange":
|
||||
case "OnChangeLevel":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnLevelChange = strcat(m_strOnLevelChange, ",_", strValue);
|
||||
m_strOnLevelChange = PrepareOutput(m_strOnLevelChange, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -251,12 +251,10 @@ trigger_hurt::SpawnKey(string strKey, string strValue)
|
|||
m_flNextDmg = stof(strValue);
|
||||
break;
|
||||
case "OnHurt":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnHurt = strcat(m_strOnHurt, ",_", strValue);
|
||||
m_strOnHurt = PrepareOutput(m_strOnHurt, strValue);
|
||||
break;
|
||||
case "OnHurtPlayer":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnHurtPlayer = strcat(m_strOnHurtPlayer, ",_", strValue);
|
||||
m_strOnHurtPlayer = PrepareOutput(m_strOnHurtPlayer, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -168,8 +168,7 @@ trigger_look::SpawnKey(string strKey, string strValue)
|
|||
m_flLookTime = stof(strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -169,15 +169,13 @@ trigger_multiple::SpawnKey(string strKey, string strValue)
|
|||
break;
|
||||
case "OnStartTouch":
|
||||
case "OnStartTouchAll":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnStartTouch = strcat(m_strOnStartTouch, ",_", strValue);
|
||||
m_strOnStartTouch = PrepareOutput(m_strOnStartTouch, strValue);
|
||||
break;
|
||||
case "OnEndTouchAll":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnEndTouchAll = strcat(m_strOnEndTouchAll, ",_", strValue);
|
||||
m_strOnEndTouchAll = PrepareOutput(m_strOnEndTouchAll, strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -113,12 +113,10 @@ trigger_once::SpawnKey(string strKey, string strValue)
|
|||
{
|
||||
switch (strKey) {
|
||||
case "OnStartTouch":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnStartTouch = strcat(m_strOnStartTouch, ",_", strValue);
|
||||
m_strOnStartTouch = PrepareOutput(m_strOnStartTouch, strValue);
|
||||
break;
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
|
||||
break;
|
||||
default:
|
||||
super::SpawnKey(strKey, strValue);
|
||||
|
|
|
@ -42,6 +42,7 @@ class NSIO
|
|||
|
||||
/* helper functions to allocate outputs */
|
||||
nonvirtual void(entity, string) UseOutput;
|
||||
nonvirtual string(string, string) PrepareOutput;
|
||||
nonvirtual string(string) CreateOutput;
|
||||
|
||||
/* whenever gamerules want entities to respawn */
|
||||
|
|
|
@ -117,6 +117,14 @@ NSIO::CreateOutput(string outmsg)
|
|||
return outname;
|
||||
}
|
||||
|
||||
string
|
||||
NSIO::PrepareOutput(string strOut, string strValue)
|
||||
{
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
strOut = strcat(strOut, ",_", strValue);
|
||||
return strOut;
|
||||
}
|
||||
|
||||
/* entities receive the inputs here and need to act on intype and data
|
||||
accordingly. this is just a stub for unknown event troubleshooting */
|
||||
void
|
||||
|
@ -278,24 +286,19 @@ NSIO::SpawnKey(string strKey, string strValue)
|
|||
#ifdef SERVER
|
||||
/* Input/Output system */
|
||||
case "OnTrigger":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnTrigger = strcat(m_strOnTrigger, ",_", strValue);
|
||||
m_strOnTrigger = PrepareOutput(m_strOnTrigger, strValue);
|
||||
break;
|
||||
case "OnUser1":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnUser1 = strcat(m_strOnUser1, ",_", strValue);
|
||||
m_strOnUser1 = PrepareOutput(m_strOnUser1, strValue);
|
||||
break;
|
||||
case "OnUser2":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnUser2 = strcat(m_strOnUser2, ",_", strValue);
|
||||
m_strOnUser2 = PrepareOutput(m_strOnUser2, strValue);
|
||||
break;
|
||||
case "OnUser3":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnUser3 = strcat(m_strOnUser3, ",_", strValue);
|
||||
m_strOnUser3 = PrepareOutput(m_strOnUser3, strValue);
|
||||
break;
|
||||
case "OnUser4":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnUser4 = strcat(m_strOnUser4, ",_", strValue);
|
||||
m_strOnUser4 = PrepareOutput(m_strOnUser4, strValue);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
|
@ -195,8 +195,7 @@ NSSurfacePropEntity::SpawnKey(string strKey, string strValue)
|
|||
/* Input/Output system */
|
||||
#ifdef SERVER
|
||||
case "OnBreak":
|
||||
strValue = strreplace(",", ",_", strValue);
|
||||
m_strOnBreak = strcat(m_strOnBreak, ",_", strValue);
|
||||
m_strOnBreak = PrepareOutput(m_strOnBreak, strValue);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue