I can haz wryte permitsun?

No, I haven’t been hacked :) I’m just kicking it large with my current passion-du-jour, Playgate. I’m not going to post screenshots because it’s some of the worst coder art I’ve ever produced, but I’ve been fighting a running battle between two – what I am coming to realize are not quite compos mentis – installs of Visual Studio.

What works on my Vista and XP boxes at home arrives at the office with phantom menu bars and graphical displacements – but only on some dialogs. Bizzare experimentation began showing that elements of the corruption would transfer if I copied and pasted the content into a different file, or if I renumbered some of the IDs, etc, etc. I copied the dialog definitions from the resource file into a blank project only to find the order and particulars of the anomalies altered.

And before you suspect anything – up to this point there was no functionality or cleverness or funky stuff in the projects to leak memory, clobber stacks or anything.

No, that fun came later when I start using _stprintf_s without realizing that you have to remember to divide sizeof(foo) by sizeof(foo[0]); and in Debug builds, Visual Studio helpfully shows you when you are exposing your stack to clobberation and curropterment by taking the destination buffer size and overwriting it with 0xEFs. If you gave it the wrong buffer size, you’ll see bad things happen even if your tests are just printing “Hello World” into a 256kb buffer.

So if you’re passing sizeof() to something that’s expecting an element count, you’ll discover it early. In theory. Instead what happens is insane behavior. During one phase, my application would block at a mutex and Windows would come crawling to a halt. I tracked this down to a mutex block inside a Window-message handler just at the right point in the process to block all Window-signaling.

And what brings all this on?


One of the Microsoft security changes is to prevent applications from writing to files in the “Program Files” folder — that prevents stuff from tinkering with your copy of WoW. But they also reorganized numerous other folders and not just the folders but the methods for querying the folders. Now, if you want to write files to disk from your application, the right place to do it us under the user’s Documents folder. Easy enough to ask Windows where that is from inside an application, but lets say you have an older installer application for installing your app: It has a pre-Vista set of variables and path concepts. Oh, that’s so not going to be good.

I’ve been trying to Vistify Playgate; Playgate was written in 1999 in raw Win32 because, at the time, Microsoft’s Foundation Classes (MFC) were still help in scepticism by many (C++ was looked at the way folks were more recently looking at C#: Poorly performing and tending towards a lot of proprietary interfaces).

So for the last couple of weeks I have been tortuously bashing my brains out against the Playgate code. The underlying application code isn’t so bad, but the interface code would draw tears of pity from Frankenstein’s monster.  Playgate was supposed to be a lot more. It’s all that more that’s been the problem. In the last two weeks I’ve removed nearly 18,000 lines of code from Playgate down to it’s basic functionality — authenticate, patch and launch.

You’ve seen my .NET mockups, but unfortunately the call was for a non .NET version. Which mean’t falling back to MFC. In the quest to be able to write to a folder, I’ve had to turn to the technology Microsoft has just spent the last 3 years trying to phase out. It’s a sign of just how little love is lost over the passing of MFC that useful information on common problems has evaporated. You can spend hours searching Google for something as simple as “How do I load a bitmap from a file into a static control?”

Still, I’ve managed to Unicode it, integrate it into the game project (not into the game itself, its still a separate executable), make the interface user-friendly and left the door open for a proper art treatment, and the use of an embedded web browser will allow us to fall on HTML content for much of the app.

And that’s where I’m stuck at the moment: For some reason the embedded CExplorer2 browser keeps dissapearing. I guess one of my sprintf_s’s is still clobbering something. But, after pulling an all-nighter last night, I’ll be getting some rest this weekend, trying to get a little time in our game again, and cleaning my carpets with my new H2O mop.


I did’nt understand any of that (other than MS took out some bits that worked?)
But it made my head hurt.
Let it lay for the weekend and unwind :)

And that is why I gave up on windows development over 15 years ago.

That’s why I’m liking Cocoa/Touch so much. Building interfaces in Interface Builder is very pleasant.

Raymond Chen lost the war, although I’m not entirely sure that’s a bad thing.

The fact is going backward with MS is a bad idea for a one man shop. MFC was a mess for experts in it, an outsider trying to use it is in for a lot of headaches.

And next time you have a tough question, try Stack Overflow. I’ve yet to be disappointed by them.

Great links, Whale, esepcially the Chen link to Joel. Note that the article was written in 2004, and that it took another 4 years for “Longhorn” to surface, and when it finally did it wasn’t Longhorn, it was XP with Longhorn concepts tacked on, and because of that failure to ship the intended product, we’re still basically waiting on this API revolution.

But what I’ve seen of Windows 7 and what I’ve seen of Visual Studio 2010 do, infact, look very promising. Despite the hyperbole that some of their marketing folks have thrown at it, there is some real evidence of a refocus on making the product great rather than the assumption that they are indubitably working a great product.

I would like to see Microsoft completely rebase their operating system, but they need to do it in a grand swoop: a fresh operating system with a fresh API with no legacy support, with a prolonged conversion period during which their pre-existing XP and Vista products continue to be sold and supported so that developers have time to migrate.

And they need to use their own experience migrating to it to provide tools for the rest of us to do so afterwards.

I get excited about Apple because they have the finest damn Windows environment out there: because it’s commercial with real money thrown at it, both in the User Experience domain and in the technical elements.

MFC was definitely not a good choice for redeveloping Playgate but it was the constraint placed upon us. The work I’d done in my previous Playgate mockups in a few hours with .NET took me nearly a week in MFC because at every twisty little turn there was some conceptual nugget that I just hadn’t learned – or had forgotten since, truth be told, I’ve done a fair bit of MFC coding in the past :)

I still haven’t managed to figure out why the CExplorer2 OCX control periodically disappears. Sigh.

With Windows 7 Beta out, and Vista set to die a horrible death of neglect (Vista 64 still kills my game on gamer laptop); isn’t Windows 7 supposed to be XP compatible /and/ the way of the future?

Or will you code Playgate now and then know enough to adapt it to the /real/ future of Win 7?

Leave a Reply

Name and email address are required. Your email address will not be published.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

You may use these HTML tags and attributes:

<a href="" title="" rel=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <pre> <q cite=""> <s> <strike> <strong> 

%d bloggers like this: