Uh oh!
There was an error while loading. Please reload this page.
Update CScriptNetPropManager - #541
Conversation
| @@ -1249,19 +1289,21 @@ class CScriptNetPropManager | |||
| if ( pInfo->datatype == types::_VEC3 ) | |||
| arraysize *= 3; | |||
| if ( index < 0 || (unsigned int)index >= arraysize ) | |||
| if ( (unsigned int)index >= arraysize ) | |||
There was a problem hiding this comment.
is there a particular reason for removing these lower bound checks? index is provided by the user so this seems scary
There was a problem hiding this comment.
Unsigned cast of all negative numbers ([-1, -2147483648] -> [2147483648, 4294967295]) is always larger than the limit. It compiles into same code with less instructions (0-test) because arraysize is always non-zero.
If, on 64-bit, this function were to take a 64-bit signed index and this unsigned cast stayed 32-bit, values in the range [0x8000000000000000, 0x800000007fffffff] would truncate the sign bit and access out of bounds, but that's a lot of unlikely ifs.
I added some more assertions and a comment to inform future editors. This isn't a super important change though, impact of these 2 instructions is negligible
5034ee8 to
dbbb73cComparesamisalreadytaken
commented
Jun 12, 2026
Also added support for reading output values. Use the following regex to find all variables that are now possible to get: Script-only demo: localgame_globalvars=SpawnEntityFromTable("game_globalvars",null);game_globalvars.AcceptInput("GetCurtime","",null,null);assert(NetProps.GetPropFloat(game_globalvars,"m_OutCurtime")==Time());assert(NetProps.GetPropInt(game_globalvars,"m_OutCurtime")==-1);localmath_vector=SpawnEntityFromTable("math_vector",null);math_vector.AcceptInput("SetValue","1 2 3",null,null);assert(NetProps.GetPropVector(math_vector,"m_OutValue").IsEqualTo(Vector(1,2,3)));assert(NetProps.GetPropFloat(math_vector,"m_OutY")==2.0);locallogic_substring=SpawnEntityFromTable("logic_substring",null);logic_substring.AcceptInput("SetStartPos","6",null,null);logic_substring.AcceptInput("SetLength","5",null,null);logic_substring.AcceptInput("InValue","yberz vcfhz qbybe",null,null);assert(NetProps.GetPropString(logic_substring,"m_OutValue")=="vcfhz");locallogic_playerinfo=SpawnEntityFromTable("logic_playerinfo",null);logic_playerinfo.AcceptInput("GetPlayerInfo","",null,null);assert(NetProps.GetPropEntity(logic_playerinfo,"m_OutPlayerEntity")==Entities.GetLocalPlayer());print("done\n");Some more useful examples: localent=Entities.FindByClassname(null,"npc_grenade_frag");ent.ConnectOutput("OnDetonate_OutPosition","OnDetonate_OutPosition");ent.GetOrCreatePrivateScriptScope().OnDetonate_OutPosition<-function(){localpos= NetProps.GetPropVector(self,"m_OnDetonate_OutPosition");printl("OnDetonate_OutPosition "+pos);}localent=Entities.FindByClassname(null,"env_microphone");ent.ConnectOutput("SoundLevel","SoundLevel");ent.GetOrCreatePrivateScriptScope().SoundLevel<-function(){localvolume= NetProps.GetPropFloat(self,"m_SoundLevel");printl("SoundLevel "+volume);}localent=Entities.FindByClassname(null,"ai_goal_actbusy");ent.ConnectOutput("OnNPCStartedBusy","OnNPCStartedBusy");ent.ConnectOutput("OnNPCSeeEnemy","OnNPCSeeEnemy");ent.GetOrCreatePrivateScriptScope().OnNPCStartedBusy<-function(){localnpc= NetProps.GetPropEntity(self,"m_OnNPCStartedBusy");printl("OnNPCStartedBusy "+npc);}ent.GetOrCreatePrivateScriptScope().OnNPCSeeEnemy<-function(){localnpc= NetProps.GetPropEntity(self,"m_OnNPCSeeEnemy");printl("OnNPCSeeEnemy "+npc);}localent=player;ent.ConnectOutput("OnKilledEnemy","OnKilledEnemy");ent.GetOrCreatePrivateScriptScope().OnKilledEnemy<-function(){localvictim= NetProps.GetPropEntity(self,"m_OnKilledEnemy");printl("OnKilledEnemy "+victim);} |
The warning message is quite important, it's easy to make typos and not be aware of it ever.
Fixestf2classified/tf2classified-issue-tracker#485
PR Checklist
developbranch OR targets another branch with a specific goal in mind