lower the code upkeep for mextra and oextra pointer additions
This commit is contained in:
+2
-2
@@ -19,8 +19,8 @@
|
|||||||
* file.
|
* file.
|
||||||
* 3. Add a referencing macro at bottom of this file after the mextra
|
* 3. Add a referencing macro at bottom of this file after the mextra
|
||||||
* struct (see MNAME, EGD, EPRI, ESHK, EMIN, or EDOG for examples).
|
* struct (see MNAME, EGD, EPRI, ESHK, EMIN, or EDOG for examples).
|
||||||
* 4. Zero out the pointer to your struct in newmextra() in
|
* 4. If your new field isn't a pointer and requires a special value
|
||||||
* src/makemon.c.
|
* on initialization, add code to init_mextra() in src/makemon.c
|
||||||
* 5. Create a newXX(mtmp) function and possibly a free_XX(mtmp)
|
* 5. Create a newXX(mtmp) function and possibly a free_XX(mtmp)
|
||||||
* function in an appropriate new or existing source file and add
|
* function in an appropriate new or existing source file and add
|
||||||
* a prototype for it to include/extern.h.
|
* a prototype for it to include/extern.h.
|
||||||
|
|||||||
+2
-2
@@ -389,8 +389,8 @@ struct obj {
|
|||||||
* 4. Add a testing macro after the set of referencing macros
|
* 4. Add a testing macro after the set of referencing macros
|
||||||
* (see has_oname(), has_omonst(), has_omailcmd(), and has_omin(),
|
* (see has_oname(), has_omonst(), has_omailcmd(), and has_omin(),
|
||||||
* for examples).
|
* for examples).
|
||||||
* 5. Zero out the pointer to your struct in newoextra() in
|
* 5. If your new field isn't a pointer and requires a special value
|
||||||
* src/mkobj.c.
|
* on initialization, add code to init_oextra() in src/mkobj.c.
|
||||||
* 6. Create newXX(otmp) function and possibly free_XX(otmp) function
|
* 6. Create newXX(otmp) function and possibly free_XX(otmp) function
|
||||||
* in an appropriate new or existing source file and add a prototype
|
* in an appropriate new or existing source file and add a prototype
|
||||||
* for it to include/extern.h. The majority of these are currently
|
* for it to include/extern.h. The majority of these are currently
|
||||||
|
|||||||
+11
-7
@@ -1038,19 +1038,23 @@ int mndx;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct mextra zeromextra = { DUMMY };
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_mextra(mex)
|
||||||
|
struct mextra *mex;
|
||||||
|
{
|
||||||
|
*mex = zeromextra;
|
||||||
|
mex->mcorpsenm = NON_PM;
|
||||||
|
}
|
||||||
|
|
||||||
struct mextra *
|
struct mextra *
|
||||||
newmextra()
|
newmextra()
|
||||||
{
|
{
|
||||||
struct mextra *mextra;
|
struct mextra *mextra;
|
||||||
|
|
||||||
mextra = (struct mextra *) alloc(sizeof(struct mextra));
|
mextra = (struct mextra *) alloc(sizeof(struct mextra));
|
||||||
mextra->mname = 0;
|
init_mextra(mextra);
|
||||||
mextra->egd = 0;
|
|
||||||
mextra->epri = 0;
|
|
||||||
mextra->eshk = 0;
|
|
||||||
mextra->emin = 0;
|
|
||||||
mextra->edog = 0;
|
|
||||||
mextra->mcorpsenm = NON_PM;
|
|
||||||
return mextra;
|
return mextra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+10
-4
@@ -67,16 +67,22 @@ static const struct icp hellprobs[] = { { 20, WEAPON_CLASS },
|
|||||||
{ 8, RING_CLASS },
|
{ 8, RING_CLASS },
|
||||||
{ 4, AMULET_CLASS } };
|
{ 4, AMULET_CLASS } };
|
||||||
|
|
||||||
|
static const struct oextra zerooextra = { DUMMY };
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_oextra(oex)
|
||||||
|
struct oextra *oex;
|
||||||
|
{
|
||||||
|
*oex = zerooextra;
|
||||||
|
}
|
||||||
|
|
||||||
struct oextra *
|
struct oextra *
|
||||||
newoextra()
|
newoextra()
|
||||||
{
|
{
|
||||||
struct oextra *oextra;
|
struct oextra *oextra;
|
||||||
|
|
||||||
oextra = (struct oextra *) alloc(sizeof (struct oextra));
|
oextra = (struct oextra *) alloc(sizeof (struct oextra));
|
||||||
oextra->oname = 0;
|
init_oextra(oextra);
|
||||||
oextra->omonst = 0;
|
|
||||||
oextra->omailcmd = 0;
|
|
||||||
oextra->omid = 0;
|
|
||||||
return oextra;
|
return oextra;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user