Chase's Techno Rants and Raves

Did I just hear him call it "C-Pound"?!

  Home  |   Contact  |   Syndication    |   Login
  18 Posts | 0 Stories | 16 Comments | 5 Trackbacks

News

Me

Archives

Image Galleries

Tuesday, July 01, 2008 #

If you have run the TFS database repair command line utility you have probably run into this issue.  I am able to reproduce the issue simply by rerunning the tool against my TFS databases in SQL.

Once you run this tool - when you open the the team explorer in VSTS you will notice that the work items are no longer available.  The reason this happens is because when you run this utility - it drops and recreates all the Stored Procedures and UDF's and other stuff that TFS uses to get to the data.  To diagnose this problem I used the SQL Profiler to listen to the queries coming into my TFS server.  I came up with one query of particular interest...

*note I removed the sensitive data items from the query - they are the values in angle brackets such as <binaryvaluetwo>. 

exec sp_executesql N'set nocount on
declare @rebuildOK as int
declare @PersonName as nvarchar(255)declare @userSid as nvarchar(256)
set @userSid=@P1
exec @rebuildOK=dbo.RebuildCallersViews null,@P2,1,0,default,@P1
if @rebuildOK<>0 return
select @PersonName = DisplayPart from dbo.Constants where SID = @P1
declare @bulkUpdateIdList as nvarchar(4000); set @bulkUpdateIdList='''';declare @missingOrUpdatedIdList as nvarchar(4000);set @missingOrUpdatedIdList='''';
select @PersonName
declare @Collation as sysname exec dbo.sp_executesql N''set @Collation =cast(DATABASEPROPERTYEX(DB_NAME(),''''collation'''') as sysname)'',N''@Collation sysname output'',@Collation=@Collation output select collationproperty(@Collation,''LCID'')
select collationproperty(@Collation,''ComparisonStyle'')
select DbStamp from Dbo.GetDbStamp
declare @accountDisplayMode as int;
exec @accountDisplayMode = dbo.GetAccountDisplayMode
select @accountDisplayMode
declare @RowVer0 as binary(8) set @RowVer0=@P3
declare @RowVer1 as binary(8) set @RowVer1=@P4
declare @RowVer2 as binary(8) set @RowVer2=@P5
declare @RowVer3 as binary(8) set @RowVer3=@P6
declare @RowVer4 as binary(8) set @RowVer4=@P7
declare @RowVer5 as binary(8) set @RowVer5=@P8
declare @RowVer6 as binary(8) set @RowVer6=@P9
declare @RowVer7 as binary(8) set @RowVer7=@P10
declare @RowVer8 as binary(8) set @RowVer8=@P11
declare @RowVer9 as binary(8) set @RowVer9=@P12
exec dbo.GetAdminData 0,@RowVer0,@RowVer1,@RowVer2,@RowVer3,@RowVer4,@RowVer5,@RowVer6,@RowVer7,@RowVer8,@RowVer9
set nocount off',N'@P1 nvarchar(45),@P2 nvarchar(8),@P3 binary(8),@P4 binary(8),@P5 binary(8),@P6 binary(8),@P7 binary(8),@P8 binary(8),@P9 binary(8),@P10 binary(8),@P11 binary(8),@P12 binary(8)',@P1=N'<mymachinesid>',@P2=N'WorkItem',@P3=<binaryvalueone>,@P4=<binaryvaluetwo>,@P5=<binaryvaluethree>,@P6=<binaryvaluefour>,@P7=<binaryvaluefive>,@P8=<binaryvaluesix>,@P9=<binaryvalueseven>,@P10=<binaryvalueeight>,@P11=<binaryvaluenine>,@P12=<binaryvalueten>

 

What's relevant here is when I ran this query in SSMS while connected to the TFS SQL Server I got this message...

could not find stored procedure dbo.GetAccountDisplayMode

 

Lucky for me I had a staging environment on a virtual machine that I could go back to and compare - it's not a stored procedure it's actually a UDF called "dbo.GetAccountDisplayMode" which does nothing more than act as a constant value (in other words the function does nothing but return the integer value of 2).

Run this query on your TFSWorkItemTracking database and you should get your work items back...

USE [TfsWorkItemTracking]

GO

/****** Object: UserDefinedFunction [dbo].[GetAccountDisplayMode] Script Date: 02/28/2008 09:58:59 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

create function [dbo].[GetAccountDisplayMode]

()

RETURNS int

as

begin

return 2

end

It works for me since my work items are back and all is good again - but this still needs to be fixed in the tool...  I submitted this to MSDN but not much has been said about it since.  I am tempted to see if the tool itself is written in C# and decompile it in reflector and fix the bug so I have my own little hot fix - but that's just something between you me and the wall ;)

 

If you want to ask or participate in the forum thread (there's not much there) feel free to visit it here...

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2922054&SiteID=1


Monday, June 23, 2008 #

George Carlin died today...  It's almost ironic that windows is complaining to me right now about the spelling of his name - but regardless, one of the greatest people of all time has died today and we have to be strong like he was  - carry the torch of truth and know what is real - it's almost like he is saying from the grave that the the rest of the world needs to WAKE THE FUCK UP!!! and move on to the truth. 

I remember back in my good ol' Wisconsin hillbilly days in the 80's of Spectrum TV watching this guy and always saying to myself at age 6 - I am never going to bullshit anyone (again that was when I was 6 and I am sure I have said some bullshit in my day - but it's hard - this guy never bullshitted anyone - if he said you were ugly - well then you probably better get a good plastic surgeon.  Everyone should be smart enough to know by now that air helps you breathe - water is wet - and the light helps you see - this guy said all that - just that that was obvious - nothing more...  God bless him.  There is nothing more noble than the truth - no matter how vulgar or offensive it is (if you are full of shit - then you are full of shit - nothing is going to change that other than the fact that you suddenly decide to stop bullshitting people) - again - god bless this man - he was for real - and he is in heaven right now for it - god always appreciates the ones who have the balls to say it like it is - this guy was most certainly one of those people...  I will miss him dearly as if he were a member of my family...


Sunday, June 22, 2008 #

As I promised in my last post I am going to demonstrate how much better it is to use Audio with the latest XNA bits from Microsoft. 

The XNA 3.0 CTP can be downloaded here...

http://www.microsoft.com/downloads/details.aspx?FamilyId=DF4AF56A-58A7-474C-BFD0-7CF8ED3036A3&displaylang=en

 

The audio support with XNA prior to this release was limited to say the least.  You had to use a tool called XACT to compile audio resources and use them in your game using the Audio Engine, Wave Bank and Sound Bank classes.  The API was easy enough - the XACT tool however has challenges of its own.  I have found the tool to be buggy and intermittent in expected behavior despite its ease of use.  It's really is a crap shoot when you start using this tool.  In that tool's defense however, it did what it was set out to do when it worked.  But when a bad relationship comes to an end we must move on. 

Now for the good stuff.

One of the touted features of XNA 3.0 Audio is the ability to play MP3 files.  This is a great advancement in XNA development as it now allows developers to use a more compact format when introducing Audio into their games.  Since most music files these days are MP3 (or at least that is the accepted format) this is a very nice feature to have.  Here is an example of how to load and play an MP3 file.

 

Playing MP3 Audio.

The first thing you need to do in your XNA 3.0 project is add an MP3 resource for audio.  It is consistent with the behavior of adding textures and other resources outside of what XNA provides in the Add New Dialog.

Right Click on the Content Area and select "Existing Item...".
Browse to your music file and click ok.

You will see your solution explorer should look similar to the image in the left below.  The image on the right is the all to familiar property explorer and is showing what we can configure when we select our MP3 file - you can see that it intelligently selects the appropriate content processor for "Song".  You cannot make MP3 files sound effects unfortunately - this would be nice since you could make the size of your SFX files even smaller, but it doesn't matter.  My rule of thumb on sound effect files is if the file is larger than a couple of K then you might want to rethink how it is composed anyway - so this approach works fine.

Solution Explorer (AudioMP3) Properties (AudioMP3)

As you can see you can set the compression quality and other attributes of your MP3 file - another nice feature to have.

To use this file in code is simple and very intuitive, just load it using the content manager the same way you load textures or anything else.  Once you have a handle to it all loaded up and ready to go, you can play the file.

Declaration...

private static Song theMirrorsTruth;

Initialization...

Code Snippet

0:   public static void InitializeAudio(ContentManager content)
1:   {

2:   theMirrorsTruth = content.Load<
Song>("01 The Mirror's Truth"
);
/font>

 

 

Playing the MP3...

 

Code Snippet

0:   public static void PlayInFlamesTheMirrorsTruth()
1:   {
2:  
MediaPlayer.Play(theMirrorsTruth);
3:   }
/pre>

 

 

Simple enough - there is a static method called "Play" that takes instances of song objects and plays them.  You can get more creative with this using the MediaQueue objects, but I will not be talking about that now, on to sound effects...

Playing WAV sound effects.

Adding the sound effect resources is very similar to adding the other audio resources.  One of the things I should mention is that when you want to use the sound effect class you need to keep in mind that this class will only allow you to load content processed as a wav file.   Your property designer for wav sound effect files will look like this...

Properties WAV

 

You can see that it is now using the Sound Effect content processor and WAV Audio File content importer.  To load and use it you have to use the SoundEffect class.

Declaring our sound effect...

private static SoundEffect plasmaMissleSFX;

Loading our sound effect...

plasmaMissleSFX = content.Load<SoundEffect>(@"RaptorOneSFX\PlasmaMissleExplosion");

Playing our sound effect...

 

 

Code Snippet

0:   public static void PlayPlasmaMissleExplosion()
1:   {
2:   plasmaMissleSFX.Play(1.0f, 0.0f, 0.0f,
false);
3:   }
/pre>

 

 

Easy Easy Easy!  I should mention what the different arguments are for a Sound Effect's Play method.

The prototype looks like this.

public SoundEffectInstance Play(float volume, float pitch, float pan, bool loop)
Volume is a float value of 0.0 to 1.0 - setting it to 1.0 will play the sound at the volume you originally recorded the WAV file at.
Pitch is a float value of -1.0 to 1.0 - this set's the octave range of the sound effect - setting this value to 0.0f will give you "unity" which is the pitch the sound was recorded at
-0.1 is down an octave and 1.0 is up an octave.
Pan is a float value of -1.0 to 1.0 - this set's the sound's left or right channel, you can use something like this to control which speaker the sound will play louder (nice if you want to 
set a sort of 3D effect with bombs going off - negative values move the balance to the left, positive values move it to the right. Setting to zero centers the sound on both speakers
as recorded.
Loop is a bool value that tells the sound effect to either play the sound once and stop or keep playing it over and over again.


The return value is something called a SoundEffectInstance.  This is sort of like the old Cue object.  Something I use this for is to keep the sound around while it is playing
and check it during updates to see if it is still playing - if I want to play the sound again in response to user input but only want to restrict it to a single play at a time regardless
of what the user is doing - this this is the object it use.

What I have done in my own project is create something called a SoundEffectHelper class that keeps a reference to the instance playing and a reference to the actual wav file.  
Then I create "Manager" classes to manage my sound effects and songs - this keeps everything in once place for me so if I want to change a sound effect that get's played in a bunch
of different places - I only need to change it once (it's just good design practice).

There are so many more features here that I could go on for quite a while,  you can do lots of neat things like doppler effects, etc...  And I only scratched the surface on the API, 
but this should be enough of an example to get you started.

 
 
 

Saturday, June 14, 2008 #

Well if you are like me and like playing with the newest stuff out there you have downloaded the new CTP for XNA 3.0. 

So far I have been nothing but pleased with it.  It integrates directly into VS 2008 so I don't need VS 2005 express or VS 2005 Pro to use it now (there were ways to install it to work in VS 2008 but it was a nightmare to make it work). 

The thing that I absolutely LOVE is the new Audio stuff  here is a brief overview of what's there that I have played with so far.

SoundEffect - this class let's you play wav sound effect files,  you can try using the Song and MediaPlayer classes to play your sound effects as MP3's if you want to save storage space / file size - but I will warn you that there is a slight delay on the first play of your effect so this is not advised - do yourself a favor and stick with the wav files and use the MP3 files for your music.

What is even better about this class is the ability to control the volume and pan / pitch and looping at runtime!  This is really cool,  for example - say you have a bomb or explosion go off on the left side of the screen, you simply pan it to the left and it put's more umph into the left speaker - likewise to the right and so on.  You can also control the volume in reference to the z-axis of where your sound is originating (you can go even further and start tweaking the doppler effects, etc using some other methods and classes if needed).  So as you can see so far, this is a very flexible and powerful audio class.  Sure you could use XACT to do this stuff, but I would really like to stick to controlling my audio in the actual code and not having to script it in a "flash like - timeline manner" as I have had to do in the past.  I like to keep my external audio tools limited to Audacity and the LAME encoder.

 

SoundEffectInstance - this is sort of like a Sound cue in play - there is not constructor for this class - it comes from calling the play method of your sound effect instance this comes in handy if you want to restrict playing the sound to only be one per play - you can say "are you playing" and if it is you can wait or move on until it's finished.  Very handy indeed (the Cue class did this too - I just like the way they did this better as it appears to be much cleaner).

Song - this guy holds on to your MP3 content.  you use this to contain the actual stream of data that is your MP3 file.  An instance of this is what you will pass to the media player class to actually play the song.

 

MediaPlayer - this is the class you will use to play the MP3 files - it's not advisable to use the media player class to play your sound effects as I have found so far that this can lack responsiveness on the first play (or it could just be my computer remember folks this is the cutting edge so anything can happen) :)

Now the new objects are great - but what I love the most is how they made the audio consistent with the rest of your resources such as textures.  You simply call the content manager's Load method - as always it expects a parameterized type and for songs and sound effects you simply pass in (you guessed it) Song and SoundEffect.  It will load these from your content just like everything else you will use the content manager for.  This is a refreshing change over what was there before and the consistency makes it so much more intuitive - kudos to the Microsoft XNA team on all this stuff so far!

I will say this - I have said some crap about Microsoft in the past - and it's usually true at the time - but one thing is for certain - if it weren't for the crap talkers out there - then things wouldn't get continually better as they have been,  one thing about Microsoft - they always make it a ton better on the next pass, I cannot wait to see what happens with XNA next.

 

There is a ton more in the Audio and Media namespaces that I have not mentioned yet - but I do have a life and this would take me the better part of my Saturday to cover it all (not to mention this blog post would be huge).  I have been playing around with some helper classes that combine the functionality of the SoundEffect and sound effect instance classes to give them finer grained control over what they do (they already give you a TON of control as it is - so there's not much left to add).  I will post the code sometime this week once I have something I am satisfied with showing to other people.


Friday, June 13, 2008 #

As I mentioned in a previous post - I got a new machine.  After repaving it with Windows XP and Service Pack 3 I started installing my favorite development tools starting with latest and greatest Visual Studio IDE.  Unfortunately I should have RTFM'ed what what out on the web before I did this.  Once I was done doing that I proceeded to install SQL 2005 only to be hit with a nasty error message about using SKUUPGRADE to change versions.  The problem is that once you install VS 2008 - you will get some of the workstation components (such as osql and some other command line goodies).  The problems with this is now I cannot install SSMS 2005.

Trying the SKUUPGRADE didn't help me - I am sure I did something wrong but found something that worked before I could dig deeper into what I was missing.

I found some good posts on how to go about fixing this - but I am a visual guy and sometimes I find pictures (to forgive the old cliche) are worth a 1000 words.

So here is a visual guide to fixing this nasty problem (and if you have not installed VS 2008 yet and are reading this - don't do what I did - just install SQL 2005 first and you should be okay).

What you will need...

1: SQL 2005 Disk you tried (but failed) to install the workstation components with.
2: Your computer - keyboard - mouse etc...
3: Your sanity (make sure you have this - if you don't, go for a walk or something and come back later when you have regained it).

4: No paste, duct tape, welders or any other tools are required for this exercise

Part One - Cleaning up the mess by removing the components added by VS 2008.

1: Open your control panel and go to add remove programs (START->Control Panel->Add Remove Programs).

SSMS Step one

2: Find SQL Server 2005 and click the "Change Button".

SSMS Step two

3: You will be presented with the following dialog - select the "Workstation Components" radio button as shown.  Then click "Next".

SSMS Step three

 

4: The SQL Server Setup will start up again and you will be presented with the wizard startup dialog (I am not showing a picture of that for brevity).  Click "Next" button to continue and it will proceed to scan your system.  You will notice that there is a warning message for the Edition Change Check (just like when you tried to install it the first time around).  You can ignore this too and click next.

 

5: You should see the following dialog if you did everything right so far,  click the "Remove SQL Server" button - this will not remove the server components - just the one you selected in the above dialog (if you have been following along it should have been the workstation components that you selected).

 

SSMS Step four

You will be presented with a confirmation dialog next - Click the "Remove" Button and it will proceed to uninstall SQL Server's workstation components (in this case it will just be the client tools that got installed with VS 2008).  You will also notice that it removes MSXML 6 (I am not sure why it needs to remove this too as I am pretty certain that the Server components use it as well) - it's okay - we are going to be reinstalling it back in after this part is done.


Part Two - Installing the Workstation components to get SSMS to install (as well all the other components we just removed back again).

 

Now that our mess has been cleaned up it's time to reinstall the components.  Without leaving any of the Add / Remove programs area - we just click "Change" again. You will see the following.

 

SSMS Step five

 

Instead of picking an option in the radio button lists - we are going to click the "To install a new component, click here" link (I marked it in red in case it's not obvious). :)

SSMS Step six

Now it's will asking for the disk again.  Click browse and browse to either one of these paths (this should go without saying but I am adding here for completeness).

for X86 folks go here...

<drive>:\SQL Server x86\Tools\Setup.exe

for X64 folks go here...

<drive>:\SQL Server x64\Tools\Setup.exe

Click Ok and the Standard SQL Server 2005 setup dialog will present itself - accept the EULA - click next and it will scan your system for settings again - once more you will see the Version Change warning rear it's ugly head.  Ignore this and click "Next" once more.

Expand the client components node and tell it to install the pieces you want (or if you like to play with all this stuff - just left click and tell it to have all the features installed).

 

SSMS Step seven

Click the next button.

Note: You can install the Documentation from here if you want - but the chances are good that they are outdated in your installer disk - to get the latest and greatest docs go to the following hyperlink once you are finished with this step.

http://www.microsoft.com/downloads/details.aspx?FamilyId=BE6A2C5D-00DF-4220-B133-29C1E0B6585F&displaylang=en

 

It should confirm your choices - click "Install" and off you go!

Once this is completed you should be back to normal with SSMS installed on your workstation once again.


Sunday, June 08, 2008 #

After that last post today about big bill I figured I better say something nice for a change.  I just got a new computer (well sort of new anyway) from a guy that was going to throw it out (the prices was right - free is my favorite).  I have been running an older MSI motherboard with a gig of ram and a 1.8 GHz proc.  It's been a good little machine that has pulled me through for a good many years now (yeah I'm a cheap bastard, what about it).

So now I have this Dell Precision 380 workstation.  I don't play with proprietary boxes very often so I didn't know much about what it had for guts when I got it.  Needless to say when I got it home and popped the hood I was very pleased.  Massive cooling fan can only mean one thing... A really fast proc.  And to my great pleasure it came with 4 SATA channels - W00T!  (yeah I know - this stuff is kinda old skool too, but compared to what I was using before - it's light years ahead of what I had before).

So I put the hood back down and repaved it then retired my old box to my son who has had the misfortune of using a machine that I pieced together from old leftover parts (yeah he's really happy too - he get's to play Kane's Wrath in his room now and doesn't have to beg to use mine anymore).

I tried out Sim City 4 - holy crap - I have been tweaking that old clunker of mine for a long time to get the kind of performance I got out of this one - very nice. 

So now for the real test - I installed AOE III.  All I can say is my breath was taken away.  I still can't crank it up to the hilt yet (it only has an NVidia Quatro card which is great for 2 monitors - but for games... well... ehhh...).

So now I am on a mission to get a new card.  I am open to suggestions from anyone who is willing to give them out.  I have been looking at some of the new NVidia Cards and ATI cards (I have been a fan of ATI ever since I got my Game Cube and made the switch from my GForce cards).  But either way the only thing I really care about is this - is it fast and does it work?  (and I need P.S. 2.0 so I can keep making my games in XNA).  I need to get a PCI express card since the AGP stuff I was using before is old hat these days.  Wow - I can't wait to see what this game does with a real video card on this machine! 

I gotta tip my hat to the Microsoft Game Studios guys - they really cranked out a masterpiece with Age of Empires III - I hope they make another expansion pack for it - I have the Asian Dynasties and the War Chiefs right now.  These guys should consult them selves out to the rest of the company and give them some pointers on how to do things the right way, because they really do put out some quality stuff *chuckles to self*.  I would love it if they went back to their roots with AOE III and made another one using the old middle age stuff they had in AOE II.  Now THAT would be awesome.


Wednesday, June 04, 2008 #

I finally finished the "raptor-one" fighter which is the player in my next game as I mentioned in the last post - here are some screen shots.

There are so many images I want to post, alas, the post would be really long so I abbreviated it to some highlights.

titlescreen VulcanRapidFire
Title screen - it's a work in progress... this is the standard Vulcan with 4 shot pattern in rapid fire mode

 

raptorone napalm
here's a close up of the fighter this is one of the final frames of the napalm bomb.

 

ParticleBeamSpread plasmabeam
this is the spread particle beam rapid fire mode (notice I screwed up the rotation on the side bursts - they are going backwards - going to fix that after the post since it's easy to fix). this is two frames from one of the super weapons (the plasma beam).

 

flashshell plasmamissleexploding
this is a flash shell (one of the standard projectile weapons) here is a middle frame from the plasma missle exploding

superflashshell plasmabombexploding
this is another super weapon in one of the final explosion frames (the super flash shell) this is one of the final frames of a plasma bomb going off

superhighexplosive riftcannon
here are two frames of a super bomb (there is really only one in the game) this is the super high explosive bomb. Last but not least here are 3 frames of the Rift Shell super weapon.  The first one is the projectile in flight - the second one is the portal opening and the final one is the portal snapping shut.

Well after I spend a couple minutes fixing that rotation issue withe the particle beam - I am going to get started on designing the bosses. 

More To Come!


Saturday, May 31, 2008 #

I started working on yet another title for the XNA platform about 3 weeks ago.  It is an overhead scrolling shooter called "Angels Ten".  I always loved games like Life Force, Gradius and Raiden while growing up so I figured that would be my next thing to tackle. 

Someone asked my about the name once pointing out that it seemed odd to them.  So I just showed them the following definition from an Air Force terminology website and it was all cleared up...

"Angels: Altitude in thousands of feet. "Angels ten" indicates 10,000 feet of altitude. "
(the link to where I found this is here... http://www.gruntsmilitary.com/airdic.shtml )

So what's the milestone?  The main character of the game (a souped up version of the new DoD F-35 Joint Strike Fighter) is finished (at least the weapons are done - still working on the animations for when the character get's killed of which there will be several variations from an abrupt arial explosion to a slow decent and crash complete with pilot ejecting).

Here are the weapons (each category is in order from weakest to strongest)

Standard Ordinance (burst and rapid fire - w single double quad and spread variations for all types)

Vulcan
Laser
Super Laser
Flash Shell (sort of an air to air mortar with energy explosions)
Particle Cannon

Missles (there are 4 missle hardpoints on the plane)
High Explosive Phoenix Missle
Plasma Phoenix Missle

Bombs
High Explosive
Napalm
Plasma

Super Weapons
Super HE Bomb (sort of like a fuel air bomb)
EMP Burst (knocks out *most* enemies on the screen - some are sheilded from this attack)
Super Flash Shell (big version of the standard flash shell described above)
Super Particle Blast (big cone that spreads out in 45 degree angles from the nose of the plane)
Rift Cannon (fires a tesla like ball of energy out in front of the plane that opens up into a temporal rift sucking everything that doesn't have a "rift sheild" activated) - this is the most powerful weapon in the game.


I'll post some screen shots once the crashes are done.  After I finish those I am going to start working on bosses - then the levels, then finally the actually scenery and enemies.

 

 


Thursday, May 15, 2008 #

Well I finished my first game on the XNA platform.  It's a simple War Card Game - the concept was entirely used to learn some of the XNA API.  The last time I wrote a game was using MFC and COM before that was a RPG using HyperCard 2.0 on a Mac LCIII and System 7 a LONG time ago - needless to say when you see the code you will not be surprised that it is a hot mess (at least in my opinion).

But - with all things aside - the game turned out decent and has some playability to it.  I am working on an overhead scrolling shooter right now - just finished the player object (named RaptorOne) which is a futuristic play on the up and coming Joint Strike Fighter.  More details on that to come - the explosions are slowing things down a bit (probably because of the number of frames I am using - will play around and come up with a better algorithm to speed things up so I can put more umphh into it).

The binaries for the game can be downloaded here...

http://www.driveway.com/u4i1i8n3c5

The source code can be downloaded here...

http://www.driveway.com/t4o8c2d0p6

This is turning out to be quite the hobby - I could spend hours doing this stuff.  I asked my Wife the other day if she thought I should get a job doing this (should I get better at it of course) - she said that she was afraid that I would never come home - that was good for a chuckle.  Anyway - enjoy the game and remember you need the XNA 2.0 Runtime and DirectX 9c + .NET 2.0 to run it - I didn't create an installer for this and I don't intend to - this was just for practice.


Sunday, May 11, 2008 #

Why oh my God WHY do we have to keep using these foul bug ridden tools! 

I have been fighting with this joy of a tool to use for the last month now and I just love the crap it keeps dumping on me.  First I can't even audition anything even after I connect to my local machine (WTF is that all about anyway?! - I just want to play a sound for chrisakes - what a PITA!).  And don't even get me started on the lack of playback support for MP3 files - you mean to tell me I need to bloat my code with 30 megs of a WAV file when I could just use a 3 meg MP3 of the equivalent sound quality and get the same result - whatever...  Seems like I need to go back to using raw DirectX or OpenGL and dump this garbage. :P

And another thing... Half the time - if the XACT process doesn't get completely killed in the process manager - it will interfere with any builds go do after that and corrupt your XACT project file and the builds so that when you try to load them into the audio engine - they completely crap out - it's hit or miss on that one - you just have to keep trying until it works - again WTF?!  And how do I know this?  Well - I it's because it starts complaining to me about a half hour after I have used it and closed it.  Whadya mean there something wrong and you need to close - I haven't even had you open for the last 1/2 hour - holy shit already...  I mean give me a break - there's nothing better than that warm and fuzzy feeling you get inside when an app you can't fix but are stuck with - does this intermittent crap.

So now we have my recent issue with the tool which has caused my Rant for the day.  And somebody please tell me that this is supposed to be supported - otherwise error check that the sound bank name matches the wavebank or at least take out the ability to make a change to the name before you ship the god damn thing.... All I want to do is change the name of a sound bank that is referring to a wave file that another sound bank is using - sounds easy doesn't it - if you only knew...

So here's the story...

Here we have one wave file called "LaserBlast"  it plays a laser sound (go figure).

Then we have one Sound Bank called - well you probably guessed it - "LaserBlast" which points at the wave bank of LaserBlast.  Now I want to create a new sound bank that uses the same LaserBlast wave bank but loops the sound 4 times before the cue ends (this is because I have a rapid fire laser and a 4 shot burst laser). 

But - when you drag the LaserBlast wave bank to the sound bank list - you get - LaserBlast2 - no problem - lets just change that Sound Bank to be named "LaserFourShotBurst".  Except after you change the name - you get this little gem of an error...

------------- Begin Dump Exception -------------
Exception Type:
System.NullReferenceException

Source:
XactInterop

Message:
Object reference not set to an instance of an object.

Clickable StackTrace:
(Unknown Source Location): XACT.Interop.CXACTSoundBankCue.GetVariationType()
(Unknown Source Location): XACTGui.PropertyPlaylistEditor.SetValue(Object objInstance, Object objValue)
(Unknown Source Location): XACTGui.PropertyPlaylistEditor.CSoundBankSound_Changed(Object sender, CPropertyChangeEventArgs e)
(Unknown Source Location): XACTGui.CSoundBankSound.set_Name(String value)
(Unknown Source Location): XACTGui.CSoundBankForm.AfterSoundNameEdit(Object sender, LabelEditEventArgs e)
(Unknown Source Location): System.Windows.Forms.LabelEditEventHandler.Invoke(Object sender, LabelEditEventArgs e)
(Unknown Source Location): System.Windows.Forms.ListView.OnAfterLabelEdit(LabelEditEventArgs e)
(Unknown Source Location): System.Windows.Forms.ListView.WmReflectNotify(Message& m)
(Unknown Source Location): System.Windows.Forms.ListView.WndProc(Message& m)
(Unknown Source Location): XACTGui.CXACTBaseListView.WndProc(Message& m)
(Unknown Source Location): System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
(Unknown Source Location): System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
(Unknown Source Location): System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
------------- End Dump Exception -------------

And seriously - why bother - it's not like I can fix this bug myself - I don't have the source code.  And if I report it to microsoft - well - we all know what a crap shoot that can be.  So i try a workaround - I leave the sound bank name alone (now it's called LaserBlast2)  - I set the loop to 4 and create a que for it (LaserBlast2 once again).  But - alas - when I try to load the que in my game - it gives me that all to familiar error message "Resource Could Not Be Loaded"  - kind of reminds me of the good ol' days of ATL COM and the wonderful EFAIL toilet paper that I used to get reams of when working with that pile of steaming ass goo.


Thursday, April 24, 2008 #

Updated 5/19/2008 to use code CSS files and show both posts as one

Recently I started playing around with the XNA framework.  I absolutely LOVE it.  So much simpler to use than raw DirectX.  Well while working on my first 2D game I came across a problem - there was no intrinsic support to move a sprite along a specified path starting at Point A and ending up at Point B (and then having it stop there) - after lots of digging - reading a lot of crappy forums and pouring through tutorial after tutorial - there was nothing readily simple out there to parse out this kind of (what should be) a relatively simple task. 

This to me seemed stupid that there would be nothing built in that does this, unit vectors and Rays alone will not help you, and trying to use a simple linear equation doesn't do it either - here's an example of that simple formula that doesn't work for all applications (works great if you have a straight horizontal line however).

B(t) = P0+(P1-P0)t

Which in code translates to...

   1:  public Vector3 PathUnit(Vector3 pos1, Vector3 pos2, float speed)
   2:  {
   3:             return pos1 + (pos2 - pos1) * speed;
   4:  }
 
Like I said - fine if you just want to go from point a to point b on a straight horizontal line - but what about diagonal lines?  This will fall flat on it's face if you just try to add the two vectors together (the Y keeps incrementing at a static rate regardless of the slope) - wait - there's that word - slope...  So that leads us to the Slope intercept formulas.

First - find the slope of your line using the slope formula you learned way back in 8th grade...

m = (y2-y1)
(x2-x1)

Which in code looks like this... 

lineSlope = (_endPoint.Y - _startPoint.Y) / (_endPoint.X - _startPoint.X);

Now that we have our slope we can get the slope intercept for the Y axis using the slope-intercept formula where the slope is "M" and b is our speed (in our case we are going to muliply it since it gives better results on the screen).

y = mx+b

Our code will look something like this (take the slope we just got and multiply it by our end point's X position - then multiply this by the speed - we will be using the value a lot later on.

For our X intercept we will use a Ray structure - as follows....

_direction = new Ray(_startPoint, _endPoint); 
_xIntercept = _direction.Direction.X*speed;

In some cases this will not work (In the case of vertical lines) this is because mathematically a slope of 0 is horizontal and a slope of Infinity is straight up and down.  So we have to do this when that happens....

   1:  if (float.IsNegativeInfinity(_lineSlope) || 
   2:      float.IsInfinity(_lineSlope)) //vertical line moving down 
   3:  { 
   4:       if (_startPoint.Y > _endPoint.Y) 
   5:            _yIntercept = -speed; 
   6:       else 
   7:            _yIntercept = speed; 
   8:            
   9:       _xIntercept = 0.0f; //duh - a vertical line moves neither left nor right 
  10:  } 
  11:  else if (float.IsNaN(_lineSlope)) //vertical line moving up 
  12:  { 
  13:       if (_startPoint.Y > _endPoint.Y) 
  14:            _yIntercept = -speed; 
  15:       else 
  16:            _yIntercept = speed; 
  17:       
  18:       _xIntercept = 0.0f; //see above... 
  19:  }


So this all works fine - now we need to come up with a way to tell it to stop when our point get's to where it is going...   The rectangle class in XNA - well - it sucks, why they use integers instead of floats like everything else makes no sense to me - oh well - enough ranting - making our own is easy enough and we can even make it smart enough to center itself over a specified vector as such...

   1:    public void Inflate(float size) 
   2:    { 
   3:            _top += size; 
   4:            _bottom -= size; 
   5:            _left -= size; 
   6:            _right += size; 
   7:            _front -= size; 
   8:            _back += size; 
   9:    }
  10:   
  11:    public bool VectorInRect(Vector3 position) 
  12:    { 
  13:         return (position.X >= _left && position.X <= _right && 
  14:                 position.Y <= _top && position.Y >= _bottom && 
  15:                 position.Z >= _front && position.Z <= _back); 
  16:    }
  17:   

Our inflate method gives us the ability to fractionally increase the size in all 4 directions (this is just like the worthless integer based rectangle I told you about earlier).

So when our point gets close to the end of the line - we can check to see if it's in this region - if it is - we can just set the point to the end and stop there. 

Here is the whole thing put together...

   1:  using System;
   2:  using Microsoft.Xna.Framework;
   3:   
   4:  namespace GameUtilities
   5:  {
   6:      public class LinearPathHelper
   7:      {
   8:          private Vector2 _startPoint;
   9:          private Vector2 _endPoint;
  10:          private float _lineSlope = 0.0f;
  11:          private float _yIntercept = 0.0f;
  12:          private float _xIntercept = 0.0f;
  13:          private Ray _direction;
  14:   
  15:          private StopRegion _stopRegion;
  16:   
  17:          public LinearPathHelper(Vector2 startPoint, Vector2 endPoint, float speed)
  18:          {
  19:              _startPoint = startPoint;
  20:              _endPoint = endPoint;
  21:  
            _lineSlope = (_endPoint.Y - _startPoint.Y) / (_endPoint.X - _startPoint.X);
  22:   
  23:              if (float.IsNegativeInfinity(_lineSlope) || float.IsInfinity(_lineSlope)) //vertical line moving down
  24:              {
  25:                  if (_startPoint.Y > _endPoint.Y)
  26:                      _yIntercept = -speed;
  27:                  else
  28:                      _yIntercept = speed;
  29:   
  30:                  _xIntercept = 0.0f;
  31:              }
  32:              else if (float.IsNaN(_lineSlope)) //vertical line moving up
  33:              {
  34:                  if (_startPoint.Y > _endPoint.Y)
  35:                      _yIntercept = -speed;
  36:                  else
  37:                      _yIntercept = speed;
  38:   
  39:                  _xIntercept = 0.0f;
  40:              }
  41:              else //diagonal line
  42:              {
  43:                  _yIntercept = (_lineSlope * _endPoint.X) * speed;
  44:                  _direction = new Ray(new Vector3(_startPoint,0.0f),new Vector3( _endPoint,0.0f));
  45:                  _xIntercept = _direction.Direction.X * speed;
  46:              }
  47:   
  48:              _stopRegion = new StopRegion(_endPoint, 10f, 10f);
  49:              _stopRegion.Inflate(speed);
  50:   
  51:          }
  52:   
  53:          private class StopRegion
  54:          {
  55:              private float _top;
  56:              private float _bottom;
  57:              private float _left;
  58:              private float _right;
  59:   
  60:              public StopRegion(Vector2 point, float width, float height)
  61:              {
  62:                  _top = point.Y - (height / 2);
  63:                  _left = point.X - (width / 2);
  64:   
  65:                  _bottom = point.Y + height;
  66:                  _right = point.X + width;
  67:              }
  68:   
  69:              public void Inflate(float size)
  70:              {
  71:                  if (size < 1)
  72:                      size = 50;
  73:   
  74:                  _top -= size;
  75:                  _bottom += size;
  76:                  _left -= size;
  77:                  _right += size;
  78:              }
  79:   
  80:              public bool VectorInRect(Vector2 position)
  81:              {
  82:                  return (position.X >= _left && position.X <= _right &&
  83:                          position.Y >= _top && position.Y <= _bottom);
  84:              }
  85:          }
  86:   
  87:          public void MoveVectorPoint(ref Vector2 currentPointPos)
  88:          {
  89:              //if we are within the boundaries of our stopping region - we need to snap to it
  90:              //so the move helper will stop the animation timer...
  91:              if (_stopRegion.VectorInRect(currentPointPos))
  92:              {
  93:                  currentPointPos = _endPoint;
  94:                  return;
  95:              }
  96:   
  97:              currentPointPos.X -= _xIntercept;
  98:              currentPointPos.Y -= _yIntercept;
  99:          }
 100:   
 101:          public bool IsAtDestination(Vector2 currentPointPos)
 102:          {
 103:              return currentPointPos == _endPoint;
 104:          }
 105:      }
 106:  }

Sunday, July 08, 2007 #

Wow I have been doing software development now for about 11 years and I am starting to go through another burn out period.  Of course this is mostly my fault since I have been working most of the time with no vacations.  Here is what I have found to help me get out of this funk...

1: VIDEO GAMES!!  Yes - we all have a daily vent for our frustration.  I have been using video games (not developing them - just playing them) to wipe away my frustration.

2: Movies.  With the new Transformers movie out and so many other kick ass flicks (the new Die Hard was awesome BTW).  There are a million ways to eliminate burnout.

3: Just playing with my Kid.  I have a 9 year old son who lives with his mother and visits me on a regular basis.  I have found getting my butt kicked by him on Age Of Empires III not only impresses me with his abilities but also makes my life more enjoyable.

4: Stay away from the house...   Getting out once in a while and avoiding sitting on my butt altogether also seems to get me out of the funk.

5: Take a freakin vacation already!  I am going on a long needed vacation next month to Cancun Mexico.  Hopefully I don't run into too many issues with the passport thing.  I am really looking forward to this as it has been almost 7 years since I last had a nice break like this.

That's all I have for now - I am working on some good code stuff to post about.  Playing around with LINQ and getting my feet wet with AJAX and the new WPF / WCF stuff - so I should have some good stuff soon.

 


Wednesday, January 03, 2007 #

Back in the day when I was a greenhorn COM developer – I had a question pop up in my head every time I was tasked to work on something that needed to be multithreaded.

 

It’s a theory I used to have in my novice days.  Let’s take a multithreaded application example and dissect a certain aspect of it. 

 

Here’s the true story behind this technobabble… About 7 or 8 years ago I was working on an application that had to talk to a COBOL CISAM file to read and write data.  We knew what we were doing as far as the data goes so this was not an issue.  Well, there was a provider for doing this called USQL.  It was not cheap however and the vendor was charging us in what is similar to the CAL based licensing in SQL sever (translation == ArmLeg).  Needless to say when there were 18 companies hitting this USQL thing at any given time so we needed a LOT of licenses for it.

 

To get away from this we were going to write a singleton data service that handled requests to read and write data to this file.  This singleton was going to use a COM component called “COBJects” (yeah I know it’s a cute name).   Well – there was a problem with this - we needed a multithreaded singleton, and COBJects was not (according to the original programmer at that time) was not "Thread Safe". 

 

Thread Safe… Now that is a term that immediately brings up bad memories of deadlocking issues in the COM and Win32 world that used to keep me up for hours  *shudder*.  But this used to be confusing to me – I cannot use a component in a multithreaded application because it is not “Thread Safe” – well why the hell NOT? I paid good money for it – I should be able to do with it as I wish! 

Let’s try this on for size; what if I keep that component’s use within the context of a Mutex or Critical Section any given time I use it?  Doesn’t that keep our component safe from multiple threads hitting it at once?  If a thread grabs a Mutex and starts working with our Unthread Safe component then releases its resource handles to it before closing the Mutex – then only one thread is using that component, Right?   Well… NO.

 

Here is where this old Theory Falls flat on its face.  Let’s say this component has some static variables it uses to retain cached information internally – but this cached information is based on a state within the context of a given thread that uses it.  Now another thread wants to play.  Just as a simple example let’s say this component tracks some kind of Thread ID and the component uses it every time it goes out and <insert distributed task here> but only aquires it the first time the object gets created.  Now the thread ID is wrong when it makes its call to the network in the context of the second thread.  The server side stub gets the wrong value that it received from the client side proxy.  Now we have PROBLEMS (and this is just an easy example).  Debugging this can be the stuff of Nightmares that would make Freddy Kruger proud (if they made a Far Side Comic about this there would be a picture of this scenario with a bunch of guys scratching their heads with flames dancing around them in a red cave with the caption “Programmers Hell”).

 

However – there may be cases where this doesn’t happen – in which case you should be safe (single call type scenario – no statics used on the inside).  But there are no guarantees in life and we will never know what goes on with the man behind the curtain (unless you are so bold as to throw the curtain back :) but this takes time – and when some other rich guy that doesn’t even get the concept of “Hello World” let alone this type of scenario – well – then we just have to assume the worst and move on so we can keep paying the rent.

 

So the moral to this story is this… If the component says it’s not thread safe.  Then don’t hit the same instance of it with multiple threads.  I learned quickly in my youth that my theory is wrong – and I hope that by telling it, I just kept any given n00bs to the world of multithreaded programming out of Programmer’s Hell.


Tuesday, November 14, 2006 #

Well it's done - my first public speaking venue.  I was nervous but it went well from what I heard others say.  Not to mention as I said in an earlier post - should I screw this one up it would cost me a swirlie. :)  Well, I left with a dry head of hair so I don't think it went too bad.  Public speaking like that reminded me of when I got my first Tattoo - it's sort of stings while your in the middle of it - but when it's all over - you can't wait to do it again.  So in a sense, it's sort of addicting. 

Now that I am done with that I can focus on other more pressing things - like my Enterprise application framework "Gestalt".  It's a hub and spoke model where you can take what you want and leave what you don't (without incurring any overhead using any given piece of it).  I will start posting about that in the coming weeks / months. 

The first thing I will cover will be the Gestalt Smart Fields (using Generics in C#) and some of the safe types that come out of the box as well as the primitive validation attributes that can be applied to them.

Stay Tuned...

Update: The results are in -- Just got the feedback from my FIRST public speaking venue.  Since it was my first - I knew coming out that I could improve quite a bit on my presentation skills, anyway it looks like i did ok.  Averaged out with 3's and 4's across the board (out of 5 possible) and 90% of the audience said they would recommend it to a friend. 

BTW : Only got one crappy unconstructive comment out of the whole thing - and that person probably kicks their dog first thing every morning (yeah some people are jerks - go figure).


Wednesday, October 25, 2006 #

Looks like the posts from my old blog have been removed by the administrator (but the blog is still up - strange).  This also happened to another coworker of mine who also had a blog on the same site.  Not sure why they would keep our old blogs going but choose to remove the posts - odd...  In my opinion if you are going to remove something for whatever reason - then remove it altogether.

So since so many people used to visit that blog to get the lowdown on my old Base Page Framework for ASP.NET 1.1, I will repost those here later tonight (the same thing is already out on the code project along with downloadable code examples if you need them). 

You can still find that stuff here  http://www.thecodeproject.com/aspnet/bpf.asp