Acki, I have no problem converting from wide to narrow and back. Maybe it doesnt' work on other platforms, but it works fine with Win32/VC.
could anybody please answer the Jargon question
There are lots of issues with you code. The one that is most important is in your
SMApply function...
Code: Select all
Test = SMModDirectory->getText();
SMModDir[SelectedObject] = Test.c_str();
You set a string from the model directory edit box. That is all fine and dandy. You then cache that pointer in the
SMModDir array. The next time you click apply [or otherwise change
Test], the pointer you put into
SMModDir becomes invalid.
I encourage you to use a core::array<core::stringc> or similar for storing your mod dir array.
Something else that I also thought was weird...
Code: Select all
void GetModDir(const c8* fn)
{
c8 filename[1024];
strcpy(filename, fn);
c8* found = 0;
if (found = strstr(filename, ".DMF"))
You copy a string just so you can search it for a substring, all the while risking a buffer overflow. In addition to that, there is the issue of the parameter type. When calling this function, you create a temporary narrow string to pass in, and then inside the function you access the original wide character string. That is silly.
Code: Select all
// kill two birds with one stone... no buffer overflow, no temporaries.
void GetModDir(const wchar_t* fn)
{
if (wcsstr(fn, L".DMF") || wcsstr(fn, L".dmf"))
{
SMModDirectory->setText(fn);
}
if (wcsstr(fn, L".MD2") || wcsstr(fn, L".md2"))
{
SMModDirectory->setText(fn);
}
}
Travis