Big Bucket Software you like to use
More news on the Pocket PC front
November 24th, 2005

So I got the latest MAGE working on the Pocket PC last night. What a huge pain. I’m really going to need to start thinking about profiling this thing; moves… so… slowly! Oh well.

My first major problem was the number of exceptions being thrown during initialisation. This process took a long, long time. After actually thinking for a moment, it occured to me that the offending piece of code must have been this:

    try
    {
        return lexical_cast<int>(lhs) < lexical_cast<int>(rhs);
    }
    catch (bad_lexical_cast&)
    {
        return lhs < rhs;
    }

This function will ensure that strings will be sorted numerically first, and alphabetically second. Very handy as a predicate for a std::map. I need this for my key/value config to ensure that an animation with more than 10 frames will be ordered correctly, that is "0,1,2,3" as opposed to "0,1,10,2,3."

Anyhoo, as it turns out, throwing exceptions on the Pocket PC is a Bad Idea. As I currently don't have any animations with more than 10 frames, I just ripped out the lexical_cast bit, and things started working... almost.

My next problem was that my SDL_Image.dll did not have PNG support compiled in! If only I had been using SDL_GetError I would have noticed the very obvious, an "unsupported file type" rather than a missing file. Thankfully, Chris had already compiled the necessary DLL, so I just plonked that onto the Pocket PC and hey-presto.

Glad that's sorted. Now it's just a matter of fine-tuning the vcproj, checking it into my subversion repository and modifying (and renaming) my refresh_project_jamfile script to ensure the vcproj is refreshed as well. No biggy.

In other news, I'm working on my first engine tutorial and the next game scene. Stay tuned.

  • Hi Matt.

    Exceptions are probably the slowest and most variable part of C++; in general, they should be used for propagating error conditions non-locally only.

    I don’t see why you need them here, though.

    I assume your functor is templated on the type of lhs and rhs. Can’t you use boost type traits to ascertain whether or not you can do a numeric comparison?

    If I have the wrong end of the stick, can you please show more detail on what you’re doing?

  • Hi Matt,

    Sorry, but my code snippet wasn’t clear (or correct). I’ve made the correction. The reason I can’t use type_traits is because the data that I’m trying to lexical_cast are both std::strings.

    I attempt to lexical_cast to an int both strings and catch the exception. In the case of an exception, I use the std::string less than operator. This ensures numeric then alphabetic ordering.