Game Design, Programming and running a one-man games business…

Shadow maps make me happy

I’ve been watching some WW2 footage, some war movies, some video game footage, etc, in a bid to up the visuals in GTB. A lot of it can’t be seen in a screenshot, it’s moving-picture stuff really. UI’ve also been re-visiting how I make the shadow maps, and massively boosting their resolution. What PC’s can’t handle a 2048 square texture these days? None, I suspect.

Anyway here is a very sparse GTB screenshot:

And here is the same frame, but without the shadowmap.

I think the shadowmap wins by a huge margin. (It’s more apparent full screen, when moving and zooming etc. Combining a grayscale shadowmap with tileable textures not only makes it look less 2D, but it also means you can detect the repeating tile patterns a lot less. I am using a tile-based system to afford easy level design for players. I’m also toying with the idea of automatically generating the shadow maps from the player-designed paths. I think it’s quite doable, although non trivial, and better than expecting players to use photoshop etc.

Comments?

Anatomy of a gratuitous bug

I think I’ve fixed a bug in the gratuitous space battles campaign game. I’ll know ‘officially’ soon, but it fixed it on my machine :D Here’s what was involved.

A player complained of a random crash bug at the end of some campaign battles. I could not ever reproduce it, and back-and-forth emails began. Eventually, this awesome customer provided me with exact steps to reproduce, and all their save game data to let me replicate it. First run through and….. nothing. It was fine. Roughly every third run-through, in release mode it crashed…

Step 1! Hurrah! it actually crashes for me. This is 50% of the battle because then I *KNOW* that it is the games fault, and not the gamers system, or software. This is good, although frustrating news.

Step 2! It crashes in debug mode. This is another 25% of the battle because I can actually see what data is corrupt. As it turned out, the ‘firstfleet’ pointer in the code that assigns captured ships to the players winning fleet is clearly trashed. How did this happen?

Step 3… debugging. It transpires that the firstfleet pointer is accessed multiple times before this point, and after being initialised, confirming that it *must* have been valid, and becomes invalid between initialisation and access when adding captured ships to the fleet. This means we  can step through and watch what happens, if I break on initialisation..

Step 4 discovery! Stepping through the code confirms my suspicions. Once the battle ends, the code updates all the players fleets and removes ships that died in battle. Then, other code innocently picks the first of the players fleets in the battle, and initialises a dialog box listing the enemy captured ships that will be assigned to the fleet. Later…. *drum roll* it deletes any fleets that are now empty. Can you see the bug yet?

Step 5: fix! Changing the code that naievely picked the ‘first fleet’ to pick the first player fleet that still has some intact ships ensures that the later deletion of an empty fleet, and invalidation of the pointer is harmless, because the captured ships are now getting added to a surviving fleet. Bug probably fixed, pending the player confirming that a new exe fixes it.

Why did I not spot this bug six months ago? Well here is what has to happen.

  1. The player has to fight a battle with multiple fleets at once (common).
  2. He has to win (fairly common)
  3. The ai has to lose by the right margin to leave some captured ships (fairly rare).
  4. The winning player has to have enough ships removed from the *first* fleet in the list to have that fleet entirely deleted, despite winning overall. (pretty darned rare).

Simply put, This didn’t happen to me once in testing. It hasn’t happened to many players either, as I understand it. And if it has happened to you… I may have good news :D

Patch and games sizes, onlive, bandwidth…

So OnLive is out in the UK. I noticed quite a few people on the interwebs pointing out that they won’t sign up because, like me, they are on limited bandwidth internet plans.

I live out in the country, where there isn’t as much choice of ISP as the cities, and because my business needs the net, I need a rock solid connection with reliability and really good telephone support, so I end up paying over the odds. As a result, I have very reliable broadband, pretty fast, but bandwidth capped to 45 gig /month. I generally never hit the limit, but then when I see a game demo thats 2 gigs, I normally just skip it.

Something that made me think about this was Heroes of Stalingrad, Red Orchestra. This game is a tech-support trainwreck, with numerous bugs, random crashes, occasional dissapearing sound effects, rubber-banding, blah blah. Underneath it all is a great game.

The good news is they keep patching the game (although often introduce more bugs than they fix). The bad news is the patches are normally 400MB+. Apparently the developers claim this is the unreal engines fault in some way, although I find that hard to believe. Almost all bugs in a game are in the .exe and the exe is rarely >20MB.  Regular 400MB patches are crazy.

I definitely think that big games studios totally forget about the ‘bandwidth-challenged’. It’s one thing to release big patches. It’s another thing to release such patches several times a month, and require the patch for online play. If everyone MUST have the latest version, don’t insist on chewing up over a gig or two a month of peoples bandwidth limit just to play a game.

 

 

Starting on the challenge stuff…

GTB is such a huge game that I seem to veer into certain areas of it for weeks at a time, then veer back into other bits of it and think “did I write all this code?”

One of the features from Gratuitous Space Battles that I was very happy with, was the online challenge system. It was very popular. About 226 trillion billion zillion challenge games have been played (roughly). Obviously I want a similar system incorporated into GTB, and naturally I want to fix the things that were not perfect, which I identify as:

  • The challenge browser was not as good as it could be. You couldn’t filter out played/downloaded challenges.
  • Any challenge that had content, be it DLC or a mod that you did not have, could crash the game, and not be pre-filtered
  • The emotional connection between you and the challenger was limited. (Rarely used messaging, and rating, but not leaving comments etc).

I plan to fix all of this, but the middle one is the current one of interest.

GSB had a binary .gsb format for a challenge, which basically packed in binary data for the fleets designs, deployments and orders, and a little bit of data about the challenge (custom settings etc) and that was it.

GTB will use a new .pak format I’ve written that will behave a lot like a zip file. (no compression yet, sadly). It will be a folder full of stuff for each battle, all the enemies unit designs, the deployment timings for their attacking units (or initial deployments of defending units), and all of the data from the scenario file, down to the location of every tree, crate, barrel, barbed wire etc…

That makes a GTB challenge file slightly larger than before, but I can live with that. They are under 100k. How many custom maps in games are under 100k now? It also means you could move a few trees or change the texture of a single tile, and upload an existing scenario trivially without any inconvenience.

Anyway…. The upshot of this new file format is that theoretically, if I write the code for it, the format could include custom sounds, graphics etc. That means you could do a mod for GTB which included different textures for the terrain, and custom units, issue it as a challenge, and EVERYONE could play it, because the required content gets downloaded with it.

Sadly, there is no way to prevent dupes there, so if you have a custom tank texture, and upload 10 challenges, someone downloading all 10 gets the texture 10 times, but I think that’s not so bad. Only a minority of players are likely to issue or play modded challenges anyway.

The main thing is, my pak file format pakker and unpakker all works fine, so it’s another step along the path to having online play working. Now I need to replicate a lot of the GSB functionality (and improve on it).

Edit: I swapped out my code to use some zip code instead , after finding a zip wrapper that was extremely lightweight.

Slipped back into graphics tartery…

Ok, so for a few days I was working on graphics stuff for GTB, rather than gameplay. A lot of this came about because I wanted some GUI in there for issuing movement orders to units, and that is mostly done now. It also looks pretty nice too. The idea is not that you will generally be issuing movement orders, because like most tower defence games, your troops attack on rails, but sometimes there is branching, and you might want to ensure a certain unit goes left, or right, so you can give them an override-path manually. My current thinking is that in the GSB style challenge battles, this just isn’t an option, so it retains it’s hands-off style for that game mode.

A bit of profiling through a lot of doubt over my claimed 400% increase, and it looks like it’s a lot lower than that :( I blame Visual studio often not realising it needs to overwrite an exe when you change configuration. pesky Visual Studio…

However, my profiling binge did point out something scary (and slowdown-inducing) which was that in some average night-time battles, I was calling SetRenderTarget about 45-50 times a frame. Ouch! This was mostly stuff like searchlights and laser beams, that render to the screen, then also get rendered to a light map for later composition and niceness. They were handling this individually, rather than being batched as they are now, meaning less that 18 SetRenderTargets per frame, and several more of those will get optimised away soon. Many of them are essential, for selection UI, lightmaps, shockwave distortion and fog of war.

The ups-hot of this is that I can play fullscreen, release-build 1920 x 1200 res with all graphics options on, at night-time, with toggling night vision on and off, explosions, lasers, searchlights, unit selection UI and range GUI, path selection-GUI and the windowed UI for minimaps and unit selection…. All at a consistent unwavering 60 FPS, with fraps and windows media player running in the background.

OH YES.

Like GSB, this will be a game that really sells itself through videos of gameplay.
Also today I might peak at 9.5kwh of power from my little garden power-station. When that pesky tree gets trimmed, it should climb even higher. Oh yeah.