I am working on a project in which I analyze acceleration in the Source engine. Being that I have very basic knowledge of computer science, I am not very proficient in understanding the syntax.
The code that I am having trouble with is:
mv->m_vecVelocity[i] += accelspeed * wishdir[i];
I am confused as to what the " mv-> " is. Thank you for your help in advance.
I am getting the code from here: https://github.com/ValveSoftware/source-sdk-2013/blob/56accfdb9c4abd32ae1dc26b2e4cc87898cf4dc1/sp/src/game/shared/gamemovement.cpp
line 1745
In particular I am interested in knowing what mv is and what the -> is
-
\$\begingroup\$ To read C, learn C. \$\endgroup\$Anko– Anko2015年05月20日 15:29:59 +00:00Commented May 20, 2015 at 15:29
2 Answers 2
It's object instance of class CMoveData. It handles movement.
This can be found from code file you posted:
CMoveData *pMove
mv = pMove;
So, mv
is CMoveData
The ->
is the arrow operator. You can access class pointers using (for example) mv->m_nPlayerHandle.Get()
. This is somewhat hard area to understand. There are couple of good answers on stackoverflow about this
-
\$\begingroup\$ Thank you. I also learned that -> is a pointer. (as you can see I am a total noob) so I am assuming that mv->m_vecvelocity[i] gets the value of velocity of the movement? \$\endgroup\$lyna– lyna2015年05月20日 05:35:11 +00:00Commented May 20, 2015 at 5:35
-
\$\begingroup\$ Yes, that's how it should work. \$\endgroup\$Katu– Katu2015年05月20日 05:42:43 +00:00Commented May 20, 2015 at 5:42
-
\$\begingroup\$ Thank you very much for your help ^^, I couldn't give you an up arrow since I am new, but take this check mark instead. \$\endgroup\$lyna– lyna2015年05月20日 05:43:56 +00:00Commented May 20, 2015 at 5:43
Basically, "mv->" means "the following property of mv".
So, "mv->m_vecVelocity" means "the vector velocity property of the movedata".
"mv" represents kinematic state of a physical object.