Until today, I had made good use of the C#3 collection initializer syntax, but hadn’t thought to write a class that could accept it. Here’s the requirements: You must implement System.Collections.IEnumerable. The implementation is never actually used. For each set of types you want to use as an initializer, there must be a method Add() [...]
Content
File: March 2010
I finally got fed up with the level of brokenness in our RA-style shroud code last night, and implemented a real visibility system. We basically have an integer counter for each terrain cell now, which is incremented for each unit which can see the cell, and decremented when it leaves. The RA-style stuff is handled [...]
I’ve got rid of the old placeholder art for OpenRA’s naval unit tabs, and made the Allied aircraft tab a helicopter (more appropriate given that we’ve given all the helicopters to them!). One more thing to strike off the `polish` list; we’re looking vaguely respectable now:
Something that often comes up in UI programming is how to bind UI controls to backend data without writing a pile of code – and preferably without using reflection. Here’s an attempt (thwarted by the compiler, unfortunately) at capturing a C# ref parameter in closures so it can be passed around, stored, etc. It seems [...]
For those of us who try to build our own C compilers, preprocessor macros are a significant stumbling-block, especially for standard C, where macros are token-oriented, rather than text-oriented. The (old) naive approach is to just do a dirty text substitution, and then lex the result normally. This appears(!) to be what several production compilers [...]
I got sufficiently bored today that I decided to try out FizzBuzz. This is a common monkey-filter used to determine whether people can code at all. It’s stupidly trivial, and yet many supposed “programmers” can’t hack it. Here’s a quick (30 seconds) implementation in C: #include <stdio.h> char const * fmts[] = { "%d\n", "Fizz\n", [...]