From 6b7979fa72304e6d7d3afe6e558a82bb066c516c Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 31 Jul 2020 08:31:09 -0400 Subject: [PATCH] add note to zero out new mextra and oextra fields Closes #375 --- include/mextra.h | 18 +++++++++--------- include/obj.h | 14 ++++++++------ 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/include/mextra.h b/include/mextra.h index ca42f2bb7..50546787b 100644 --- a/include/mextra.h +++ b/include/mextra.h @@ -19,7 +19,9 @@ * file. * 3. Add a referencing macro at bottom of this file after the mextra * struct (see MNAME, EGD, EPRI, ESHK, EMIN, or EDOG for examples). - * 4. Create a newXX(mtmp) function and possibly a free_XX(mtmp) + * 4. Zero out the pointer to your struct in newmextra() in + * src/makemon.c. + * 5. Create a newXX(mtmp) function and possibly a free_XX(mtmp) * function in an appropriate new or existing source file and add * a prototype for it to include/extern.h. * @@ -39,7 +41,7 @@ * } * } * - * 5. Consider adding a new makemon flag MM_XX flag to include/hack.h + * 6. Consider adding a new makemon flag MM_XX flag to include/hack.h * and a corresponding change to makemon() if you require your * structure to be added at monster creation time. Initialize your * struct after a successful return from makemon(). @@ -47,17 +49,15 @@ * src/makemon.c: if (mmflags & MM_XX) newXX(mtmp); * your new code: mon = makemon(&mons[mnum], x, y, MM_XX); * - * 6. Adjust size_monst() in src/cmd.c appropriately. - * 7. Adjust dealloc_mextra() in src/mon.c to clean up + * 7. Adjust size_monst() in src/cmd.c appropriately. + * 8. Adjust dealloc_mextra() in src/mon.c to clean up * properly during monst deallocation. - * 8. Adjust copy_mextra() in src/mon.c to make duplicate + * 9. Adjust copy_mextra() in src/mon.c to make duplicate * copies of your struct or data on another monst struct. - * 9. Adjust restmon() in src/restore.c to deal with your + * 10. Adjust restmon() in src/restore.c to deal with your * struct or data during a restore. - * 10. Adjust savemon() in src/save.c to deal with your + * 11. Adjust savemon() in src/save.c to deal with your * struct or data during a save. - * 11. Zero out the pointer to your struct in newmextra() in - * src/makemon.c. */ /*** diff --git a/include/obj.h b/include/obj.h index 3feabe688..703f82792 100644 --- a/include/obj.h +++ b/include/obj.h @@ -389,7 +389,9 @@ struct obj { * 4. Add a testing macro after the set of referencing macros * (see has_oname(), has_omonst(), has_omailcmd(), and has_omin(), * for examples). - * 5. Create newXX(otmp) function and possibly free_XX(otmp) function + * 5. Zero out the pointer to your struct in newmoextra() in + * src/mkobj.c. + * 6. Create newXX(otmp) function and possibly free_XX(otmp) function * in an appropriate new or existing source file and add a prototype * for it to include/extern.h. The majority of these are currently * located in mkobj.c for convenience. @@ -410,14 +412,14 @@ struct obj { * } * } * - * 6. Adjust size_obj() in src/cmd.c appropriately. - * 7. Adjust dealloc_oextra() in src/mkobj.c to clean up + * 7. Adjust size_obj() in src/cmd.c appropriately. + * 8. Adjust dealloc_oextra() in src/mkobj.c to clean up * properly during obj deallocation. - * 8. Adjust copy_oextra() in src/mkobj.c to make duplicate + * 9. Adjust copy_oextra() in src/mkobj.c to make duplicate * copies of your struct or data onto another obj struct. - * 9. Adjust restobj() in src/restore.c to deal with your + * 10. Adjust restobj() in src/restore.c to deal with your * struct or data during a restore. - * 10. Adjust saveobj() in src/save.c to deal with your + * 11. Adjust saveobj() in src/save.c to deal with your * struct or data during a save. */