Attnam / ivan

Iter Vehemens ad Necem - a continuation of the graphical roguelike by members of http://attnam.com
GNU General Public License v2.0
302 stars 42 forks source link

Clean up some code #540

Closed jakwings closed 5 years ago

jakwings commented 5 years ago

This may prevent some memory corruption. Also added more checks for NULL pointers.

jakwings commented 5 years ago

I feel bad for the unchecked memory allocation everywhere, just hope the NULL is never spawned. :( I always mix up C and C++, new and new(std::nothrow). :P

ryfactor commented 5 years ago

I decided to resolve the conflict due to #543 using github's resolve feature. @iology can you please check it is resolved correctly?

jakwings commented 5 years ago

No, git showed a confusing diff:

--- a/Main/Source/nonhuman.cpp
+++ b/Main/Source/nonhuman.cpp
@@ -959,7 +959,7 @@ truth vampirebat::SpecialBiteEffect(character* Victim, v2 HitPos, int BodyPartIn
     return false;
 }

-bool ChamaleonPolymorphRandomly(chameleon* c){
+bool ChameleonPolymorphRandomly(chameleon* c){
   if(!c->StateIsActivated(POLYMORPH_LOCK)){
     character* NewForm = c->PolymorphRandomly(100, 1000, 500 + RAND() % 500);
     if(NewForm==NULL)ABORT("chameleon PolymorphRandomly failed"); //means needs more checks

The actual function name is still ChamaleonPolymorphRandomly.