Main page | About | Articles | Previous Posts | Archives

Thursday, June 29, 2006


I've been tinkering with Flash 8 a bit. I made a tank which moves around with the arrow keys and the turret follows the mouse cursor. Yes, I know the turret rotates wrong if you turn the tank.

ActionScript seems like a rather easy to learn language. I doubt I will start making anything "serious" with Flash, but I might have to code some ActionScript for a project soon so I thought I'd practice.

Regarding the game project, I've been pretty stuck. I've been browsing through the code but haven't written any. There's just something... wrong... in it. I think it's the batching thing. It's not as flexible as I'd want it to be, at least not at the moment. I think I'll have to make the changes to it which I was talking about here.

And I still hate the text drawing method. It's just so crap compared to how it works in winforms.

How it works now is that you pass a size, font, text and colors to a CustomText Control, which in turn creates a texture with the text and coloring and you can then place the CustomText control wherever you want to show the text at... the problem is that the text quality is so horrible. I want crisp fonts!
Adjusting the size and stuff takes quite much effort now.. it can be done this way too but meh... it's troublesome.

I know you could probably do something like bitmap fonts, but I find it clumsy.
Another method would be saving the whole block of text into a pre-made texture and using that, which would work fine for static text, but what if you want to make a list of... let's say, maps. That list can obviously change so you'd need to make a texture for the map text... not good.

Well in any case, I'll have to do something about the rendering. Also the z order stuff is troubling... I added z order sorting to the pipeline, but that doesn't work very well as things with the same z order may get a different rendering order which then may cause flickering.

This is one of the things what is wrong with the rendering. Previously I could just stuff things to it and render away and they would appear in correct order because the quad vertices were ordered properly. Now if I separated the pipelinebuffers so that the maps would have it's own and the objects and the GUI and they could each be rendered separately.. then I'd get rid of the z order prob too. First render the map, then the objects and then the gui. Problem solved. Of course there's also the issue of using the vertices Z position and the z buffer but that would make them appear wrong because I'm not using ortogonal projection.

Whatever. Maybe I'll get something done when I get bored with Sim City =)
And here's the link for today..
Here are some good MDX tutorials, including a pretty extensive ones about GUI.

Tuesday, June 27, 2006

C# snippets - create a "transparent" click-through window

I ran into this at the C# channel today.. One guy wanted to create a window, which would be on top of another app and if you clicked that window, the window would not get activated and the event would be sent to the app below it instead.

Here's the code you need to accomplish this:

These two WinAPI functions are required

static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

static extern long GetWindowLong(IntPtr hWnd, int nIndex);

Then the actual form/window is made "transparent" with this call (this.Handle being the forms' handle)

SetWindowLong(this.Handle,-20,GetWindowLong(this.Handle,-20) | 0x00000020)

The values (-20, -20 and 0x00000020) are respectively the following from winuser.h: GWL_EXSTYLE, WS_EXSTYLE and WS_EX_TRANSPARENT

And as a side note, I did end up installing SC4... and what have I been doing?... Well, playing it. Not coding like I should be! :]


Wednesday, June 21, 2006

Opera 9 has reached final

The Opera browser has now reached version 9 which adds lots of fixes and new features... Widgets, BitTorrent support, SVG vector graphic support and many small things.

Opera can be downloaded from here

When installing you may want to note that if you're installing on top of your old Opera installation and you are using a custom language, it may remove all text in any buttons and such, so make backups of your bookmarks and make a completely new install.

Also, if you can't find things like Widgets in the menu, Content blocking in the right click menu or such, you need to go to preferences, toolbars and choose Opera standard from "Menu setup"

And here's some links about why choose Opera:
Why I Prefer Opera over Firefox?
Why I Love Opera
10 reasons to choose Opera
30 days to becoming an Opera 8 lover
Firefox myths

Note that this one is not completely serious

Also, why do I keep typoing widgets as widgers?

Layout changes ahoy

I think I'm finally going to dump this ready-made layout this blog is using. I've made some changes as you might see (like the image in the header bar), but still it's a generic one.

I was thinking about something like the frontpage on my home servers site... Here's some experiments

Maybe even have it published there so I can use PHP/ASP.NET/whatever I want.

I will probably experiment with that when I have all the CSS stuff written for it.

Tuesday, June 20, 2006

Ideas for the Pipeline and GUI

Here are some drafts about things I'm thinking about changing in the batching class, RenderPipeline, I discussed earlier.

Move the Work() method into a separate class. Have this class hold PipelineBuffer-objects.

This way you could have very precise control over what to render, in what order, and when. The workerclasses could have a z-order in themselves or a container class like a game object manager or a GUI manager could contain one and render it if needed etc.

The pipeline would be modified to maybe contain references to these classes. By doing this, the PipelineBuffer could also be abstracted more, for example, to allow a MeshPipelineBuffer and a QuadPipelineBuffer. Though they could probably be more abstracted even the way they are now, but anyway.

Anyway with this method you could have more control over what's rendered, what buffer is associated with what object/objectgroup etc.

Also for the GUI, I was thinking about implementing some kind of a manager as you might've noticed above. The manager would handle positioning the controls and such.
As the screen is moved around, the GUI has to stay in one place obviously.

The GUIManager class could itself be a generic one, which could be inherited from to allow for different handling of input. You could probably also have multiple instances of it, so you could "group" different gui elements.
For example, a "game UI" which would contain the money amount, terrain details and such, and an "Object details UI" which would contain some boxes for showing details on a unit or a structure.

And regarding UI also, over here is a webcast from Microsoft's site about the input and GUI in a game called Rocket Commander. The rest can be found here, quite much intresting stuff in them and also the whole game sourcecode is available too.


Finding the location of a point in a certain Z depth

I've been trying to solve a problem for my GUI code...

If I unproject certain coordinates to the 3D space, I get a 3D Vector. Now, how to find out what that point would be in, let's say -5 Z instead of 0 Z?

I was kind of lost for a while about how the point could be found, but now I've finally found an answer!

//Let's say we want point 100 100

Vector3 point = new Vector3(100, 100, 0);


//Create near and far vectors

Vector3 near = new Vector3(point.X, point.Y, 0);

Vector3 far = new Vector3(point.X, point.Y, 1);


//Unproject them

near.Unproject(device.Viewport, device.Transform.Projection,

    device.Transform.View, device.Transform.World);

far.Unproject(device.Viewport, device.Transform.Projection,

    device.Transform.View, device.Transform.World);


//Create a plane at the z-depth (-5) we want to know the position           

Plane zplane = Plane.FromPointNormal(

    new Vector3(0, 0, -5), new Vector3(0, 0, 1));


//Intersect the line going from near point to far

//to get the result

Vector3 resultPoint = Plane.IntersectLine(zplane, near, far);

The result obviously depends on the viewport, projection and such of your device.

Ah well, now I can finally start thinking about the GUI placement.

Getting the GUI in some kind of shape would allow me to do lots of new things, like unit detail sheets, building new units (which was in with a very crap looking GUI), Attacking etc. so it's pretty vital to get it working properly!

And for the sake of mentioning other things, I've recently felt like reinstalling Sim City 4... doing that might be dangerous since I could forget anything about coding and just build a better city for my sims to live in... :]

It also looks like I might actually get something meaningful to do for this summer... I visited the company I do freelance-coding for yesterday and we had some talks about starting working on a Flash-project for a client. Would take the rest of the summer to work on that, and I'd get paid too, unlike when coding my own things ;)... Also, as I don't know Flash very well, I could also learn a bit of that though I will be mainly working on the ActionScript side of things.


Sunday, June 18, 2006


This time, I'll present you a documentary of my ventures into the magical world of Linux, the superior operating system! (note the sarcastic tone)

So I wanted to install mod_mono to my server machine so I can run ASP.NET applications with Apache.

I had to upgrade the kernel

First I tried to build it from the source, which didn't work however. Thinking how to get it back running, I decided to see if the Ubuntu discs I have contain a rescue mode (the box itself is using Debian).

Well they did but... the rescue mode somehow managed to garble the console so text editors and such wouldn't work!

Then trying to figure out how to get them running properly... well, I finally thought about trying "rescue debian-installer/framebuffer=false" boot option, which luckily fixed the issue and I got into a proper console, finally.

So I did the rescuing and stuff (I won't go into details, I'll just say it wasn't very easy). I later found out that I was supposed to compile something called cramfs into the kernel. Well, intrestingly enough the kernel menuconfig utility which is used to configure it before compiling didn't even have an option for it! I would have had to manually edit the config file (which isn't really a very big task, but anyway)...

I gave up with the idea of compiling the kernel and just downloaded a pre-built one from Debian packages. Thank god for that.

I had to install Mono

Mono wanted me to install a new version of libc6. Well, okay, I thought. Let's just switch to the unstable apt-get sources.

Now, then... the libc6 install wanted to remove the kernel. Yes, remove the kernel. Uhhh right! Let's remove it!... not!

Okay, time to go ask some people who might actually know something about this unlike I do!
[Quakenet] /j #debian

The wise man (thanks cortana) of the channel told me about a thing called backports, which might help me.. okay. I yet again change my apt sources.list to include backports and try to install the required things from backports... nothing again. Still running against the wall. I had also the pleasure of meeting Fangorn, the channel jester who absolutely loved me, because my nick (zomg) somehow offended him and "publicly insults religions" and I had also called him a faggot (which I absolutely did not) and whatnot. If you're ever reading this, Fangorn, I love you too!

Continuing my journey, I decided to try apt-get install'ing both libc6 and the kernel. Well well! It told me that kernel is already at the latest version and proceeded with the libc6 installation!. "zomg WINSSS - FATALITY!", I thought... but I was happy too soon.

Then began the fight to install libapache-mod-mono. It would require a specific version of apache-mono-server... which was, however, not even available from any of Debian's package sources! Oh man...

Trying to fix the thing again from backports with no success. Trying to compile it from the source code, which worked but I never got it working with apache...

I thought Ubuntu also had mod_mono, I had seen something about ubuntu and mono.
Looking up the ubuntu package page in Opera, I search their packages... and yay, they happen to have them!

Now, adding the ubuntu sources to my sources.list and updating the cache... apt-get'ing the files... everything worked smoothly. I got the things running, finally!

I wonder if my distro is called Debuntu now...

and finally, maybe some fun! Youtube-links, yay
"Apache" + Painkiller

Thursday, June 15, 2006

Input management

I was playing with an idea about how to manage different kinds of "input" (and also output) in a turn-based game. This stuff could probably be applied to non-turn-based games too.

For example:
-input from the local player through keyboard and mouse
-input from the AI "player"
-input from a remote player through a network connection

Now, the game engine has methods to do things in the game, like moving units around the screen and such. Now the thing is, how to express this information to the different types of "players" in the game.

A local player needs to see things on his screen:
-messages, menus, animation

AI needs to access the "raw" data

A remote player needs to get the data through the network:
-The data from the local machine must be sent through the network
-The game running on the remote host must parse the data and display it to the user

So the idea I'm playing with now is that the engine itself does not know what kind of a player it's sending the data to. The engine would just have a bunch of messages and states like...
-Waiting for input from player
-Waiting for confirmation of action
-Turn begins
-Unit selected
-Unit moving
-Unit reached destination


The engine would forward these kinds of messages to a IO handler class, which would implement some interface the engine uses. The IO handler class itself would then decide the course of action, depending if it's a "RemotePlayerIO" or "AIIO" or whatever.

For example, a LocalPlayerIO gets a message "Unit destroyed"... it plays an animation of a unit blowing up in the game and plays a sound, as where an ArtificialIntelligenceIO would do something like removing the unit from the DB or something.

The IO handler class would also be have to be able to query things from the engine, like "give me this unit's details" or "is there anyone in this tile?" and things like that.

Basically it would act as a proxy between the engine and the user(s).

Oh well. This is another of my gazillion or so ideas about all kinds of stuff.
There are more important matters than this, like making the GUI code (finally)... but for some reason I keep avoiding it and doing other stuff. Getting the GUI done would allow for some more progress, instead of adding "nice touches" or random things here and there.

It's summer holidays and what have I been doing? Sitting in front of the computer, writing code... nothing better to do I guess.


Tuesday, June 13, 2006

Batching code

Since it seems there's not much resources around regarding batching quads or such, and my batching code seems to be working fine, I thought I'd post it. Maybe someone can learn something from it (or hopefully someone will point out obvious mistakes from it so I can learn something, *cough* *cough*)

It's not ready
It probably does not work with other things than quads
It probably has bugs
It probably could be done better

The GEngine-class:
DeviceAvailable is true if the device can be rendered to
GfxDevice is the actual DirectX.Device

Here's the code

I tried to add some useful comments, but if something is unclear, ask away.

Basic usage:
Create some quads (which implement IPipelineable)
Use RenderPipeline.Add(foo) to add each of them into the pipeline
In the render loop, call RenderPipeline.Work() and RenderPipeline.Render()

Also, here's my Quad class. Probably useful for seeing the IPipelineable implementation
Quad code
This is probably even more WIP than the batching code
Contains old, pre-batching code because I'm lazy
Doesn't contain (much) comments, also because I'm lazy


Monday, June 12, 2006

User Interface

I'm reworking the classes I used for creating some simple GUI elements. The old classes I had were a bit bad I might say... not very simple to use as I'd like.

I'm currently working on a bit similar model as System.Windows.Forms.Control uses.

I have a "base" class called Control. It's basically a class which holds 1-9 Quad-objects.

Control c = new Control(Vector3.Empty, new SizeF(5, 10));






c.MouseOver += new EventHandler(c_MouseOver);

c.MouseOut += new EventHandler(c_MouseOut);

Okay and now the CopySourceAsHTML2005 plugin has been tested too.

So that's how the Control works. I also made a quick wrapper around the mouse events in a WinForms Control. The HookMouse() command hooks mouse events from the MouseManager and allows for functionality like MouseOver and MouseOut.

The Control initially holds a single Quad. When calling SetBorders, 8 more are added (top corners, top, left side, right side, bottom corners and bottom) which hold the actual border data. The whole block can only use a single texture, but I'm going to add UV-coordinate support and maybe completely different textures if I feel I'm going to use that.

The color methods are simple: They just set a Material with the color given as Emissive light. Works wonders! If you use a white texture like in the example code, the color shows up, not as white, but as pure red if you set it to red. Result will obviously be different if you set a texture which is not white, but then you can use the functions to create different tones or such.

I'm going to add support for adding child controls, and maybe for dragging and dropping the controls to other places and such.

I also need to add something to allow a Control to smoothly slide from the side to the middle of the screen or something like that. Transitions, or whatever they should be called. They could probably just be a bunch of Vector3's which define the start location and the result location... maybe something fancy, like a rotation.

Adding rotations would need matrixes though.. well, not necessarily, but I'm not going to work positioning all the different vertices by hand when they're turned or such! Maybe later.
Using a matrix translation for a menu transition or something would cause very little effect on performance. It would just require one another DrawIndexedPrimitives call anyway, as the whole menu could be batched using the same matrix, and the functionality for sorting quads into proper buffers is already in the RenderPipeline, I just need to add detections for matrixes there or such.

Gah. Maybe it would be time to go sleep. 7 AM... so it's getting kind of late.. or early, depending on how you like to think. ;)


Sunday, June 11, 2006

How to get more debug data from DirectX?

I thought I'd write up something on getting more details on debug stuff from DirectX with managed languages as there's not much stuff up about that.

Tired of the "InvalidCallException" or "InvalidDataException" or whatever comes up in your app, with no data on what might be the cause?

Well, for the users of Visual Studio Express Edition line, tough luck. Unmanaged debugging is only in "proper" Visual Studio's.

Okay here we go!

Step 1:
Go to your projects properties by right clicking it in the solution explorer and choosing properties. On the debug page, tick "Enable unmanaged code debugging"

Step 2:
Go to control panel and from there, DirectX. On the Direct3D tab, crank "Debug Output Level" to max, tick "Use Debug version of Direct3D" and "Break on D3D Error"
Then go to Managed tab and go to Microsoft.DirectX and right click on the assembly name/number and choose "Switch to debug version". Do the same for Microsoft.DirectX.Direct3D

Step 3:
Start debugging your app. You should see a tab called "Output" in the debugger. If not, go to View menu in Visual Studio and select Output.
The Output tab will contain the messages your app receives from the DirectX debugger.

This was quite helpful for me when I tried to figure out what was wrong with my rendering, as the map editor just kept on crashing without giving me any clues on what was going wrong. In the end, it was something as simple as missing device.VertexFormat = something definition.
The Direct3D error I got wasn't very helpful either, but after a bit of googling with it, I found an answer. More than I could ever find with "InvalidCallException" which is just waaaay too generic.

Seems the D3D debug also displays small tidbits like redundant state changes.
I mean, device.RenderState changes. If you are using a Pure device, they aren't filtered out and will probably result in decreased performance.

Another thing it seems to report is if a static buffer is locked more than twice in one frame, which is something which will cause a major performance hit if it's done often.

Maybe others too.

Saturday, June 10, 2006

Implementing batching

H'Ok, so here's the earth... no wait, this is not the end of the world...

So. I got the FPS issues fixed for now at least. I implemented something I call the "Pipeline". I like fancy names for simple things! Makes them sound... more complicated.

It's basically a bunch of dynamically created VertexBuffers and sorting algorithms.

To begin with, I changed my quad rendering code to use TriangeLists instead of TriangleFans to deal with the texture problem. I also added an IndexBuffer. That didn't affect the FPS (yet) as I was still doing waaay too many DrawIndexedPrimitives calls.

Well, okay. As I had mentioned earlier, I had succesfully batched vertices in the tile map and got a big FPS boost. Now as I had some code to generate a VertexBuffer and IndexBuffer with TriangleList-style rendering, I could batch them and the textures would appear correctly too.

So the batching worked wonderfully. There's a few things to mention though:
If I wanted to use lights for a quad, it would have to be separated from the batch (I use lights to dim tiles to highlight the area a unit can move to)
If I wanted to use a different texture, it would again have to be separated from the batch (except if using a texturemap and changing vertex U and V values)

So to cope with those, I create the Pipeline-class.

The basic principle of the Pipeline goes something like this:
-Create new quad(s)
-Add quads to the pipeline
-Have the pipeline process the quads
-Now you can render them using the pipeline

Now the magic of the pipeline is done in the processing part.

When adding quads to the pipeline, they first go into a list.

The Pipeline has a method which processes the quads added:
-Loop though "free" quads
-Check if there's a PipelineBuffer with similar features as the quad
-If we found a buffer, add the object to it
-If not, create a new buffer with the quads properties
-Clear free quad list as they should be assigned to a buffer now

Free quads are ones which aren't yet assigned to any PipelineBuffer

A PipelineBuffer is an object which holds quads. It can generate a VertexBuffer based on the quads and an IndexBuffer. It also contains details of the lights used, the material used and the texture used, so quads which can be batched together can be sorted from the free list and added to the buffer.
It also has flags determining the type of the vertexbuffer (dynamic or static) and if it's "dirty".

If a PipelineBuffer has the dirty flag, it means the data inside it has changed (like a quad has got a new light and can't be batched with the others anymore) and has to be re-initialized.
Quads in a dirty buffer are dumped back into the free quad list and re-assigned.

The dirty mechanism is done in a simple manner: a quad contains an event which is triggered whenever a value which makes batching different is changed (light, material, texture or dynamic/static flag). When adding a quad to the PipelineBuffer, the buffer adds it's handler for the event.

Comparing to the earlier batching, without indexbuffers and without batching the 15 or so units which were also rendered:
1. No batching, 20x20 map, about 15 units - 45 FPS
2. Batched 20x20 map, non-batched 15 units - 100-150 FPS
3. Batched 20x20 map and 15 units, with IndexBuffers - 650-750 FPS!

1. used 20 * 20 + 15 = 415 DrawPrimitive calls
2. used 16 DrawPrimitive calls
3. used 2 DrawIndexedPrimitive calls (units in a dynamic buffer, if not, one call)

All this good.. and something bad too: lightning broke up. For some reason, tiles using Diffuse lights show up in black now, no matter what I try. Any input welcome.
Using Emissive lightning for now, which works just fine.

Edit 10. Jun: About matrix translations:
Matrix translations are replaced with "vertex translations". I still use a location Vector3 structure, but I don't apply a World translation. Instead, I offset the vertices in model space when defining them. Works just as fine. Using a matrix translation would yet again need me to separate things from bathing.

And here's some links related...
Bitwise Flags with Enums (samples in C#,VB.NET and TSQL)
GameDev.net forum post on efficient rendering
A C++ article on drawing 2D in D3D using quads.. has some quad-batching examples
A very deep look into C# delegates and events


Google Analytics

A friend recently told me about a thing called "Google Analytics".

It's yet again something intresting from google. This time it's a traffic analyzer.

Basically you just insert a small javascript block in the end of the page you want it to track. After that you can look at the statistics from your google analytics page.

It tracks quite many things and gives pretty detailed reports. In addition to the usual there's a few more special things too.

-Visits and page view
-New and returning visitors
-Source of the visitors (the referer page)
-Visitor countries
-Top search engine keywords
-Top entrance/exit/content pages
-Lots of marketing related things
-Browser versions, Platforms (Win/Linux/etc), Screen resolution, Screen colors, Languages, Java enabled, Flash version, connection speed, hostnames

Lots of optimization reports.. on content, marketing and such.
and much more

You can apply for an account at their page at www.google.com/analytics/home/

Thursday, June 08, 2006

Tilemap rendering optimization

Getting rather horrible frame rates with lot's o' tiles, I decided to yet again foray into optimizing the rendering procedure...

For now what I've done...

I added a DumpVerts function into my Quad class. You give it a list as a param and it dumps the verts of itself into the list, transformed to the coordinates of the quad.

When the TileEngine class renders the map for the first time, it just initializes a huge VertexBuffer, dumps all the tile verts there, sets dumped flag to true... and that's it.

Gained 100 more FPS, which keeps fluctuating though... and the textures are b0rked for now at least...

The texture breakdown is probably caused by the fact that I use TriangleFans for rendering quads... and it would look like it tries to render a gigantic trianglefan.
So now I need to change the method I render the quads... very much completely. Bahhh. Why does anyone even bother to write tutorials where you do trianglefans when you'll eventually run into the fact that you get shit FPS and you need to batch things because a billion DrawPrimitves calls cause huge overhead.

Did also all the small things like reducing repeated device state sets etc.

I still don't want to get 40-140 FPS with a 20x20 map and a bunch of units in it. Bah. And the textures are broken... except for units which aren't using the dump-render method... yet.


Tuesday, June 06, 2006


I'm doing some major rework on the graphical side of my game.

The units for example, will need indicators for health or such that will stay with their own graphic when they move. I got that worked out, made a QuadStack class and a new Quad class with a dynamic vertexbuffer and some other optimizations on rendering. I'll probably replace the rendering in Plane object by inheriting it from Quad.

So anyway the QuadStack is basically an object which has a position in the world and a render method. Calling render first moves the world matrix to the stack's position and then calculates the positions for the quads in the stack. Their positions are all relative to the stacks position. (Stacks world matrix multiplied by Quad's world matrix)

I should probably make the stack act as a hit detector too, maybe allow it to forward click detection into the quads inside it as that would probably be useful.

The next thing on the road to graphical glory and photo-realistic effects is making an animation class, for the units and such need to have different types of animations. Idle, moving, etc.

I made a simple interface on top of my current method of exposing textures to the renderable objects, so I can have a static texture which will use the same methods or an animation which also uses the same methods, but returns different textures as the animation progresses. A very good idea, I'd dare to say!

I also made some sample code, yet again as people asked for help at #C#...
Detecting double clicks
A method for parsing Half-Life 1 server query replies

Double click detection code could use something to reset the click tick counter to zero after a doubleclick to prevent triple clicks and such causing more double click detects and the serverquery code could... well, use a more functional approach as there's lots of repeated code... but it works and if you care, you can refine it yourself and maybe learn something in the process.

On the other news, intresting search queries in google have landed people to my site:
intitle:index.of mp3 albums -htm -html -php -asp last modified
parent directory mp3 or wma or ogg or wav best_of or bestof or

Maybe I should add some pr0n-strings and metakeywords to get more visits. Har.
Anyway, I added a "use opera" button to the site, because it is a superior browser. Yes yes, you don't think so. Maybe you should check the feature list on Opera's beta 9? Maybe you should try it!

Also - AdSense - Just for fun. Let's see what happens.

Monday, June 05, 2006


No, not like the one you drive. Buggy code! (ha-ha)

I managed to do some work on my game project again. I've lately been badly distracted by the Hoff and his talking car and an anime series called Overman King Gainer.

Here and here are the latest screenshots of my project.

As you can see from the second picture, I've continued developing the map editor to the point where you can actually insert units (and structures, had I defined any - but they're not very finished yet) to the map. You can also define the players in the map and victory conditions (which do nothing at the moment, but they can be defined and saved/loaded anyway)

I thought I had yet again broken the picking code.. the units didn't get selected. In the end I noticed I had made some stupid mistakes.

1. the game tried to load the units owner from the wrong XML attribute
2. the game tried to assign players to the units before the players were loaded

There we see again. My code sucks! ;)

And I'm still having problems with the editor flickering and having glitches because of the DirectX-rendered panel. I had to resort to a hackyish measure to make a ColorDialog visible! (The Panel is hidden when the dialog is visible)

Seems MDX-knowledge is not very common...

Sunday, June 04, 2006

Google ebook hack

It's quite intresting how google can find massive amounts of ebooks on various subjects... if you just know how!

Here's a trick..

intitle:"index of /" KEYWORD ebooks size description date -filetype:html -filetype:htm

Replace keyword with your subject (for example, DirectX)

So you just type that into google and.. bang.

What's the secret behind all of that? Well, as you might know, usually file lists in webpages start with the big title "Index of /something".. so we want pages with that in the title (intitle:).. also, to filter off bogus results, we add words "size" "description" and "date" to the search.. as those words usually appear in file lists.

The work ebooks is used to find filelists with word "ebooks" in them. Change it if you want. The two -filetype parameters are also used to filter out bogus results... filelists do not appear as .html or .htm files, you know.

Google can be used in a myriad of ways. It's just the trick of knowing what to type in. Some people even say that you can find anything with it... which I don't really believe.

Well anyway, check out www.fravia.com.. that site contains huge amounts of information on searching the web. I found that ebook search trick from that site too, although I applied another trick a bit to come up with it.

If you're a lazy bastard who can't figure out things yourself, j0hnny has a large google hack database.

Saturday, June 03, 2006

Sudden code-rot?

I ran into a really weird error today while trying to make some progress with my game.

It would just keep throwing an InvalidCallException on the Device creation in the engine. I had done no changes to the code, no nothing.

I finally found out that in the code where PresentParameters for the Device are initialized, the Windowed property is no where set to true if the app runs in windowed mode!

And it had worked before! What on earth deleted a line or just decided to require it, all of a sudden? I had installed Hitman: Blood Money, and after that I hadn't compiled the game nor ran it... and as far as I know, Hitman didn't install any new DX binaries.

The InvalidCallException isn't very helpful. Not at all. It doesn't even point out what might have gone wrong...

I know that there's the DirectX debug version and such, and I tried it, but I didn't find a way to see what kind of messages it gave. I read they could be set to be visible from project props in VS and going to debug and setting "Allow unmanaged debug" or something like that... well guess what, there was nothing like that in VS Express. Gahh.