Category Archives: C#

C# development, including converting C++ code to C# code.

Another Good Chunk

Down to 4,539 errors.

Most of the rest of the errors to be squashed are going to be pretty involved, so I expect slower progress for a while.  Even so, we’re not too far from zero now.

Just 100

The error count is down 100 to 5,704.

I spent this week sending out the second and last issue of my fantasy/sci-fi magazine, All Possible Worlds. Although I run a dozen or so other websites, I might be able to put more time into the Basternae code without the magazine stealing my time. It is/was a pretty cool little magazine, but it’s a massive drain on the time and finances to run.

A Tiny Update

The error count is now down to 5,804.

Working on the Basternae code is a lot of fun, but I don’t get as much time to do it as I would like.  Even so, at least progress is being made.

Slow Moving

Haven’t been able to spend too much time on it lately, but the code is now down to 6,470 errors.

One thing I have been able to do a bit of lately is read a few more programming books. I’ll have to post a few comments on them one I finish what I’m reading now.

Errors: Halved

After a handful of changes, the number of errors is down to 7,173.  That’s less than half of what we had during the last report.

Most of the fixes were ‘invalid argument’ fixes (function calls for ref ClassName, but called without the ‘ref’).

Spatula? No Thanks.

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.

A Simple Solution

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

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

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

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.

No Real Progress

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.