An interesting and hard to catch bug in WinROTT...

by Codewiz51 29. November 2008 09:07

Update: Check out my wiki page for the latest download of WinROTT

While moving the WinROTT file w_wad.c to w_wad.cpp, I ran into the most interesting bug. It was very difficult to catch. The problem was only apparent when the game was compiled in Release mode. After inserting a lot of logging statements, I was able to trace the problem down to this routine.

int     W_CheckNumForName (char *name)
{
        char    name8[9];
        int             v1,v2;
        lumpinfo_t      *lump_p;
        lumpinfo_t      *endlump;

// make the name into two integers for easy compares

        strncpy (name8,name,8);
        name8[9] = 0;                   // in case the name was a fill 8 chars
        strupr (name8);                 // case insensitive

        v1 = *(int *)name8;
        v2 = *(int *)&name8[4];


// scan backwards so patch lump files take precedence

        lump_p = lumpinfo;
        endlump = lumpinfo + numlumps;

        while (lump_p != endlump)
           {
           if ( *(int *)lump_p->name == v1 && *(int *)&lump_p->name[4] == v2)
              return lump_p - lumpinfo;
           lump_p++;
           }


        return -1;
}

More...

Tags: , ,

WinROTT

New WinROTT Release (#7)

by Codewiz51 27. November 2008 23:02

Update: Check out my wiki page for the latest download of WinROTT

I managed to move all the C files to C++. It's working! I've made some code improvements and cleaned up quite a bit. The download is here.

I am currently cleaning up all the extern declarations, trying to get everything into correct header files. It's a slow process. I am in the process of creating header files for all of the DirectMusic, Input, Video, etc. source files, as many of the extern declarations are needed for linker resolution.

Enjoy the game.

Tags: , ,

WinROTT

WinROTT Port

by Codewiz51 11. November 2008 22:58

Update: Check out my wiki page for the latest download of WinROTT

I've been able to make quite a bit of progress converting C modules to C++ modules in WinROTT. Most of the problems I encounter at this stage are missing link symbols. It is time consuming rearranging code and inserting extern "C" blocks. As always, testing consumes the most amount of time. I hope to have a significant (to me) release this weekend. I am down to about 30 modules that need converting. This is down from roughly 60 when I started.

I've had a couple of inquiries regarding my porting strategy. I employ a concept of "least dependency" when selecting modules to move over to C++ from C. In practice, you simply choose the last C module in the compile process. In theory, the last C module to compile has the fewest dependencies and should require the smallest amount of fixes for missing symbols. The occasionally doesn't work, but it's simple to implement. I try to never port more than one module between testing. For me, testing entails playing several game levels to verify code execution. When I complete the C to CPP migration, I want to implement some unit testing, which should significantly speed up future modifications.

When the migration is complete, I intend to scrub the code of extern "C" blocks and create proper header files for the modules. Currently, the code has a number of places where I simply threw in the function prototypes to get the code to compile and execute. You'll often see multiple prototypes for the same function included in the source. This is a result of not having proper header files that can be included as needed in source modules.

Tags:

WinROTT

Back To WinROTT

by Codewiz51 26. August 2008 22:11

Update: Check out my wiki page for the latest download of WinROTT

Summer is over. My son is off to college, my daughter has started her sophomore year in high school and the web site redesign is stable. It's time to crack open the WinROTT project and get started.

I am moving UserActor.c to a cpp file. There are some dependencies to resolve. This may take a couple of evenings while I get back into the swing of things. I am really feeling the need for some sort of .c and .cpp cross referencing tool. I still have somewhere around fifty .c files to convert. I'm looking forward to getting rid of all the extern "C" hacks I've had to use while the code is mixed between c++ and c. I was able to move a few functions outside of the extern "C" blocks. Whenever I am able to do this, it feels like progress is being made.

Tags:

WinROTT

Release 4 of WinROTT Source Code

by Codewiz51 17. July 2008 23:33

I managed to complete the port of rt_actor.c to rt_actor.cpp. There are some source code changes, and a lot of changes to header files so both C and C++ files will compile and link properly. The source code may be downloaded from my WinROTT page. Please let me know if you have any problems.

I will be taking a break from WinROTT for a couple of weeks to enjoy the summer with my children. I will be updating some porting notes in my wiki. I have some notes regarding function and enum declarations a developer needs to watch out for when porting from C to C++. Please have fun playing WinROTT! Enjoy the summer.

Tags: ,

WinROTT

Disclaimer

This blog represents my personal hobby, observations and views. It does not represent the views of my employer, clients, especially my wife, children, in-laws, clergy, the dog, the cats or my daughter's horse. In fact, I am not even sure it represents my views when I take the time to reread postings.

© Copyright 2008-2011