Sign in to follow this  
  • entries
    37
  • comments
    68
  • views
    46554

More on Asylum

Sign in to follow this  

291 views

I still haven't stuck a page up on the Meldstar Entertainment website because there isn't really anything to say. The project is still in the pre-production stages (in fact, I'd claim it's still in the research stage since I'm still working out how best to use OGRE and CEGUI).

The prototype of the state machine that I'm working on was further developed on the weekend. I finally added code to use CEGUI, with a singleton GuiManager class that does little more than init, deinit, and hand out references to certain CEGUI objects. I've also implemented the console (sans command management) and put in a menu.

Main Menu pic

Only the Play and Quit buttons work. There's nothing yet for Options or Profile to do so I haven't bothered implementing handlers for them yet.

Console pic

The console is implemented as a game state, and also inherits from Ogre::LogListener. So it gets to slurp anything put into the log file. In addition, anything typed in gets put into the console window, but as stated earlier, nothing else is done to it. Yet.

There is a problem that I am suffering with the console, however. It deals with removing old lines. The implementation of Ogre::LogListener::write() in this class is:


void ConsoleState::write(const Ogre::String &name, const Ogre::String &message, Ogre::LogMessageLevel lml=LML_NORMAL, bool maskDebug=false)
{
std::string constext(mConsole->getText().c_str());

// remove old lines if old text is more than 1k long
while (constext.length() > 1023 && constext.find("\n") != -1)
constext = constext.substr(constext.find("\n") + 1);

// add the new text afterwards
constext += message;

mConsole->setText(constext.c_str());
mConsole->setCaratIndex(constext.length() - 1);
}



The problem seems to be the "old line slurper" (lines 6 & 7 of the code) itself, but it doesn't manifest right away. (In the actual code it's commented out to keep the program from crashing.)

The crash itself takes place on line 13. For reasons I cannot discern, either std::string::length() or mConsole->setCaratIndex() takes offense to my code. Because I'm having problems with the debug memory manager of OGRE hating CEGUI's memory manager, I have to do Release builds which means I can't really trace the crash past this point. (Hopefully I can find some way of resolving the mem manager problem today and be able to debug properly.)

As well, CEGUI::String and std::string don't like working with each other. Unlike Ogre::String and std::string, which are actually the same (gotta love typedefs). CEGUI::String isn't std::basic_string like std::string is; in fact, CEGUI::String isn't a basic_string at all! Through various typedefs, CEGUI::String carries each character in a ulong, supposedly in Unicode UCS-4 format (also known as UTF-32). It might have probably been better off as std::basic_string where a utf32 class would exist with whatever's needed to convert characters between char and ulong. I mean, wasn't std::basic_string created as a template class for just this purpose?
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

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