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

multithreading sound engine bug…

I have a bug thats driving me nuts. I use some middleware as a sound engine. its the ONLY middleware I use, and its bugging me. theoretically its easy to use, but I have a situation that it seems incapable of coping with.

With this middleware, I can play a sound, and request a pointer to track it. I can use that pointer later to adjust volume, or stop the sound, or query if its finished. For various reasons, I need to keep my own list of what sounds are currently playing. Thus I have a list of ‘current playing sounds’.

The middleware gives me a callback which triggers when a sound ends. This is handy, as I can then loop through the current playing sounds and remove it, keeping that list up to date. The sound engine runs in its own thread, so that callback triggers in a different thread to the main game.

This is where it goes wrong (but only on fast speed). I decide from the main game, to stop a sound. I firstly check that the sound exists within the current playing sounds. It does, so I access the sound pointer and tell it to stop. But wait! in-between those two events, the sound has expired naturally (in another thread) and the pointer has become invalid. CRASH.

using critical sections just produces race conditions, because stopping the sound has to happen in the same thread as the callback, and there are likely several sounds generating callbacks in the same frame (on fast speed) as the one I’m trying to stop, and it reaches a deadlock. It’s a real pain.

One solution is to make all such sounds loop (and thus never expire naturally, and rely on me killing them, which should work ok) and I thus never hit this problem. Another is to just not stop them prematurely (looks weird). I have currently hacked it, but I suspect the 1.18 build still has this issue manifesting itself as a 4x speed lots of beam-lasers crash.

Another solution is to tell the sound engine to run single threaded but that seems horrendously hacky.

I may have to try the always-loop solution. One day I’ll write my own sound engine again.

 

Gratuitous Space Battles Beta 1.18 update

So hey, another week, another update to the GSB2 beta. Hurrah! When I look back at the change list there is actually a ton of cool stuff in this update. If I had the time, I’d make a video explaining it all…but I don’t so here it is in lovingly crafted text form!

The complete changelist is here

But the highlights are…

  • All Unlock costs are 50% higher, so you don’t ‘progress’ stupidly fast any more (hopefully!)
  • In some cases (the first race for now) ships come with a pre-defined ‘default’ visual appearance rather than just a blank hull, because some people were too keen to fight than design ships, and this way those ships still have decent visual appeal.
  • Steam workshop support, and a general implementation of mod browsing and creation and toggling is done now, although the workshop is likely inactive for everyone at the moment.

tease

  • Some cool new sound effects :D.
  • You can now type in exact values when adjusting stuff on the ship design screen. (A feature much requested)
  • A better end-battle dialog to explain how honor works. (The actual dialog has the right numbers in :D)

honor_better

  • Sub-deployments are in! (although a tad buggy). You can now save and load sub-deployments and use them in any mission, allowing you to have predefined formations of ships to use as the core of a fleet.

subdeployments

Obviously more patches will come, although things are likely to stall slightly for GDC and then Rezzed, but hopefully around that time I’ll get the translations done and maybe the mac/linux port, so even if the release date moves into April, it will be a decent release with lots of cool stuff. Trading card artwork is being done right now, along with extra module graphics. I’m reading all the player feedback and implementing tons of tiny fixes for stuff which people point out. In the meantime, it really helps if people up-vote any videos/articles they see about the game, all coverage is appreciated, and sharing this blog post/tweeting it is much appreciated too :D

If you are at GDC I am in two talks. And do come along and try out both GSB2 and Big Pharma at Rezzed in London if you can.

 

 

More Crunch than crunch itself

Gah! this may be the year I dump firefox, its bugginess and post-eating crashiness is finally starting to try my patience… Anyway I am in crunch mode. I know that in theory indie devs do not crunch, but GSB2 was originally scheduled for a December 2014 release. That became January, January became February and now I am targeting the end of March. And although that sounds four weeks ago, in game-shipping terms it is only a few days of work away and this is why…

I want to be PC+Mac+Linux capable on release day and I need time for the port to be done.

I want to have *at least* French + German versions on day one and they need time to do the translations…

blog

Plus…I have a bunch of ideas/tweaks/improvements from the beta to put in *before* I declare it ready for any of that. And then… even more timing related angst because I am going to both GDC and Rezzed between now and release. MADNESS. (I have to attend both, because I’m speaking at GDC and also showing off GSB2 and Big Pharma at Rezzed…). This might work out ‘ok’ because with luck, people will be working on translations and/or mac builds whilst I’m at these things, which is at least something that can get done while I’m busy smiling at people at shows.

Anyway…

There is also some other stuff to dop, such as extra ship module graphics for variants and also steam trading card stuff. And of course a lot of testing and general QA/Polishing. Even as I type this, I’m starting to think *cliff you are nuts…it will not ship in March, FFS get a grip and let it slip a few more weeks*.

Arggh,

Anytway, if you can’t wait (and who can!) you can grab the current build of GSB2 when you pre-order-the-game here!

 

Gratuitous Space Battles 2 Update 1.17

It’s that time again! its Gratuitous Space Battles 2 beta update day! Currently the patch is still being put together, but if you can’t wait, you can just re-use your download link to grab the latest copy, 1.17. Here is a video with me demonstrating some of the new features: (uploaded in HD at considerable inconvenience on my rural broadband :D)

And the complete changelist is…

Version Beta 1.17 Feb
==========================
1) Added a bunch of new voiceover sounds.
2) Fixed crash bug relating to very complex scenes.
3) You can now place visual components beneath the ship hull.
4) Fixed GUI issue on R&D screen for modules.
5) You can now disable the suns lens flare under options.
6) Added new ‘reset to zero’ button for object rotation on ship design screen.
7) Choose battle screen now only shows high scores for difficulties that are present.
8) Module order on design screen is no longer scrambled.
9) Fixed composite objects shrinking slightly when split in ship visual design screen.
10) Composite objects on ship visual design screen now have a blue outline.
11) Fixed some display bugs relating to composite objects on ship visual design screen.
12) Composite objects now sorted to the bottom on the ship visual design screen.
13) Engine glows have more variety now, plus contrails and engine glows displayed more sensibly in the ship editor.
14) Ship visuals editor now shows tooltips & display values for the object sliders.
15) Crash at end of challenge games now fixed.
16) Inbox for messages now displayed on online screen.
17) Pop-up indicator for new messages added to main menu.
18) new option to send another GSB user a message from the online screen.
19) Fixed issue where challenge fleets would appear in the wrong place.
20) Fixed bug where text-entry carat was sometimes in the wrong place.
21) Balance: Reduced resistance of light and medium shields.
22) Added new second tutorial mission.
23) Balance: Increased capability but reduced range of gunship mounted disruptor bomb.
24) Added new anti-shield bomb for fighters & gunships.
25) Sounds added for shield impact and failure.
26) Larger more apparent visual effect for radiation damage.
27) Added fuel indicator readout when you click on your fighters/gunships for details.

Gratuitous Space Battles 2 is a space strategy game where you design your own spaceships and space-fleets and then pit them in hands-off battles against either AI fleets, or fleets designed by other players, and you can grab it right now (in beta) from this link:

buy_button

GSB2 Design mode composites (pre-built)

I admit it, it makes me cough and splutter a lot when people say ‘I don’t want to go to the trouble of designing the look of the spaceships, so I just slap down an empty hull graphic‘. It worries me because there are several downsides to this. Firstly, they are missing out a big part of the game, especially a big part of what makes GSB2 new. Secondly it means their challenges, screenshots and videos are going to give a poor impression of the game, because those naked hulls are…well naked, and simplistic looking. My engine can do better! Thirdly (and perhaps most importantly) it suggests that people think the ship design interface is too complex, or fiddly, or time consuming. This is something I’ve been working on.

Firstly we now have a lot of fixes that make composite objects work better, and rotation speeds are fixed, and there is now a handy ‘reset to zero’ button for rotation speed. Plus the interface now only shows color layer options when they are relevant, because always showing three confused people, as there are rarely three layers to adjust…

But something that was suggested, and it was a great idea, was that the game should come not only with all these tiny little widgets, but also some pre-built big components you can drag and drop to make the process quicker. I agree. This now acts as a half-measure between those people who couldn’t be bothered to design at all, and those who spend hours adjusting each fin.  Here is a screenshot of a naked hull surrounded by some of the pre-fabs you can choose from.

550

Those pre-fabs are ‘composite objects’ and you can just right click on one and split it into all its components. Each one has a big pile of them, and you can delete one, move one, and then regroup as a new composite if you like. You can scale and duplicate/mirror/set colors for composites just like anything else, it’s one of the ship editors best kept secrets.

On that topic, I should probably give some love and attention to nudging people into using the hotkeys on that screen, as frankly I never touch the size or angle slider for anything, its so much easier to use a mouse wheel with ctrl or shift. Here’s a closeup of a composite, made up of probably 30+ components.

composite

I’m going to spend some time today just making a few of these for each race. They act both as ‘quick-fixes’ to otherwise dull looking hulls, as well as a demonstration of the way composite objects work, which hopefully will nudge more people into creating their own. Eventually I’d like to see collections of them in the steam workshop or as lists of mods on the GSB2 website. I can foresee people getting reputations as expert ship designers!

If you just stumbled upon this post, this is a blog about the PC space strategy game ‘Gratuitous Space Battles 2‘ which is currently in beta, and you can pre-order the game and start playing right now by clicking this link here. Tell your friends!