Sign in to follow this  
  • entries
  • comments
  • views


Sign in to follow this  


I've been quite busy lately, working on a variety of things, except what I should really be working on: 4e5 [grin]

1. Since my 4e5 game will be slightly fantasy based, and I'm going for a graphical style similar to Warcraft3, I figured I'd just write a loader for Warcraft3 models to use as temp art. So said, so started. Unfortunately, the format is barely documented. I did find one document which describes all the blocks, though not what they are for. Bar a few errors in that, I've been able to load the static base mesh, and am now in progress of loading the bones for the animation (I think). Will post screenies once I've actually added code to convert to my internal model format.

2. Abstracting renderer into DLL. I've always wanted to try this, so I decided to give it a go. My renderer was already quite self-contained because I work for multiple platforms, so it shouldn't be too much of a problem. I got the basic D3D sample off internet, and made it into a DLL. With a little help from Dave with compiling it, it seems to work. It doesn't do much yet, but it does work.

3. Something else I've been thinking a lot about lately is materials and vertex streams. Since my code is meant to work on machines which differ in power greatly, I need to get this right else it'll be a mess in client code. My current idea is to keep models and materials internal to the rendering system (which is modular) since it wouldn't usually be needed outside of that. I'm not going to worry about physics just yet [grin].

4. I've been using RakNet to add some multiplayer to my 4e5 entry. It'll make it easier to test the gamelogic and balancing while there is no AI yet. Connecting works, next step is to actually share the commands.

5. boost::any rocks! I figured I needed something to allow me to pass some arbitrary data into the DLLs for setup routines. I vaguely remembered boost had something, so I did a quick search. It turns out boost::any is exactly what I needed. Observe:



class PropertyList
void Insert( const std::string& name, boost::any value )
propertyMap_[name] = value;
void Remove( const std::string& name )
std::map::iterator iter = propertyMap_.find(name);
template< class T >
bool GetValue( const std::string& name, T& value )
std::map::const_iterator iter = propertyMap_.find(name);
value = boost::any_cast(iter->second);
return true;
catch(const boost::bad_any_cast &)
return false;
return false;
std::map propertyMap_;


PropertyList myList;
myList.Insert("astring", std::string("mytext"));
myList.Insert("anint", 5);
myList.Insert("afloat", 3.5f);

std::string st;
int i;
float f;
double d;

bool success = myList.GetValue("astring", st); // returns true
success = myList.GetValue("afloat", d); // returns false, and doesn't modify d
success = myList.GetValue("anint", i); // returns true
success = myList.GetValue("adouble", d); // returns false, and doesn't modify d

myList.GetValue("astring", st); // returns false, since astring removed

myList.Remove("me"); // no-op since "me" isn't there

It allows you to store any data in the PropertyList and access it extremely easily.
Sign in to follow this  


Recommended Comments

I wonder if you could integrate boost::lexical_cast into that as well - so that you can put something in as a int and get it back as a string without problems.

Share this comment

Link to comment
Although that seems like something nice, I'm not sure it's possible.

The syntax would theoretically be something like:

std::string myString = boost::lexical_cast<std::string>( boost::any_cast<int>( iter->second ) );

The problem being that you then need to store the type inside the boost::any (to pull out the correct type to put into the any_cast). At a quick glance, boost::any can return a std::type_info, but I don't know if you can use that to do the boost::any_cast<type here>.

You'd need to pass the actual type to the GetValue function as well, at which point, you could just as well do the lexical_cast after getting the value. Maybe someone with more experience with RTTI can help here?

Share this comment

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now