-2
\$\begingroup\$

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

\$\endgroup\$
1
  • \$\begingroup\$ To read C, learn C. \$\endgroup\$
    – Anko
    May 20, 2015 at 15:29

2 Answers 2

2
\$\begingroup\$

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

Difference of pointer and reference variables

Array operator vs dot

\$\endgroup\$
3
  • \$\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
    May 20, 2015 at 5:35
  • \$\begingroup\$ Yes, that's how it should work. \$\endgroup\$
    – Katu
    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
    May 20, 2015 at 5:43
1
\$\begingroup\$

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.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged .