Archive for July, 2007

Crawling Along

Monday, July 30th, 2007

Ever-so-slight progress this weekend - only 77 squished, making the total 14,810.

Spatula? No Thanks.

Friday, July 27th, 2007

The errors count is now down to 14,887. The more time I spend with C# the more I develop a pure loathing for raw C. Programming with C is like trying to chop down a tree with a spatula. Sure, you could probably manage to get your way through the tree, but it’s going to be a long, messy, painful task.

JetBrains ReSharper

Thursday, July 26th, 2007

I just finished a trial of JetBrains ReSharper 3.0, an add-on for Visual Studio 2005 designed for code analysis and refactoring.

ReSharper’s main feature is automatic code analysis. When you open a code file, it will scan for and higlight errors in your code and show an error count and error locations on the sidebar. It also goes a step further than the compiler by highlighting warnings and making suggestions for improving code.

For many errors, it will pop up a lightbulb icon if it knows how to fix the problem. If you click this icon, it will give you a menu that will let you perform a quick-fix.

ReSharper is smart enough to warn about places where a NullReferenceException could occur and overrides intellisense with its own, more thorough version. It gives more parameter information, shows more class info, and takes intellisense to the next level in general.

Visual Studio’s refactoring options are a neat addition, but not overwhelmingly useful. ReSharper extends them quite a bit to add a lot more functionality. I never really made much use of ReSharper’s refactorings since I prefer to change things by hand.

ReSharper has quite a few features that I couldn’t imagine ever using, such as code generation, code templates, and build script editing.

Although it add a lot of features and functionality to Visual Studio, in a project of any significant size (such as the 116k-line Basternae codebase) it causes a drastic slowdown, rendering my development machine nearly unusable at times, especially when code analysis is grinding away on a large code file. It’s true that the codebase I’m working on isn’t optimal (huge classes, bloated files, plenty of errors, etc), but that’s why I’m working on it in the first place — to fix all of that.

It’s an ambitious tool, but perhaps it’s trying to do too much. Maybe future versions will be faster, but right now it doesn’t add enough value to the development process to justify the $149 price tag.

If JetBrains removed everything but the code analysis functions for a “lite” version that sold for $49 I’d buy it in a heartbeat, but as it is now ReSharper doesn’t speed up my development process more than it slows it down. I’ll look at the 4.0 version when it comes out, but 3.0 isn’t for me.

Today’s Update

Saturday, July 21st, 2007

Just a few minor fixes for today. The error count is now down to 15,785.

A Simple Solution

Thursday, July 19th, 2007

This may only be a temporary solution until I find a better way, but for now we just number skills and spells in the constructor based on a reference count (static int _numSpells), essentially like this:

Spell()
{
SpellNumber = _numSpells;
++_numSpells;
}

This insures that nobody will get a duplicate and is a simple way to do things. More importantly it was quick to implement and didn’t break anything.

We’re now down to 16,156 errors.

Just A Little

Wednesday, July 18th, 2007

Small change in numbers: We’re now at 17,270 errors.

One of the problems I have to solve is to find a clean way to create global references to specific spells and skills without them actually being globals (which are ugly and disgusting and a horrible thing to put in code).

For example, in C, we used something like skill_bash which was just an integer referring to the skill number for bash. At runtime, when all the skills were initialized, the value of skill_bash would be set. It didn’t really matter what order skills were created in, because skill_bash would always point to the bash skill, whether it be number 35 or 350. The problem with this method is that is uses a global variable. It’s something that can be done in C#, but what, really, is the point of having a value containing the bash skill if you someday decide to take the bash skill out of the game. Then you have a bunch of useless code lying around doing nothing.

Not that bash will be removed from the game — this is something more likely to be an issue with spells.

I’ll have to look into reflection, delegates, etc. to see if there is some sort of common-sense way to handle this. I also have to keep in mind that someday I may want to convert the skill and spell tables to files that load at runtime and can be tweaked and adjusted without recompiling the entire codebase.

Since skills are so heavily involved in the game engine, it will be nearly impossible to decouple them completely.

A Productive Day

Monday, July 16th, 2007

The error count is now down below 20,000. Quite a bit, in fact. We’re now at 17,719. This puts us at about 4500 for the day.

A large portion of the vanquished errors were just array initialization fixes — converting from C-style to C#-style, which is quite different. I can’t give a definite date, but I suspect this phase of the conversion/rewrite will finish in mid-August.

Overriding the NOT (!) Operator

Sunday, July 15th, 2007

One thing commonly seen in C and C++ code is use of the NOT operator to check whether a struct or class pointer is set to NULL. For instance:

class value = NULL;
if( !value )
{
printf( “value is null” );
}

In C# code this results in an error because the compiler has no idea what “NOT” means on a class.  To be able to use this syntax in C# you have to override the ! operator, which is something I’ve never had occasion to do, AND that there are no easy-to-find code examples of. Luckily it’s just like overloading any operator in C#:

public static bool operator !( ClassType ct )
{
if( ct == null )
return true;
return false;
}

It works and it saves me the trouble of changing around 700 lines of code. We’re now down to 20,392 errors.

Visual Studio Becomes More Responsive

Sunday, July 15th, 2007

I mentioned in an earlier post that Visual Studio 2005 was gradually becoming more responsive as the error count decreased.

On my system, which is a Pentium D 2.66 GHz with 1GB of RAM, it starts becoming usable again at about 22,000 errors (we’re at 22,267 now).  That’s where the “type-a-character-and-wait” transitions into using the application in realtime.

One thing to keep in mind is that I have a trial installation of ReSharper (which I’ll post about once I’ve had more chance to evaluate), which slows things down considerably due to constant recompiling to find errors in realtime and excessive intellisense-ing above and beyond that which Visual Studio does.  Without Resharper I think I would have noticed responsiveness a bit earlier, but for now I have to say that 22,000 errors should be considered the upper limit of usability in a system like mine.

With more RAM it would probably be a bit better, and at this point it probably makes sense to upgrade to 2GB (RAM’s gone down quite a bit recently, probably due to Vista finally starting to sell).  I’ll have to add that to my grocery list.

No Real Progress

Wednesday, July 11th, 2007

Soooo… here’s my list of excuses:

1. I started a new job Monday (writing home automation software used to control lights, stereos, alarm systems, etc.)

2. I got married over the weekend.

3. I’m just plain tired right now.

So, not much progress in the past few days. The bug count is sitting at 22,677 right now. At that rate it would take about 396 days to finish. It won’t take that long.