Tuesday, July 14, 2009

Any decent c++ programmers out there to translate this code?

here is doom source code for a file called d_items. Need to know what it means. Is the variables = to a graphic or animation image? Notice upstate, downstate etc, are these animations of the character shooting the gun?





static const char


rcsid[] = "$Id:$";





// We are referring to sprite numbers.


#include "info.h"





#ifdef __GNUG__


#pragma implementation "d_items.h"


#endif


#include "d_items.h"





// PSPRITE ACTIONS for waepons.


// This struct controls the weapon animations.


//


// Each entry is:


// ammo/amunition type


// upstate


// downstate


// readystate


// atkstate, i.e. attack/fire/hit frame


// flashstate, muzzle flash


//


weaponinfo_t weaponinfo[NUMWEAPONS] =


{


{


// fist


am_noammo,


S_PUNCHUP,


S_PUNCHDOWN,


S_PUNCH,


S_PUNCH1,


S_NULL


},


{


// pistol


am_clip,


S_PISTOLUP,


S_PISTOLDOWN,


S_PISTOL,


S_PISTOL1,


S_PISTOLFLASH


},


{


// shotgun


am_shell,


S_SGUNUP,


S_SGUNDOWN,


S_SGUN,


S_SGUN1,


S_SGUNFLASH1


}

Any decent c++ programmers out there to translate this code?
There is no actual code here, it does nothing. These are purely structures containing definitions. Just as you would define a variable. It doesn't do anything until you reference it again and do something with it.
Reply:It's kinda chopped off, but what it looks like to me is a set of enumerations that define the state of a weapon animation. Without more of the code, I can't tell you if this is related to graphics or animations. My guess is that it describes the entire state of a weapon at a given point in time.
Reply:can't really tell by the code you posted. It's standard coding convention that those ALL_UPPERCASE variables are constants they never get changed. S_SGUN represents the same thing in this function as it will in any other function.


Judging by the comments about the upstate and downstate, it sounds like these are arrays holding the address or something similar to the animation code. They might be pointers to it.
Reply:This code is purely definitions, it does nothing. The images are stored somewhere else, probably in an external file.


No comments:

Post a Comment