Wednesday, 15 December 2010

Civ and Code

So, what have I been up to?  Well, since the yule tide is rolling over us I've been incredibly busy at work.

I have however been enjoying Civ5, I'm reasonably happy to play the game, though in DirectX 10 mode is does crash out sometimes.  Hopefully the up coming patch for it will sort somethings out.

In the world of code, especially at work though, I have been very busy.  I have a project to put together, but as an aside I've been looking at the boost C++ libraries, one little ditty I recently had to sort out was a hostname resolver for IPv4, here is that C++ for anyone interested in boost:

// Investigation into Boost - 14/12/2010
// (c)2010 - Jon Bond

///
/// Function to resolve a URL as an IP Address
///
std::string ResolveURLAsIPv4 (const std::string& URL, const int Port)
{
#ifdef _DEBUG
char* msg = Debugging::AssignMessage(128);
sprintf_s (msg, 128, "ResolveURLAsIP (%s : %i)", URL.c_str(), Port);
OutputDebugStringA (msg);
DWORD StartTick = GetTickCount();
#endif


std::string result = "127.0.0.1";

try 
{
// Construct the resolver service we're going to run
boost::asio::io_service IOService;
boost::asio::ip::tcp::resolver resolver(IOService);

// Set up the IP query we're going to run on the resolver service
boost::asio::ip::tcp::resolver::query query(
boost::asio::ip::tcp::v4(),
URL,
boost::lexical_cast(Port) );

// Set up the query we're going to iterate through
boost::asio::ip::tcp::resolver::iterator i = resolver.resolve(query);

// Iterate through all the end points returned by the DNS query
boost::asio::ip::tcp::resolver::iterator endIterator;
for ( ;
i != endIterator;
++i)
{
// Get the current end point indicated
boost::asio::ip::tcp::endpoint currentEndPoint = *i;

// Process the result
if ( currentEndPoint.address().is_v4() )
{
result = currentEndPoint.address().to_string();
// break out of the loop
break;
}
}
}
catch (std::exception e)
{
#ifdef _DEBUG
sprintf_s (msg, 128, "Error in ResolveURLAsIP.");
OutputDebugStringA (msg);
delete msg;
#endif

throw e;
}

#ifdef _DEBUG
DWORD Diff = GetTickCount() - StartTick;
sprintf_s (msg, 128, "ResolveURLAsIP Complete [%d] %s => %s", Diff, URL.c_str(), result.c_str() );
OutputDebugStringA (msg);
delete msg;
#endif

return result;
}
Please note, I know I could cut down the number of boost::asio:: whatever indirections by using 'using' statements, but this is fully written out so I could understand what was going on.

The other ditty I've been playing with is Direct2D as part of DirectX 10 on Vista & Windows 7... here's my class to initialise the Direct2D interface:

// Investigation into Direct2D - 3/12/2010
// (c)2010 - Jon Bond

#pragma once

// The program main
#include "..\Program\Program.h"

// Include the header
#include "D2D1.h"

// Include the library
#pragma comment (lib, "d2d1.lib")

namespace GuiMain
{

// The gui
class Gui
{
private:
// Shows whether there has been an error
bool m_Error;

// The window handle
HWND m_WindowHandle;

// The factory
ID2D1Factory *m_Factory;

// The render target
ID2D1HwndRenderTarget *m_Target;

// Factory handlers
void SetupFactory();
void CloseFactory();

// Create the resources
void CreateDeviceResources();
void ReleaseDeviceResources();

// Get the window size
D2D1_SIZE_U GetWindowSize ();

// A white solid brush
ID2D1SolidColorBrush* m_WhiteBrush;

public:

// The gui constructor
Gui (HWND WindowHandle);

// The gui destructor
~Gui ();

// Draw something
void Render ();

};


}

Code:

// Investigation into Direct2D - 3/12/2010
// (c)2010 - Jon Bond
#include "GuiMain.h"

namespace GuiMain
{

// Constructor
Gui::Gui(HWND WindowHandle)
{
m_Error = false;

// The window handle
m_WindowHandle = WindowHandle;

// Set up the factory
SetupFactory();
}

// Destructor
Gui::~Gui()
{
// Release the device drawing resources
ReleaseDeviceResources ();

// Close the factory
CloseFactory ();

m_WindowHandle = NULL;
}

// Set up the COM class factory for this interface
void Gui::SetupFactory()
{
HRESULT hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_Factory);
if ( hr == S_OK )
{
CreateDeviceResources ();
}
}

// Close the factory
void Gui::CloseFactory()
{
// Release the factor, if it exists
if ( m_Factory != NULL )
{
m_Factory->Release();
m_Factory = NULL;
}
}

// The device resources
void Gui::CreateDeviceResources()
{
HRESULT hr ;

hr = m_Factory->CreateHwndRenderTarget(
D2D1::RenderTargetProperties(),
D2D1::HwndRenderTargetProperties(m_WindowHandle, GetWindowSize()),
&m_Target);
if ( hr != S_OK )
{
m_Error = true;
}
else
{
// Create the white brush
hr = this->m_Target->CreateSolidColorBrush(
D2D1::ColorF(D2D1::ColorF::White),
&m_WhiteBrush);

if ( hr != S_OK )
{
m_Error = true;
}
}
}

// The release the device resources
void Gui::ReleaseDeviceResources()
{
m_WhiteBrush->Release();
// Dispose of the tar
if ( m_Target != NULL )
{
m_Target->Release();
m_Target = NULL;
}
}
// Return the screen size
D2D1_SIZE_U Gui::GetWindowSize ()
{
RECT rect;
GetClientRect (m_WindowHandle, &rect);
return D2D1::SizeU(rect.right-rect.left, rect.bottom-rect.top);
}
// Render something
void Gui::Render ()
{
m_Target->SetAntialiasMode(D2D1_ANTIALIAS_MODE::D2D1_ANTIALIAS_MODE_PER_PRIMITIVE);
m_Target->BeginDraw();
m_Target->Clear(D2D1::ColorF(D2D1::ColorF::Black));
m_Target->SetTransform(D2D1::Matrix3x2F::Identity());
D2D1_SIZE_U size = GetWindowSize();
m_Target->DrawLine (
D2D1::Point2F(0.0f, 0.0f),
D2D1::Point2F(size.width, size.height),
m_WhiteBrush,
0.5f
);
m_Target->EndDraw();
}
}

Please note, all my code here is copyright 2010 - Myself, but you may use it as you see fit.  So long as you leave my copyrght notices and name on the code.

Monday, 6 December 2010

Its time for 'it'

So, it is about to happen... if you don't know what I mean by 'it' then you've been living under a rock, because the 'it' to which I refer is Cataclysm.

I'm going to be honest, I have been back, briefly into WoW; I had a month on my main account a while back, but I was hopelessly annoyed at the inflation of items over my hard earned raid gear... so I quit again.

But now, it is the day, before the big day.  And I'm feeling a few pangs of longing, even though I'm pissed off utterly with the inflation in the game, I love its look, I love the game; I'm just so tired and bored of it.

And I'm going to miss Loch Modan, I'm going to miss Stormwind, I'm going to miss all those lands we've all spent so long living in.

Okay, I'm not going to miss Outlands, nor am I going to give a shit about Northrend.  But as I consider myself a veteran player of the original game, and I spent the best part of three years just playing out those area's, I am going to miss them.

The questions are... when will I go in to take a look at everything that's going on?  And will I miss it all going on "live" because its happening on a Tuesday and I'm at work?

Monday, 22 November 2010

The Chore of No Game

So, I've recently been wrestling with a new PC build... well, not so much wrestling as oiling up and pressing myself against its sheer sexual energy.

But the failure of my old rig really cut into my regular play time, so much so, that the dreaded lady of the house seems to think that I should always have a lot of time to watch X-Factor and the like with her on a Saturday night... Oh Lord above save me!

But I have actually managed to get two games installed now, first off Eve, which I have all three accounts training on thanks to 5 free days on each from CCP... I'm not re-subbing to Eve just yet, with so much expenditure recently I can't justify it.

Likewise, I've not looked at any of the F2P MMO's (D&D, LOTRO or RoM) which I was playing previously, mainly because I will have to wait for vast amounts of data to download in order to get into them...

But I have put CIV5 back on the machine, thanks to Steam and the superior bandwidth Valve get it was a breeze.  And over the weekend I enjoyed a decent random game as the French, when I busily wiped the smug Samurai smile off of Japan's face.

Another thing I have been up to though is selling off lots of my old PC parts on the old auction sites.  I had hoped the CPU in my old Quad Core rig (its Core 2 Quad Q6600 2.6GHZ) would have survived the destruction wrought in my old rig dying, but it seems its not, dropping it into another Core2 Quad able mobo I have and it seems to be dead as a door nail... Hey ho, onwards and upwards with my eight thread true quad core and 12GB of RAM... Roar.

Friday, 12 November 2010

The Good, The Bad and the Intel...

Just a quick new post, first of all, the good... I've had a stinking cold for like a week, and it has kept me up all night, but finally after forcing myself to stay in bed and doing a lot of Vitamin-C I feel better.

The Bad... My main PC has died, it is no more... my prior post about patching out the broken piece of memory was just holding off the inevitable, and it burned out the motherboard.

This leads me to the Intel, I've just placed an order for a new Core i7 - 950 chip, a nice Asus motherboard and 12GB of DDR3 from Corsair.

The bad news is between now and then I'm using my old P4 (which is still a nice P4 HT 3 ghz).

Monday, 8 November 2010

Remember, Remember the Month of November

Well, it's been a busy busy old time for me, so appologies to anyone out there wondering why I was not sending out my moaning groaning vibe.

So here we are, it's November... A month of Rememberance here in Britain, on the 11th we Remember and mark the end of the First World War, and reflect on the losses our armed forces have suffered then and ever since.

Having one grand father a veteran of the Battle of North Cape and D-Day aboard HMS Belfast, the other a veteran of the British Expeditionary Forces who fled the beaches of Dunkirk and whom later was part of the return at Normandy; not to mention one Grandmother who tended the wounds of returning USAAF Airmen and another in the British Land Army.

I find myself taking a moment to remember them.
They went with songs to the battle, they were young.
Straight of limb, true of eyes, steady and aglow.
They were staunch to the end against odds uncounted,
They fell with their faces to the foe.
They shall grow not old, as we that are left grow old:
Age shall not weary them, nor the years condemn.
At the going down of the sun and in the morning,
We will remember them.


Friday, 22 October 2010

#71

So, it seems Darren over at common sense gamer is no longer a gamer and no longer applying his common sense... Darren, you're a near scientific sounding chap at times.... science has to stay 250 yards from religion at all times... what are you thinking man?

(He's branched out into a new blog about philosophy and the meaning of life... the answer is 42 mate, thanks for all the fish, etc etc).  Go check that out at his new site Ethos Incarnate.

But Darren is the reason I'm back here to post again, I have his SUWT recordings lying around and have listened to them, but for some reason I missed part of the listeners mail section in #71.  This is the follow up cast to the one featuring myself and Mr Richard from over at GeekRageQuit.  And I had to laugh at what I heard...

Darren explains that the second writer to him... "Tevaco" or "Teveco" I can't be sure with the accent :) wrote to Darren and complained he found my comment strange, that really WoW isn't and MMO, but yet I then went on to explain a core concept of an MMO, i.e. I described my explaining to a friend about the character classes...

I think poor old "Teveco" missed my point... the point was... I sat here, exactly where I am sitting now, with World Of Warcraft on my screen, I'm sat in my Mage and I'm in the middle of the Ring of Trials... and my friend leans over...

F: "Hey Xel, who's that?"
X: "That's me, I'm a mage, see the fireballs, whoohooo glass cannon"
F: "Oh, right, and who's that?"
X: "That's a druid."
F: "That looks cool, he's a tree and a person at times, what's he doing?"
X: "Well, Druids can heal, like when he's in the tree form, and they can do damage as a caster or cat form, or they can be the tank to soak up damage."
F: "Oh cool, three things."
X: "Oh a lot more than that, they're like the original swiss army character, they even have a form to get stones out of horses shoes."
F: "Right, so who's he there then?"
X: "Oh that's the newer class, the Death Knight"
F: "What can he do?"
X: "He can do a damage, or tank and heal himself a bit".
F: "So what can your mage do?"
X: "I do damage high damage per second, I nuke stuff"
F: "Can you heal?"
X: "No, not at all."
F:  "Oh. What's that guy there do?"
X: "Oh that's a rogue, he just does damage too, he can't  heal"
F: "Hang on, so him and him can do many things, you can only do damage, doesn't it get boring?"
X: "A bit repetative yes."
F: "Doesn't seem very fair to me.  So what's that last guy over there do?"
X: "That's a paladin."
F: "Let me guess, he does everything?"
X: "Yup".

And that's the moral of the story, not about the character class, its funny how my friend saw the unfairness of one person being limited to one thing and others being let hog wild.

We went on to discuss the situation, and I had an attack of the memory lanes, when in vanilla wow up to level 60, right up to BWL and ZG really, each person had a role to fill, and each class was seen only one or two ways.  It's only with the esculation of gear and skills and talents and enchants and gems and scrolls that really some glasses have homogenised into the same sort of role in groups, while others have ben further specialised to just a couple of tasks.

I mean, there's no doubt early on in the history of WoW a Druid who was specced for levelling was a poor healer in instances, and so healing fell much more often to Priests and Paladins at that stage, but soon with multi speccing, bigger mana pools from multiple high level, easily obtainable, gear Druids could choose to be a jack of all trades much more easily... In fact on the servers I played on, but PVP and PVE, for a long while Druids were the choice healer for their heal over time abilities....

So, to Teveco, I hope; where ever you are out there; you read this and chuckle along with me...

And to Darren, the first listener mail in show #71... what did he mean "new blood, but not really"? Me and Rich were virgins, you took our podcast cherries, if I recall correctly.... :)

Thursday, 21 October 2010

The "Low Velocity High Impact Reset"

So, my Office PC just went off to the IT Department for upgrading from Windows XP to Windows 7... yay...

But, not yay, after 3 minutes my phone rang:

"What have you done to this machine?"
"Nothing", was my immediate reply
"Well, it doesn't turn on"

Silence

More Silence

"What do you want me to do about this?"  Was my tentative question.
"Nothing, I'm just trying to work out what you've done?"
"Well, I turned it on at 6:30am worked on it until about 11am and then shut it down unplugged all the cables and hefted it on my man boobs over to you."
"Right, well the man boobs have killed it"
"I'll be over in two minutes" and I set off back over to sort this out.

Interior IT Office, much applause.

I wave a cursory greeting and go stand over my now open, sad looking PC.

I earth myself, pull the power and press all the RAM, Graphics, CPU and connectors generally in view into place.

I try to power it back up, nothing... the IT chap is looking happily smug my doing this did nothing...

So I have an idea... "Have you tried a low velocity high impact reset?"  I asked...

"No, wha..."

And before the chap could question me further I hefted the case about 2 inches off the desk and dropped it.

It immediately powered on.

As the shock and awe slipped from his face, I looked at his smooth cheeks, his still shining eyes, un-dulled by the march of time... and I ask...

"You're too young to have had an 8 or 16 bit Computer, am I right?"

"I'm 21, I had a Windows 95 PC" he said defensively.

"Yes, but Windows 95 would have been what, on your 486 CPU?.. you never had a dodgy Apple II or Atari ST where you had to reseat the chip set every so often... that's what I just did... Something was out of socket and now it's in... I just hope I've not got any dry joints"  I eagerly await some retort, and I'm not let down by the classic...

"What have your knees to do with anything?"