I don't know if this message is even going to arrive at all, because my mail server has been really messed up recently. Here goes anyways. WARNING: This post is long and doesn't say anything interesting unless you like finding bugs in StudioModelRenderer.cpp :D
I've been doing some coding with CStudioModelRenderer to create motion blurred player models for TS 2.2, and I ran into a problem. The method I was using was to create a series of tempents, each with a special renderfx flag. When StudioDrawModel() is called on one of my special tempents, I call a special function called StudioDrawBlur(), which is basically StudioDrawPlayer() with some special functionalities to draw regular models that look like players. Then I started to run into intermittent crashes that involved m_pPlayerInfo being non-null for non-player studio models. In other words, StudioDrawModel() was being called with m_pPlayerInfo != NULL. This would create crashes when gait animations with crazy indexes (like 800 and 2429814, obviously corrupt values) were being applied to non-player models. After some considerable moaning about how the Half-Life engine sucks and I wish I had the source code and whatnot, I realized that the cause of this was that m_pPlayerInfo was not being nulled out in all situations when StudioDrawBlur() returns. Therefore, it would stick around with bogus values and corrupt the drawing of other studio models and crash the game. So, the moral of the story is: "Allways null out m_pPlayerInfo after drawing a model." Now, in stock HLSDK 2.3, there is one instance where m_pPlayerInfo is not nulled out before leaving StudioDrawBlur(), around line 1405 you can see two returns where there is a possibility of m_pPlayerInfo not being NULL. This doesn't seem to have caused any problems so far, as I don't know any any non-player models that have really been messed up because of an m_pPlayerInfo from the last model drawn still hanging around. Then again, it's probably not something you see in-game. So, Micheal Hobson twisted my arm and made me post here to make this known to hlcoders. ;) So, here goes: There's a bug in the SDK, m_pPlayerInfo should be set to NULL before the returns just below line 1405 in StudioModelRenderer.cpp Now, since the possibility of m_pPlayerInfo ever being not-null upon the exit of StudioDrawPlayer() is rather slim and the possibility of it hanging around to mess up the next model drawn or even crash the game is even slimmer, there's really nothing to worry about. However, this bug does become very important when you deal with people who try to modify the code here and end up with corrupted/crashing models. I'm talking to anybody who finds this post on Google five or ten years from now: Remember the moral of the story! Allways null out the member variables of CStudioModelRenderer before you finish drawing your model, or you could get some really messed up models! For those who have actually bothered to read this, thank you for your time, and I hope somebody actually understood what the hell I just said. -- Jorge "Vino" Rodriguez _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlcoders