Fixing more Battlefield 2 problems

Fixing more Battlefield 2 problems

Battlefield: Bad Company 2 on my PC was causing me MAJOR grief.  I’d get into a game, and about 5 minutes in, I’d get dropped and ‘connection to EA server lost’ message.  UTTERLY annoying.  Appears tons of other people have the same problems.  Various solutions from turning firewalls off/etc – but that didn’t work for me.

Changing your router’s UDP and TCP endpoint filtering to “Endpoint Independent” certainly helped – but it would still drop after about 10 minutes.

What seems to have worked is this.  Go to your steam client and:

Steam Library -> rightclick BC2 -> properties -> Set launch options… -> “-pingInterval 50000”
Paste the “-pingInterval 50000” phrase without the quotation marks and that’s it.

That seems to have solved the problem for me; but this was pretty much utter fail on EA/Dice’s part. The amount of hate-forum mail that’s gone on for over 2 years relating to this problem is amazing.

More Battlefield 2 adventures: PnkBsrtrB.exe handshaking failed

More Battlefield 2 adventures: PnkBsrtrB.exe handshaking failed

So, when playing the AIX mod for Battlefield 2, I kept getting kicked after about 2-3 minutes of play when punkbuster(!) complained that:

PnkBsrtrB.exe handshaking failed ; PnkBsrtrB.exe heartbeats stopped ; PB init failure ; Packet loss

The basic problem boiled down to the fact that when Punkbuster installed, it created the outgoing rules in windows firewall, but it did not create the INCOMING rules.  I simply added incoming rules for:

c:windowssysWOW32PnkBsrtrA.exe
c:windowssysWOW32PnkBsrtrB.exe

And set them to ‘allow’.  That turns out to fix the problem.

I still can’t believe how horrible the solutions to prevent cheating were back in the day.

Booting from a 4.0TB raid drive in Windows 7

Booting from a 4.0TB raid drive in Windows 7

Woot!  I just set up my system the last few nights with *three* 2TB drives all connected in RAID 5 setup into a single, 4.0 TB partition – AND I am using that huge bit bucket as my primary boot drive.  Now I have speed from the data striping and redundancy from the RAID.   It’s quite nice so far, but I’m still getting all my old software installed.   However, up until about a month ago – this wasn’t possible with the standard Intel storage controller that comes with almost all the new 2nd generation core systems (or with most RAID controllers).  But getting this magical land to work involves a lot of new information and a good bit of bleeding-edge fighting.

What you need to know:
First off, getting a RAID-ed boot partition larger than 2.2TB involves several pieces that need to work together.  If you only have the first 2, then you can still boot from a single-drive larger than 2.2TB, but you won’t be able to use it in a RAID setup with large partitions.

  1. A motherboard with EFI support
  2. An OS that can boot in EFI mode and supports GPT partitions
  3. A raid controller that can support creating and using boot partitions larger than 2.2TB.

First off, you need a motherboard with an EFI (Extensible Firmware Interface) bios.  EFI bios is the successor to the 20+ year old CMOS bios.  You might remember or have seen CMOS when that awful text screen came up when you hit the power and it would count memory or say ‘Press [del] to enter setup’.  Well, Intel with a lot of other companies finally, happily, heavenly, triumphantly are putting the nails in what had become a painful bit of computing legacy by throwing out CMOS and inventing EFI.  Apple has had EFI bios in their machines for a few years now, and some of the first-generation Core i3/i5/i7 motherboards had EFI support too – but it was spotty and very few things seemed to take advantage of it.  Which brings us to #2 – needing an OS that supports EFI booting and GPT.

If you have a motherboard that supports booting in EFI mode, you still need an OS that supports it and knows how to boot from partitions created with GPT (GUID Partitioning Table). I had an EFI board on my old system, but you couldn’t actually boot in EFI mode unless you used an early Linux distribution with EFI support or until about Windows Vista SP1/Win7 range.  Not only that, but EFI booting only worked on 64-bit versions of the Vista/Win7.  If you’d bought the 32-bit version – then you were out of luck.  The Vista route was also painful because unless you had an install disk that had the EFI boot files on it, you couldn’t actually install Vista in EFI mode.  Early versions of the Vista install CD’s (at least the one I had) didn’t have the EFI boot files.  I never learned if someone who had one of those early disks could return it and get an install disk with EFI boot support.  The reason you needed this is because if you couldn’t boot in EFI mode, you were stuck with the 2.2TB CMOS MBR boot limit.  If you weren’t in EFI mode during the install process, Vista/Win7 will refuse to create a boot partition larger than 2.2TB because it knew a MBR system couldn’t boot from it.  Unfortunately, you couldn’t override this in the install.  GPT booting was usually only supported when the BIOS booted in EFI mode.  So if your OS install disk couldn’t boot to EFI, or wasn’t able to make GPT boot partitions in CMOS mode, you were still out of luck.  As you’ll see, booting in EFI mode is actually more than just having a disk with the EFI files on it.  It’s a two-step approach, but those details will come later.

Finally, Windows 7 64-bit comes along and seems to solve our problems.   The OS install disk has EFI boot support on it.  The install disk is able to make bootable GPT partitions larger than 2.2tb.  Awesome.  But until this last month, you weren’t able to get your Intel RAID controller to make a bootable RAID set larger than 2.2tb because Intel hadn’t finished writing the EFI bios support for it.  You have to check the motherboard manufacturer’s website for a BIOS update – but you should now see new BIOS’s with the new large-partition RAID booting support.  That was the final key to the puzzle.

So, without further adieu, here is how one does this with the following equipment:

  • Asus P8P67 rev 3.1 motherboard (socket 1155 with 8 SATA ports and embedded Intel matrix storage controller) with BIOS flashed to version 1704 or higher
  • Three 2.0TB Hitachi drives all plugged into the Intel SATA ports
  • Windows 7 64-bit install DVD
  1. Back up everything
    The way I did it IS a destructive process and your drives will get erased.  There is no way that I know that you can migrate from a CMOS partitioning system to GPT.  There might be, but fiddling with this sort of stuff in a RAID setup is voodoo and you’ve been warned.
  2. Get and install the BIOS patch
    Be sure you are backed up at this point.  Asus bios flashing seems to always forget my RAID setup when I flash the bios.  In other words, poof – they’re gone.
    I went to Asus and found the newest BIOS patch. In my case it had the very clearly named:
    P8P67 (REV 3.1) 1704 BIOS – 2.2TB or larger HDD can be supported under RAID mode.
    I downloaded the patch file and put it on a USB key.  I then rebooted the machine and entered the BIOS setup.  Asus has a really nice built-in BIOS flashing utility with their new EFI BIOS.  I was able to point it at the USB key, find the image, flash the BIOS, and reboot. If the flashing forgot your RAID drives, then you’ll likely be greeted by a ‘no boot device found’ error.  You cannot safely re-create them if this happened.  The data on them is gone.
  3. Reboot your machine, and create your raid set
    With your BIOS patched, you should now be able to enter the Intel storage manager portion of the boot-up cycle via CTRL-I and create a large RAID set as bootable.  In my case, I selected: create a new set, selected the 3 drives I had plugged in, set the RAID configuration to RAID 5, 64k blocks, and made it bootable.  Save the changes and reboot.
    I find it extremely helpful and safer to shut off the machine, and physically unplug any extra drives you don’t want to get accidentally erased when manipulating RAID setups.  When you create the RAID set, you simply select the drives by serial number.  If you accidentally include a drive that (let say was your backup drive), the moment you add it to the RAID set – the data is gone. Be careful.
  4. Insert your EFI bootable Linux/Win7/Vista DVD, or USB key
    This is where you’ll need to consult your individual motherboard’s docs – and where things can get a little hairy.  For EFI booting on my ASUS board, I have to insert the EFI bootable media (in my case it was the Windows 7 x64 install disk), then reboot/turn the machine on.  Then I had to:

    1. press [DEL] to enter the CMOS setup during boot (with my Windows 7 disk in the drive)
    2. Go to the ‘boot’ menu in the CMOS
    3. Scroll down to list all the bootable devices (CD-Rom/Volume0 RAID set/etc)
    4. I saw the CD-Rom drive I wanted listed at the top, but that’s NOT the one you want.
    5. Keep scrolling down, and at the bottom you’ll see the device listed AGAIN but with the word EFI printed at the start of it.  THAT’S the one to choose.  It tells the system to boot from that device in EFI mode.  If you do NOT see your device listed a second time with the letters EFI in front of it, then that means the BIOS has not been able to find the key EFI boot files on the media you’re using.  In my case, my old Vista x64 disk wouldn’t allow me the option.  Why Asus doesn’t let you just manually set the mode to EFI only booting – I’ll never know.  I think it’s stupid they don’t let you, my old Intel DP35DP board let you do that…
    6. Select the device with the EFI bootable disk in it and tell the bios to boot.  You’ll notice that the fonts are different on startup, and that the cursor will do a funny indented thing during the boot cycle.  This tells you it’s in EFI booting mode.
  5. Boot the Windows install disk and create your partitions
    You should see the windows installer start just as normal.  When you get to the partitioning menu, you can select the auto-create option, and that should work.  However, this step is the MOST finicky and the place where you’ll find if you really are in EFI mode or not.  I chose the manual creation of the partitions and told it to make me the biggest one.  Sure enough, it said 3.7TB.  By default, you will get 2 other 100MB partitions created by windows for recovery purposes.  You can live without them, and they do not show up as drive letters in your system after it’s up.  Instructions on how to create your system without those extra partitions are here. The important thing is that you make SURE the partition is the right size at this point.  If it won’t create a 2.2+TB partition, or if it says it did, but the size is 2.2TB, then you’re not really in EFI mode or the Vista disk you have isn’t EFI bootable.  After you see that beautiful, full-sized partition – you might get a warning about the partition being potentially unbootable due to it’s size -but you can safely ignore it.  Just make sure that it actually created the partition.
  6. Finish the OS install as normal
    From here on out, follow the Windows install as normal.  On reboot, the motherboard will detect the GPT partition and properly boot in EFI mode automatically from here on out.  You’ll never need to do the selective EFI bios boot again.
  7. Install the Intel matrix storage manager software
    This really excellent software should be on your system.  If you have a UPS device on your system, I highly recommend turning the buffering on.  It allows for the drive read/writes to also be buffered in system memory.  It is dangerous without a UPS because a power loss means anything in the system buffer is lost, but delivers a noticeable speed improvement if you do have a UPS. Also, make sure to ‘Initialize’ the drives.  When you’re just fresh installed with windows, this is instantaneous.  Finally, this software is great because it’ll report any SMART errors your drives start throwing.  If a drive starts dying, it’ll warn you (hopefully) long before it finally goes bad.  I’ve seen this software work exactly as advertized when one of my own drives started failing in a previous setup.  It also gives you information about which drive is failing so you know which one to pull out and shows you status of any rebuilds when you swap in a new one – which can happen WHILE you’re actively using the system.  How cool is that?
  8. Done!  When you get into windows, you should have one large C: drive with all your space and no extra ‘boot’ drives!

I know many Linux afficianatos cringe at big bit buckets like this.   Put your swap on another partition!  Make a partition for your programs files!  Make a tiny one for your boot partition!  This is all well and good if you like micro-managing.  I hate micro-managing.  I hate extra drive letters.  We’re in the f-ing 2000’s now people!  3TB drives are $150, and 2TB drives are $65.  RAID comes built into boards for free.  Storage is a commodity.
I use Windows for most of my daily game playing/tv watching/etc and don’t want to futz with the headaches of multiple partitions.  I want to play games, watch tv, and surf the web.  I don’t want to have to worry about how big to make a partition for my programs files or data files or worry about how big my boot partition is on windows.  What if I over or under-guess?  I get to either re-install or test my luck with a partition resizer or have some programs one place, and others somewhere else.  Or the fun of every. single. time. I install a program, I have to select a custom install and pick a different drive letter.  Windows patches often automatically install in the system32 directory – what if a new service pack is too big to fit on my tiny boot partition?  It makes no difference for security if my boot is on a different partition than my data or programs.  Creating a separate partition on the same drive just for the swap file is no gain.  Unless it’s on another physical drive, you’re not gaining any speed in Windows.  And even then, I have 16GB of memory in my machine (and you can too – it’s ridiculously cheap at $60/8GB of high-quality DDR3 ram), I never swap anymore.

In short, I never have to worry about my space or what I’m putting where.  We’re not in the 70’s anymore where drives were real investments.  They’re cheap, replaceable commodities now.  I have a RAID 5 which means I’m getting the best of both speed and redundancy all in one place, and it’s details are taken care of by the hardware.  What more could one ask for.

A Windy Dog Mountain

A Windy Dog Mountain

Did an ‘easy’ hike (compared to Hood anyway) up Dog Mountain this weekend, and man was it windy.  Flowers on the upper peak were in bloom and beautiful, but man was it windy!  20-30mph sustained.

Good Hood climbing resources

Good Hood climbing resources

After make a successful climb of Hood, here are some of the helpful websites I used in planning:

Cascade Climbers – message board for folks that just did climbs/etc
http://cascadeclimbers.com/forum/ubbthreads.php/forums/7/1/Oregon_Cascades

Mountain Forcasts.com – Best source of wind/freezing levels/temperatures by elevation for many summits:
http://www.mountain-forecast.com/peaks/Mount-Hood/forecasts/2500

Mt Hood climb!

Mt Hood climb!

Had a GREAT time climbing Mt Hood on Saturday, Jun 11th.  Here is a flickr stream of photos:

   

http://www.flickr.com/photos/18696433@N02/sets/72157626828673343/

We left around midnight and it was a perfect night for climbing.  It was nicely in the mid-20’s (which kept the snow frozen for easier travel) and only 5-10mph winds.  We were about halfway to the crater rim from Palmer as sunlight starting coming out around 4am.  We hit the crater rim around 6am as I recall.  Fantastic views and we got really lucky with the cloud cover.  There was a lot of low-lying clouds around Timberline lodge level, but also a layer of really high clouds which kept the sun off the top of the mountain.  Keeping the sun off the top of the mountain is important later to prevent ice and snow from melting and falling from above.  But we  had a wonderful window between the two layers and enjoyed it.  We did the Old Chute route, and there were easily 50 other people doing climbs as well.  One or two groups did the Pearly Gates, but it was pretty icy and a good number of people switched over to the Old Chute for the way down.  The snow was nicely consolidated all the way up.

I did find out more about the slide that happened on Wednesday.  I took a picture while I was up there since it was the very route we had to take(!), and we think this is where it happened:
http://mattfife.net/special/shuteslide.jpg
The time of the slide was supposedly around 7am – which surprised us at hearing it had being so early.  Usually these sorts of slides happen after the sun has been shining for a few hours (noon/afternoon).  It was apparently a bunch of ice that fell off the wall and then slid down.  The lady who got hit did end up falling a couple hundred feet, sustained ‘a couple fractures’, and went to the hospital but was expect to make a full recovery.  It was small/mid-sized slide by the look of it and you could see where it had left big chunks laying around as we climbed up.  We’d had below freezing temps all night so there was nothing coming down; but the sun was shining directly on the wall section right where it had broken loose by the time we arrived.  Being new to Hood and climbing, I was a (understandably) worried but we got up and down as quickly as we could.  Since we got up there a little later than we wanted, we didn’t run across the summit ridge to get to the true summit.  The sun had been hitting the chute walls for well over an hour by the time we got up there, so we played it safe.  We got to summit ridge, took a good look around to enjoy the view,  and then came down again to be safe.

Most of the folks we ran into up there were really well prepared and safe.  As for poor form awards of the day, we ran into a ski patrol guy on the way down that said a lady had broken her ankle on the way down because she was glissading with her crampons on (a classic, big no-no).  Another guy had done the chute in the simple metal band crampons tied around his hiking shoes (not boots) and a hoodie (no coat, no pack/extra gear/etc).  He got stuck up at the top until someone who had found an extra ice ax (the one that the guy in the slide lost??) lent him it to go down with.

Oh, and a dog made the summit too. 🙂

Nice hike up to the top of Palmer on Mt Hood

Nice hike up to the top of Palmer on Mt Hood

Had a ridiculously sunny and warm day on Saturday.  In preparation for my attempt on Mt Hood this week, I did another hike up the climbers trail from Timberline lodge to the top of the Palmer lift (5,900ft-8,470ft).  Had amazing views and beautiful, sunny weather:

 

It was only about 1/2 the distance to the top (11,240ft), but was a great gear and stamina check.  I considered going higher, but I had started later and the snow was already pretty mushy.  That and I wasn’t going to go higher than the patrolled area alone.  Had to keep putting the SPF 50 on during the few hours I was up there and still got a lot of good sun.  It was so bright that the auto-white balance of the camera turned the blue sky black.

Overall, gorgeous day and great hike.

Gotcha’s of using ID3D11ShaderReflection

Gotcha’s of using ID3D11ShaderReflection

So, I am working on something that requires I programmatically know what’s in a DX11 shader file.  One of the cool things you can use to figure out how many constant buffers, get string names from position streams, etc – is the DirectX Shader Reflection system.  It gives you the ability to query a loaded shader blob for names/types/etc.  However, it’s not quite as straightforward as one might expect to use.  The docs were pretty incomplete up until the DX11 version.  But here’s the basics of the ID3D11ShaderReflection system:

  1. Load your vertex/pixel shaders.  Get the actual shader blob – or extract it from the FX system if you used that.
  2. Bind it to a shader reflection object using D3DReflect:
    pd3dDevice->CreatePixelShader( pPixelShaderBuffer->GetBufferPointer(), pPixelShaderBuffer->GetBufferSize(), g_pPSClassLinkage, &g_pPixelShader );
    ID3D11ShaderReflection* pReflector = NULL;
    D3DReflect( pPixelShaderBuffer->GetBufferPointer(), pPixelShaderBuffer->GetBufferSize(), IID_ID3D11ShaderReflection, (void**) &pReflector);
  3. Query the reflection object for whatever constant buffer, input/output stream, or other info you want using the many methods available.  It’s a GREAT way to test your shaders at load time so you don’t get cryptic runtime errors later when you try to actually draw objects.

Now, the gotcha’s:

  1. You must also include this:
    #include <D3DCompiler.h>
    Or you’ll get a compile error with D3DReflect() – despite the fact the official Microsoft docs seem to say you should (only) include:
    #include <D3DShader.h>
  2. Finally, you MUST have the DirectX SDK include directory listed before the windows include directory in the Visual Studio compiler include directory list or you’ll get compile errors in D3DShader.h. This is apparently because the windows headers that come with Visual Studio actually have a few DX definitions in them that conflict with the DX SDK header definitions.  
    In Visual Studio, check: Tools/Options -> Project and Solutions -> VC++ Directories and make sure Windows SDK include & library paths appear AFTER DirectX include & library paths.  See here for the thread.
iPhone programming – Learnings

iPhone programming – Learnings

From the wayback machine…

I found a half-completed post on when I was first learning to program on the iPhone.  I think these things are all still valid…
So, I’ve embarked on an ambitious programming project.  One that is now 1/3 of the way complete (first third was the ‘heaviest lifting’ part of the project – took about a month of outsourced grunt work).  The next 1/3 involves programming an app on the iPhone/iTouch.  I thought that would be the easy part, but as it turns out – there is a substantial learning curve that one should be aware of before starting this endeavor.  Here are some of the learnings I’ve found so far after having just got the bare bones of my own app up and running.

  1. Apple’s documentation is very robust – but frustratingly ‘useless’ at times.  They provide many very detailed and excellent vertical stacks of information.  Want to learn about pooled allocators?  They have a document that gives you all the information you could ever want.  But not in the context of how you’d actually use them – or why you hit various problems you hit.   You’ll find yourself sifting around from document to document trying to find out why your NSString object is throwing an exception when returning from a function – only to find the real reason is buried in the memory management section of the Cocoa programming guide – not anywhere near the NSString documentation or their samples
  2. You need to learn Objective C and Cocoa. – and learn them in THAT order.  It’s annoying, but try to find a good Objective C book first.  There aren’t many of them.  There are lots of bad ones though.  Learn how to write a class, add functions with multiple calling parameters, how to make calls to classes, and how allocation works.  That last one is key.  Really spend time learning why:
    [[NSString alloc] init]
    is the right way to allocate and initialize an object and then learn why:
    NSString *s = [[NSString alloc] initFromString:@”hello”];
    [s appendString:@”this string now leaks”];
    leaks memory.  And how the autoAllocator pools work/don’t work.  This is all huge and the first biggest gotcha’s your get hit with right off the bat.
  3. You’ll struggle to get even a 5 line program working at first.  Your first Objective C/Cocoa programs will be very painful.  The simplest things will feel like fighting a brick wall.  I tried to do a simple enum, and kept getting burned by an invalid class definition.  Wha?  The objective C compiler on the iPhone requires you typedef your enums and structs:
    enum newEnum { a, b, c, d }; (NOPE – will cause a compiler error in whatever line follows this definition)
    typedef enum { a, b, c, d } newEnum; (yes – works)
    Just millions of little things like that.  Again, logical if you put your old C/gcc hat on, but it’s been a bit since I last had that hat on and it had some dust on it…
  4. The GUI IDE is great – if you do things they way THEY want them and only for straight-forward designs.  The interfaces for GUI controls holds very much like Win32/X programming philosophies, albeit the syntax is very different.  X Code comes with it’s own WYSIWYG GUI editor, but I found it very limited if you’re going to come up with any kind of innovative interface.  If you just want some standard buttons/etc – you’re probably fine.  But if you want to have some interesting scrolling effects/etc – you best be ready to spend another few days learning how the UI control systems work underneath and experimenting.  The built-in GUI editor reminds me of the old VS2005 GUI editor that you could drag-n-drop controls, compile, and you’d see the results.  If you want any dynamic elements – I haven’t found a way to do that using their gui editor.  And if you want to embed controls on scrolling panels and some other more modern effects – you’ll be tossing the GUI editor altogether.  Trouble is, you spend a good bit of time learning how the built-in GUI system works, find out it won’t do the thing you need without tons of digging through forums and ‘tricking’ the thing to do what you want, then give up and have to learn a bunch of NEW stuff when you give up and decide to just dynamically/hand-generate the controls yourself.  Frustrating.



							
Advice from a manager

Advice from a manager

Interesting article in Fortune from someone who appears to be a good manager and author of the book “You Can’t Fire Everyone” by Hank Gilman.   I particularly liked him because he seemed like a ‘good’ manager.  i.e. he had the notion of treating his people with respect, and handling his job with class, professionalism, and style.  One of his un-stated guidelines he seems to have is that if you build a great work environment, then it will sell itself.  Keep that point in mind while reading the rest of this. Some of his points:

  1. The day your star employee decides to leave is the day you start woo-ing your player back again – it’s not a time to act like child, hold a grudge, or try to sabotage them.  New opportunities and a chance to grow/try something different come along for everyone.  It’s your job as a manager to get them to want to come back. Doing any of the aforementioned childish behaviors only sabotages your own reputation, future hiring, and long-term career.
  2. Try to keep them – if what they want is something you can give.  Know when it’s right to bend over to keep someone.  If it’s about money, get them some more. If it’s about title, do something about that (titles are only words anyway). But if they really want a new job – or need a change – let them take it.  People who think a good career move is a new title will likely be back in six months anyway.  Conversely, all the money in the world won’t keep someone who really wants or needs a change.
  3. Don’t bad-mouth their direction/new employer.  Even if you know the other company is bad or people there are cut-throat back-stabbers, don’t get involved in a petty squabble or words that might get back to the people you gab about.  Show your integrity at those moments.  If you’ve build a great work environment, then you can honestly say “Go off and have a great time. I think you have a great opportunity.  However, I’ve had enough of them and I believe you’re not going to get much better than what we offer.  You’re always welcome here.”  The grass isn’t always greener, but sometimes you just have to let them find that out on their own and welcome them back when they’re ready.
  4. Keep in touch – Make it a point to have lunch or dinner and remain friendly.  You have a scout in a new place if you want to recruit one of their colleagues. You also have a damn good reference in case you need to look for work!

He had other suggestions, but you get the idea of his style.  He shows how an other-directed focus gives your actions class and doing things with a style that makes people want to come back to him.  His advice is to not pout around like a child that didn’t get their way, burn up potential partners and bridges, and generally strangle your own career over the long haul because you’re too ego-centric.  If all managers worked in a similar way, then I think far more people would be happier in their work lives.