Support PVS visibility changes for entities#507
Support PVS visibility changes for entities#507makindotcc wants to merge 2 commits intomarkus-wa:masterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #507 +/- ##
=======================================
Coverage 80.49% 80.50%
=======================================
Files 47 47
Lines 6367 6375 +8
=======================================
+ Hits 5125 5132 +7
- Misses 1029 1030 +1
Partials 213 213 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
pkg/demoinfocs/sendtables2/entity.go
Outdated
| if cmd&0x01 == 0 { | ||
| if cmd&0x02 != 0 { | ||
|
|
||
| if cmd&updateFlagLeave == 0 { |
There was a problem hiding this comment.
to reviewdog: it was already "complex" 😭
I can "flatten" it or extract handlers to other functions, that was on my mind first, but I thought people in go don't like too many functions.
There was a problem hiding this comment.
I will take a look when I'm on my PC 🙂
Personally I like having lots of functions in Go (I know this project doesn't look like it as a lot of it is REd and kinda done 1:1) but let's leave it for now until I had a chance to take a proper look 😄
There was a problem hiding this comment.
PS: reviewdog is more of a guideline than hard rules, so we don't always have to listen to it 😄
|
More about
Still no idea why they introduced these extra bits, since there already were soft "entity left". |
3745a42 to
9dcbb9c
Compare
9dcbb9c to
cba32f0
Compare
|
Hmm. So it is set to 1 on creation. Fine. |
In case the packet has PVS bits, we'll set it to 0 and 1 otherwise. I guess this is done for backwards compatibility. really raw decompilation of cs2 engine2.dll // [...]
no_pvs_vis_bits = packetEntities->_impl_.has_pvs_vis_bits_ == 0;
entityReadInfo->has_pvs_vis_bits1 = !no_pvs_vis_bits;
// [...]
ReadPacketEntities(clientStateIGuess, entityReadInfo);
// [...]ReadPacketEntities: // [...]
p_has_pvs_vis_bits1 = &entityReadInfo->has_pvs_vis_bits1
// [...]
p_UpdateFlags = &entityReadInfo->m_UpdateFlags;
*(_DWORD *)updateType = 3;
pNewEntity = &entityReadInfo->m_nNewEntity;
while ( 1 )
{
packet_has_pvs_vis_bits = *p_has_pvs_vis_bits1;
// [...]
cmd = *(_DWORD *)&entityReadInfo->m_UpdateFlags;
if ( (cmd & 4) == 0 )
{
if ( (cmd & 1) != 0 )
{
isNotDelete = (*p_UpdateFlags & 2) == 0;// https://github.com/markus-wa/demoinfocs-golang/blob/cba32f0669f0b9f055d711547ece1ea4f703d9f6/pkg/demoinfocs/sendtables2/entity.go#L578
*(_DWORD *)updateType = 1; // leave entity
if ( isNotDelete )
{
if ( qword_5742A0 )
{
v71 = (unsigned int)*v9;
v169 = 0;
v164 = 0i64;
entity = 0i64;
v166 = 0i64;
v167 = 0i64;
v168 = 0i64;
v170 = -1i64;
if ( (*(unsigned __int8 (__fastcall **)(__int64, __int64, __int128 *))(*(_QWORD *)qword_5742A0 + 208i64))(
qword_5742A0,
v71,
&v164) ) // get entity or smth
{
entity->m_bVisibleinPVS = packet_has_pvs_vis_bits == 0;
}
}
}
else
{
v70 = qword_5742A0;
*(&entityReadInfo->unsigned_intE0 + ((__int64)*v9 >> 5)) |= 1 << (*v9 & 0x1F);
memset(v161, 0, sizeof(v161));
v162 = 0;
v163 = -1i64;
if ( v70
&& (*(unsigned __int8 (__fastcall **)(__int64, _QWORD, __int128 *))(*(_QWORD *)v70 + 208i64))(
v70,
(unsigned int)*v9,
v161) )
{
*(_DWORD *)(*((_QWORD *)&v161[0] + 1) + 0x30i64) |= 0x8000u; // I didn't reverse this flag, but it hasn't changed in the "arms" update, so I assume this marks entity as deleted
}
}
// [...] |

In lately introduced update two extra bits that represents:
m_bVisibleinPVS) - a new thing i discovered nowPart of an decompiled
CClientState::ReadPacketEntities:Similar code is in
PreserveEnthandler.Looks like server does not use PVS for entities yet.
Im requesting this as a draft because I dont know what to do with
m_bVisibleinPVSyet - there isactivefield in Entity parser struct, but should we use it as representation ofm_bVisibleinPVS? I don't understand why there is additional bit for it when there already isupdateFlagLeaveandupdateFlagDelete.