Well I think you meant: if (Q_memcmp(&fog, &CFogController::s_pFogController->m_fog, sizeof(fog)))
which certainly makes more sense than what was there before. However that memcmp is still never going to return 0, because you're still memcmp'ing two objects with vtable entries, due to virtual function declarations from DECLARE_CLASS_NOBASE. Alternative to my patch, it'd probably make more sense to add a != operator to fogparams_t. (I didn't do so prior to my first post only because I was worried that header might be in cbase.h and cause a cascade recompile of the world.) Then if the != operator still wanted to use a memcmp hack, it could, but that landmine would be encaspulated in the fogparams_t struct more safely. At 2006/09/04 02:31 PM, Jay Stelly wrote: >This is a bug, the line should read: > if ( Q_memcmp( &fog, >CFogController::s_pFogController->m_fog, sizeof(fog) )) > >Jay > > >> -----Original Message----- >> From: [EMAIL PROTECTED] >> [mailto:[EMAIL PROTECTED] On Behalf Of >> [EMAIL PROTECTED] >> Sent: Monday, September 04, 2006 11:48 AM >> To: [email protected] >> Subject: [hlcoders] invalid fogcontroller memcmp? >> >> It's not clear to me what this code is trying to accomplish, >> but memcmping a struct is of course always dangerous and >> never a good idea. In this case, it's actually memcmping an >> inhereted class which is even worse, as the vtable pointer >> gets involved, causing the memcmp to seemingly never succeed. >> >> It's not clear though whether this memcmp might be masking >> some other buggy codepath, so I haven't added a KI yet. >> >> Anyone understand the CFogController? Do certain maps make >> use of this? >> >> Patch to use correct comparisons: >> >> >> --- src/dlls/fogcontroller.cpp 26 Aug 2006 21:24:29 -0000 1.2 >> +++ src/dlls/fogcontroller.cpp 4 Sep 2006 18:43:46 -0000 >> @@ -381,8 +381,22 @@ >> { >> if ( CFogController::s_pFogController ) >> { >> - if ( Q_memcmp( &fog, >> CFogController::s_pFogController, sizeof(fog) )) >> - { >> + if ( >> + fog.enable.Get() != >> CFogController::s_pFogController->m_fog.enable.Get() >> + || fog.blend.Get() != >> CFogController::s_pFogController->m_fog.blend.Get() >> + || fog.dirPrimary.Get() != >> CFogController::s_pFogController->m_fog.dirPrimary.Get() >> + || fog.colorPrimary.Get() != >> CFogController::s_pFogController->m_fog.colorPrimary.Get() >> + || fog.colorSecondary.Get() != >> CFogController::s_pFogController->m_fog.colorSecondary.Get() >> + || fog.start.Get() != >> CFogController::s_pFogController->m_fog.start.Get() >> + || fog.end.Get() != >> CFogController::s_pFogController->m_fog.end.Get() >> + || fog.farz.Get() != >> CFogController::s_pFogController->m_fog.farz.Get() >> + || fog.colorPrimaryLerpTo.Get() != >> CFogController::s_pFogController->m_fog.colorPrimaryLerpTo.Get() >> + || fog.colorSecondaryLerpTo.Get() != >> CFogController::s_pFogController->m_fog.colorSecondaryLerpTo.Get() >> + || fog.startLerpTo.Get() != >> CFogController::s_pFogController->m_fog.startLerpTo.Get() >> + || fog.endLerpTo.Get() != >> CFogController::s_pFogController->m_fog.endLerpTo.Get() >> + || fog.lerptime.Get() != >> CFogController::s_pFogController->m_fog.lerptime.Get() >> + || fog.duration.Get() != >> CFogController::s_pFogController->m_fog.duration.Get() >> + ) { >> fog = CFogController::s_pFogController->m_fog; >> return true; >> } >> >> _______________________________________________ >> To unsubscribe, edit your list preferences, or view the list >> archives, please visit: >> http://list.valvesoftware.com/mailman/listinfo/hlcoders >> >> > >_______________________________________________ >To unsubscribe, edit your list preferences, or view the list archives, please >visit: >http://list.valvesoftware.com/mailman/listinfo/hlcoders _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders

