The pains of making an installer + uninstaller

I’ve been working on an installer/uninstaller for firesync 2. The installer is fairly straightforward, although it is quite a bit of work to set registry keys and make shortcuts, but overall it’s all fairly standard stuff. The one unique aspect of the firesync installer is that it is multi-part and actually consists of 2 executables. The first executable, the setup.exe file that will be distributed, is a native code binary + a zip archive. This program checks that the .NET Framework 2.0 is installed and extracts the zip archive to a folder in the user’s temporary directory. The zip archive contains the firesync executable and data files, but also contains another setup executable setupx.exe (a .NET executable). This executable is the real setup, as it shows/prompts the user for setup information (installation directory, whether or not to make a desktop icon, etc.), copies over the necessary files, makes program shortcuts, and writes registry entries so that firesync appears in the Add/Remove Programs list.

The reason for the multi-part installation is that it is much easier to design an interface using the WinForms designer in Visual C# compared to MFC, wxWidgets, etc. However, a .NET executable alone won’t suffice because users without the framework will just be given a cryptic error message (I think you get dialog about mscoree.dll not being found) and they’re not actually told that they need to install the framework.

(fyi, the native code executable is being done with wxDevC++)

Now making an uninstaller should be simple, your just deleting files and removing a couple of registry entries (in general, I avoid the registry and for firesync I’m only using it for the entry in Add/Remove Programs). Also, I think it’s rare that a user will uninstall the .NET Framework then try to uninstall firesync, so it’s pretty safe to make the uninstaller a .NET executable. However, there’s one big issue (and it’s a major pain in the ass) that pops up when it comes to making an uninstaller, how do you delete the uninstaller executable itself? I was lucky enough to stumble across this old Q&A from Microsoft Systems Journal. It’s a very inter… well to be honest it’s a very boring read (how interesting can deleting a file be?), but it’s important stuff. Ultimately, I went with the simplest method, and just used a batch file (although I haven’t played around with setting thread priorities as mentioned in the article; I’m not crazy about doing it and I’m not sure if it’s even worth it).

Finally, some important issues I ran across that was not mentioned in the article:

  • The directory your attempting to remove may be in use by the OS or another application. Another loop in the batch file should take care of this.
  • You can’t have the batch file in the directory your trying to delete (you’ll never be able to delete it as it’ll be in use by cmd.exe, you’ll have to manually kill cmd.exe to delete the folder and free the CPU). This is simple to solve, I just put the batch file in the user’s temp directory.


The dream of a standardized gaming platform

There was a small story last week about a guy from EA (Gerhard Florin) saying that dedicated consoles are bad for developers and consumers, and that an open, standard platform would be preferable to the current state of things. Ars Technica has a nice write up.

The idea is a bit out there given the current climate of competition between MS, Sony, and Nintendo, but it’s not without its merits.

I’m not going to reiterate what’s in the Ars Technica article, but a few things I thought about after reading it:

  • 1. A cheap machine that almost anyone can afford to pick up and that can play any game on the market is not a bad thing.

    Consider DVD players:
    • They’re cheap
    • A single platform and disc format = simplicity. (put in a dvd disc and it plays a movie)
    • Almost every movie can be found on a DVD disc.

    Now consider the typical console or gaming PC:
    • They’re expensive
    • A multitude of platforms and disc formats != simplicity. Think of it from the dumb consumer’s perspective: I want a game, I don’t want to consider my hardware platform choice or graphics card specs. (When you buy or rent a DVD, how often do you consider what type of DVD player your going to play it on?)
    • Unless the developer/publisher supports your platform, your screwed. As Nintendo continues to exclusively support its platforms and Sony and MS buy up studios to bring out exclusives for their platforms, the library of great games for a platform shrinks (due to less third-party developers and publishers), and in a weird sort of way I think this diminishes the value of the platforms themselves and weakens sales and exposure of the games which are exclusive to the platform (maybe Resistance: Fall of Man would have been much more popular if gamers weren’t forced to buy a $600 machine to play it, and maybe even Halo 3 would be even more insanely popular than it already is if it was released on multiple platforms). On the flip side, publishers which try to support all the platforms have a much harder time due to increasing development costs and technical hurdles; they are ultimately forced to take very little risk on new ideas or focus on platform exclusive titles.

  • 2. While a standardized platform could certainly be a hardware solution as EA sees it, a software solution is not a bad idea. If all consoles and PCs have a common platform on which to develop, porting a game would be significantly simplified. It doesn’t achieve the DVD-player-esque usability I outlined above, but it’s certainly better than what exists now.

  • 3. The lifetime for a console seems to be getting longer (the biggest selling console last christmas was the PS2), if the lifetime for the current “next gen” consoles are even longer, the PC may swing into the limelight. What’s a high-end PC today will become a cheap, ordinary PC soon enough and hardware-wise it would be more capable than any of the consoles. In this event, releasing PC games may become more attractive as there will be a very large install-base for the target platform.

Anyways, a lot of this may just be a lot of wishful thinking. Sony, Microsoft, and Nintendo won’t waste any time in trying to crush anything that challenges their market share.


Resistance: Fall of Man Lighting

I stumbled across an interesting article last night; it’s the creation of the lighting for Resistance: Fall of Man by Eric Gooch, a lighting artist at Insomniac Games. He also has a pretty cool blog and I totally agree with him about level bosses.


Atmosphere

I think it [System Shock 2] has an atmosphere. Not a lot of games have atmosphere, and that really draws people…

–Ken Levine (quoted from this article)



I’ve always felt that atmosphere is one of the most important, if not the most important, element of a game; it is ultimately what draws you in, encourages you to explore, gives you empathy or disdain for characters, and traps you in the virtual world for hours on end. However, the term itself is almost never used by gamers, reviewers or even designers. When a game is compelling and draws you in, its atmosphere is typically (by some incredibly bizarre mechanism) dubbed as “storyline”, “narrative”, or “plot.” Then it seems subsequent analysis focuses on the narrative elements of the game due to the false terminology. I think Half-Life is probably the biggest victim here. For years I’ve read forum posts and reviews about how Half-Life was incredibly popular and and able to push the bar due to its incredible story. However, if you take a step back, Half-Life had a pretty lackluster story: you open a portal to another dimension, there’s some mysterious dude following you around, you make your way to the lambda complex, you go to Xen, you kill the Nihilanth, you make some deal with the mysterious G-Man. You could probably write it all out along with all the dialog in a couple of pages. In terms of storytelling it doesn’t really go beyond first-person-shooters such as Quake or Doom. The bottom line is that Half-Life had a terrible storyline, it was the atmosphere that drew you in. A sense of chaos (after the resonance cascade), danger (fighting the extermination squads), and alienation (very literally, being in Xen). This is also what made games like Doom and Quake (and probably every other game on a “greatest ever” list) popular. In fact, even though I mention Half-Life, there are games which, in my opinion, are a lot more fun to play and do a much better job of creating a captivating atmosphere (e.g. System Shock 2, Deus Ex, Thief, Homeworld, … I can go on and on…).

(oh, and I’m specifically not making any criticisms of Half-Life 2 b/c I haven’t played it… yea, I know, it’s been a long time since it was released… maybe, I’ll pick up the orange box)

So what constitutes atmosphere? This and similar questions I constantly think about. (I’m currently writing a design document, but that’s besides the point). It’s very difficult to come up with a comprehensive list, as a lot of atmospheric elements (not only in games, but art, movies, etc.) just seem to come together naturally when looking at the finished product. In any case, here’s my attempt to dissect what constitutes atmosphere in a game:


  • Overall environment (weather [I’m so sad more games don’t have interesting weather fx], plant-life, terrain)

  • Architecture

  • Lighting (both globally, i.e. the sun, and locally), shadows, and colors (of light and textures)

  • Characters and dialog (not necessary, but if there are characters in the game and they can draw you in and you can connect with them in some way, I believe it adds to the atmosphere. For example, if you have to protect someone, and they’re represented as a genuinely innocent and vulnerable person, the game suddenly has an added sense of danger as well as heroism and empathy. On the other hand, if the character is an empty vessel, just there to fulfill the mandatory “escort mission,” the character adds nothing; perhaps he/she even takes from the atmosphere)

  • Sound effects (from the article linked to above, “You can’t [in System Shock 2] identify every single thing you can hear. Sounds, voices, things people are saying, things you can’t hear that are of unclear meaning. That creates a great deal of tension. It adds another element of mystery, another element of suspense.”)

  • Music (I think music adds a lot, I was really disappointed that Doom 3 and Quake 4 didn’t have music tracks, and they may have been better games with compelling music to drive the action forward; especially, given the repetitive nature of the missions.)

  • Animations (especially w/ humanoid characters, if it doesn’t look right, it’s usually instantly noticeable)

  • Level of detail, the higher the better (i.e. nuanced elements in any of the areas above. For example, the reload animations for certain weapons in counterstrike, the way clips or parts of a weapon are “slammed” in place, giving a sense of force [it’s been a long time since I played counterstike, I’m specifically thinking about the M4A1 or the Steyr AUG A1, I don’t remember which]. Similarly, the way Duke Nukem slams clips into the pistol. I could give a million example here in a variety of areas, but I’ll keep this short.)

  • Interactivity with environment, (in general) the higher the level, the better, (how the player or characters are able to interact with elements in the environment, from the largest to smallest scale. For example, can you shoot out a light? blow thru a wall? (ugh) push a crate? I say *in general* the higher the interactivity the better because in certain cases interactivity with the environment could destroy a lot of the preceding items in this list. For example, being able to move the sun, this can significantly screw up lighting, shadows, and colors of a level. For certain games, a real-time simple lighting or radiosity solution *might* offset the impact, but that very dependent on the game itself and the artists working on it.)

  • Non-linear or seemingly non-linear level design (A level doesn’t have to be non-linear to be good, and a non-linear level isn’t always a good thing, as it can confuse games and annoy them with what they consider to be pointless detours. However, painfully obvious linear level design is not a good thing and makes you painfully aware of the artificiality of the virtual world your in. For example, at certain points in Quake 4, once you’ve killed a bunch of Strogg, a door which was locked will magically open up.)

Anyway, that’s my list, for now, maybe I’ll modify as I learn new things, play more games, and reconsider certain items I’ve listed. In particular, I’m thinking a lot about Bioshock, and the concept of allowing the player to make moral choices.

oh, and if you haven’t figured it out, I hold System Shock 2 in very high regard 🙂


Java IDEs, The KMPlayer, and the uncooperative bedfellows

I do a lot of programming in Java. I’m required to. Being the non-Luddite that I am, I almost never write code outside of an IDE; I’ve experimented w/ most of the major Java IDEs:

  • Netbeans: Seems to have a nice set of features, but I dropped it pretty fast as it was horrendously slow. It seems to have to freeze the IDE and write to the HD after every few keystrokes or every time the code completion dialog had to popup; incredibly stupid behavior considering I always had a ton of memory free.
  • Eclipse: Probably the most popular IDE and it seems to be loved by the open source community. As with Netbeans, nice feature set, but not as pretty, in fact the interface is pretty ugly. It doesn’t have the nice “open on mouse-over-tab” side menus which I first fell in love w/ in Visual Studio and I always seemed to be fighting to see my code. Also, in terms of performance, Eclipse is no rabbit. It’s significantly better than Netbeans, but there is quite a bit of disk thrashing and its code completion is not very responsive. However, this was a very long time ago and a few months back I attempted to do an install of the latest version to see how far Eclipse had come, and I couldn’t get it installed; I remember some stupid error during setup, but can’t recall exactly what it was. I decided it wasn’t worth my time given my previous experience.
  • JCreator: The IDE I currently use. I’ve been using the LE version, and will likely get the Pro version depending on how much Java is in my future. The most notable feature missing from the LE version is code completion. Even w/o code completion, this is the best Java IDE I’ve come across, excellent performance and very responsive in all areas, stable, easy setup, and it has those nice side menus I mentioned above. It’s not as rich as Visual C#, but it does seem to take a lot from the Visual Studio family which is a very good thing.

These criticisms may no longer be valid or fair as I don’t actively keep up w/ new releases, but first impressions do matter.

Now for something completely different…

I’ve used Winamp for a long time. There’s really only a few other good media players around for Windows: Windows Media Player (function, but the thing’s a beast), iTunes (same crit as WMP, performance is also crappy on older machines), VLC (seemed like the greatest thing since sliced bread, but I installed it a while back and just couldn’t get it to play anything). I liked Winamp, but lost favor w/ it b/c of it’s poor support for video formats and, more than anything else, installing a new version of it placed a ton of AOL shortcuts everywhere (start menu, desktop, bookmarks, etc.).

In my search for a new media player, I discovered The KMPlayer a while back. It has great video support (there are a few color issues in the odd video here and there), great audio support (as long as it had mp3 and ogg I would have been happy, but it also played a bunch of old MOD files I had lying around), and a really nice interface. Just fuckin’ sweet.

Now, I have an incredibly weird situation on my system. KMPlayer and JCreator don’t play nice together. If they’re both open, some JCreator panels and menus are suddenly blank and don’t refresh and the side tabs panel is transparent, showing thru to the desktop. As for KMPlayer, I can’t open anything, clicking play (which plays the last file opened when nothing else has been loaded) does nothing, and certain items are mysteriously missing from the context menu. This hasn’t been a big deal for me, and I still use both JCreator and KMPlayer, but it would be nice if they worked together. Also, I have to wonder, what is the common component causing the conflict here, what would a media player and a java IDE both be using or trying to access concurrently? (assuming there is a conflict for a common component, which I suspect might be the issue here)

Independently both products are great, they just don’t seem to like each other.


firesync 2.0 coming soon

firesync 2.0 is just around the corner, there aren’t a whole lot of new features but it’ll be very stable and fast, with quite a few tweaks (delay in querying the network won’t lockup the UI) and improvements (graceful handling of conflicts, where copies of overwritten files are sent to the recycle bin). Perhaps the only major new feature it’ll have will be the ability to handle file deletions and renames, which seems to be an issue with a lot of sync apps. (A revised sync algorithm handles this, it’s not done using a service running in the background; I wanted to avoid a service at all costs as it can lead to some sticky situations, e.g. what happens if the service doesn’t start or is killed?)

One feature I would have liked, but may not make it in is “auto-sync,” which would have automatically sync’d files when your CPU was idle or its usage was very lower (I rejected the idea of a scheduling system b/c [a] users won’t take the time to do it and [b] it can be hard to guess when both machines setup to be sync’d would be free and connected to the network). It’s not difficult to implement, but I doubt I’ll have the time to properly test it (and for firesync, testing anything takes a huge amount of time and patience). However, it’ll definitely be in firesync 3.0.

Anyways, I’ll be talking more about firesync 2.0 when it’s released, for now, enjoy the new logo…

firesync 2.0 logo


Loop Burn

Here’s a small program I created and used to test the Single Core Launcher I talked about in my last post. It’ll run both cores in a dual-core processor at 100% (i.e. it’ll use 100% of a dual-core CPU). It might be useful to someone else.

LoopBurn -> download here!

Note: It is not generic and will not scale to processors with more than 2 cores, so this will only burn 2 cores if you have a quad core setup.

Oh, and it doesn’t do anything special it’s just incrementing variables. I was going to have it display something, but output to the console actually incurred a delay which lowered CPU/core usage.


Bad dual-core processor, no twinkie for you!

So, I’ve had a new desktop for a little over two weeks now, but stuck with my old one because there was just too much stuff that had to be transferred over or reinstalled and I didn’t have the time. This past weekend I finally made the move.

Now, my new desktop is cool high-end machine and of course that means it has a dual-core processor (well, I could have gotten a quad-core processor now, but the prices are insane). I got an Athlon 64 X2 6000+, which is pretty sweet. The comparable Intel chip (the E700 or whatever) does squeak ahead on the benchmarks, but not by a whole lot to justify its substantially higher price tag, even after the price cuts last month.

Overall I love my dual-cores, but yesterday I tried to run Deus Ex: Invisible War, just b/c I’ve never been able to run it will all the graphics setting cranked up, and it froze on the menu screen. So I rebooted (it was fullscreen, and I couldn’t get to task manager) and googled for solutions. Turns out it’s a pretty common problem, and the fixes were either:

a) Install dual-core optimizer from AMD (even though the dual-core optimizer seems interesting, my system was working fine and I wasn’t too crazy about installing additional stuff just to run this game; for the most part, I like to keep my system running the way it would for a typical user so I don’t write code with false expectations about the environment it’ll be running in.)

b) Hit Ctrl+Alt+Del before the menu screen shows up and set the thread affinity of the process to a single CPU core. (I played around with the config file, was able to start the game in a window, to prevent having to reboot if it froze again, and this little hack worked, but requires an amazing amount of speed and agility to set the thread affinity before the game loads the menu)


So the problem was obviously that the game couldn’t deal with multiple cores.

I had played around with thread affinity (just a fancy way of saying which processor a thread runs on) in code a while back and figured it might be possible for me to do a quick program to set the thread affinity automatically. The big question was would it be possible for a parent process to set the affinity of a child process, and would any processes spawned by that child process inherit the affinity? (The inheritance issue was especially important b/c DX:IW is started by running DX2.exe which executes DX2Main.exe, and you can’t execute DX2Main.exe without launching DX2.exe; there are quite a few other games that have similar setups). I guessed that affinity should be inherited and after a little bit of digging, a post in Raymond Chen’s blog confirmed my assumptions.

So, I set about making an application which would allow you to run a program on a single core of a multicore processor. It took a couple of hours. I did a nice interface using C#/Winforms and the code to actually launch the app and set the thread affinity was done in C++/Win32. I’m calling it Single Core Launcher, this app was small and simple, so no fancy name for this one.


single core launcher screenshot


Single Core Launcher -> download here!

(Extract all files to the same directory and run “Single Core Launcher.exe”; requires .NET Framework 2.0)

Oh, before making this I also found Mike Lin’s SMPSeesaw, which is pretty cool, but it only allows you to switch which core an app is running on after it’s already been started.


Preloading multiple images in javascript

I needed to preload a set of images for a nav. menu using javascript. I googled “javascript preload” and found a few sites with examples. I followed the examples and adapted the code to my problem… it didn’t work.

You’ll find many sites that have examples for how to preload a set of images in javascript, such as this one, this one, this one, etc… They all basically have the same code, which as far as I can tell doesn’t work because they all have the same simple mistake.

Here’s my code after following the examples from these sites:

function preloadMenuImages()
{
pl =
new Image();
imgurl =
new Array();
imgurl[0] =
"images/nav_products_highlight.jpg";
imgurl[1] =
"images/nav_services_highlight.jpg";
imgurl[2] =
"images/nav_location_highlight.jpg";
imgurl[3] =
"images/nav_about_highlight.jpg";
imgurl[4] =
"images/nav_contact_highlight.jpg";

var i=0;
for(i=0; i<5; i++)
{
pl.src = imgurl[i];
}
}

I tested with IE7 and after the browser executes this code, the only image preloaded is the one referred to by imgurl[4], the last element in the array. I loaded the page with IE6 and Firefox 2, and it was obvious that the preload function didn’t work in these browsers either.

It seems that simply assigning to the src member doesn’t load the image. You actually have to create an Image object then assign to the src member. So the correct code is:

function preloadMenuImages()
{
imgurl =
new Array();
imgurl[0] =
"images/nav_products_highlight.jpg";
imgurl[1] =
"images/nav_services_highlight.jpg";
imgurl[2] =
"images/nav_location_highlight.jpg";
imgurl[3] =
"images/nav_about_highlight.jpg";
imgurl[4] =
"images/nav_contact_highlight.jpg";

var i=0;
for(i=0; i<5; i++)
{
pl =
new Image();
pl.src = imgurl[i];
}
}

Simple enough.

Of course it’s simple after you find the bug. I spent about an hour trying to figure out why my original code wasn’t working; never thinking that there could be a mistake in the code I found online.


My adventures in web design

I’ve tended to avoid web design and web development work like the plague. I’ve done web stuff on and off since the early days of geocities; remember, back when everyone had a web page or fansite of some sort? There was even a web design class at my high school where students made sites and put them up on geocities. Then of course the geocities fad went away and, fast forward a few years, we now have myspace filling the void.

Anyways, there is a sense of satisfaction from building a website, but in the early days I never had much of an interest in it and if I needed something done, I’d just hack it out in Frontpage. In more recent times I’ve been put off by the annoyances encountered when supporting multiple browsers. Learning a language or a technique was one thing, but all too often web design work felt like learning hacks to get things to work in a certain browser (typically IE6). And of course, I still didn’t really have much interest in it because of all the game development stuff which always seemed much cooler.

However, there’s no denying that outside of a few specific fields (e.g. video games) in the computer programming world, most programming jobs now require some form of web development work and, more often than not, the projects being worked on are web-based services. So being the pragmatic person I am, I decided to invest some time in learning some web stuff over the past two months. I’ve spend a ton of time learning XHTML (well, ok, learning XHTML takes like 5 minutes) and CSS (via. web, book, and class at NYU), which is very interesting and so cool now that I realize that you can do more with it than just do the hover effect on hyperlinks. I’ve also spent some time on PHP, which is fairly simple to pick up for anyone that has some computer programming experience and while not the prettiest language, it is very useful and seems to do a great job of addressing web-specific issues. I’ve also spent some time on ASP.NET (which seemed natural for me, as I’m familiar with C# and the .NET Framework), but haven’t really done anything practical as yet. I’ll also be putting in some time with Javascript soon. Almost all my time for the rest of this month will be web development work, as I have 3 paid projects and 1 personal project (I’ll talk about this next month) that needs to be completed in early May.

So am I in love with web development now and given up on game development? No way! Game development is still #1 (the Zerospace solution is open and sitting patiently in my task bar), but web design and development is very interesting. I love the workout I’m getting in Photoshop (somehow or other, I think I’m becoming a competent graphic designer). I love styling in CSS and not having to fight with tables (bad Frontpage memories) is wonderful. And some of the stuff that can be done in Javascript seem to rival Flash (check this out). I’ll probably try to learn Flash and a bit of Actionscript next month, but I’m not too sure about that as yet. My one negative comment about doing web design is that browser inconsistencies still exist (from what I can tell, primarily with CSS support). IE7 seems fairly good when it comes to CSS standards compliance, but IE6 isn’t dead and probably won’t die anytime soon.

I was going to rant a bit about the rise of web applications and the decline of desktop application, but I’ll save that for another day.