Doomdark’s Revenge

I sat down today to do some DDR code, first in a while, and spent 3 hours debugging some crashes!

Don’t you just hate it when you leave your code in a none working state! One was some bad XML, incorrect closing elements, and the other was some memory being trashed. The memory problem was due to my string class doing a shallow copy on assignment… well actually it wasn’t, but the compiler was for some reason not using my string assignment operator and instead doing it itself! Actually I have no idea what the compiler is doing at that point… grr…

It seems that the compiler differentiates between these two bits of code…


int example_function ( const string& source )
string new_string = source ;


int example_function ( const string& source )
string new_string ;

new_string = source ;

figure2 creates the correct constructor code for new_string and the correct assignment operator call for new_string = source. Figure one just makes new_string exactly equal to source. I think I must be missing something somewhere!

Technorati , , , , ,

Related Posts:

5 Replies to “Doomdark’s Revenge”

  1. Hey, great to see you working on a remake of one of my all time favourite games!
    Any chance to do the unreleased EYE of the MOON? Were any details of the 3rd part ever released?

  2. Really good to see you working on this great game again.

    Just out of interest, can you tell me how to start Lords Of Midnight with all the Lords?


  3. I supose this is the expected behavior, because you are declaring an doing an assigment in the same time.

    This is a compiler optimization to avoid calling the empty constructor and after another call to the assigment operator, witch is supose to have the same behavior than de copy construcor.

    To do this as you expected you must have an empy constructor, and have your ” string(const string& str) ” with the keyword “explicit” .

    You can avoid this declaring some or all the constructors with the keyword “explicit” , witch make them unavailable for ‘implicit convertions’.

    Keep up your excelent work.
    Nuno Custodinho.

  4. Hi Chris, Thought it was about time one of the Midnight M?MU gang sent a response, just to prove we do read it from time to time!! Keep up the good work, can’t wait to see it.

Comments are closed.

%d bloggers like this: