bool detectMSVCBuildDir(char *c_path) { std::string path(c_path); const char *ends[] = {"bin\\Release", "bin\\Build", NULL}; return (removeStringEnd(path, ends) != ""); }
bool Client::loadMedia(const std::string &data, const std::string &filename) { // Silly irrlicht's const-incorrectness Buffer<char> data_rw(data.c_str(), data.size()); std::string name; const char *image_ext[] = { ".png", ".jpg", ".bmp", ".tga", ".pcx", ".ppm", ".psd", ".wal", ".rgb", NULL }; name = removeStringEnd(filename, image_ext); if(name != "") { verbosestream<<"Client: Attempting to load image " <<"file \""<<filename<<"\""<<std::endl; io::IFileSystem *irrfs = m_device->getFileSystem(); video::IVideoDriver *vdrv = m_device->getVideoDriver(); // Create an irrlicht memory file io::IReadFile *rfile = irrfs->createMemoryReadFile( *data_rw, data_rw.getSize(), "_tempreadfile"); FATAL_ERROR_IF(!rfile, "Could not create irrlicht memory file."); // Read image video::IImage *img = vdrv->createImageFromFile(rfile); if(!img){ errorstream<<"Client: Cannot create image from data of " <<"file \""<<filename<<"\""<<std::endl; rfile->drop(); return false; } else { m_tsrc->insertSourceImage(filename, img); img->drop(); rfile->drop(); return true; } } const char *sound_ext[] = { ".0.ogg", ".1.ogg", ".2.ogg", ".3.ogg", ".4.ogg", ".5.ogg", ".6.ogg", ".7.ogg", ".8.ogg", ".9.ogg", ".ogg", NULL }; name = removeStringEnd(filename, sound_ext); if(name != "") { verbosestream<<"Client: Attempting to load sound " <<"file \""<<filename<<"\""<<std::endl; m_sound->loadSoundData(name, data); return true; } const char *model_ext[] = { ".x", ".b3d", ".md2", ".obj", NULL }; name = removeStringEnd(filename, model_ext); if(name != "") { verbosestream<<"Client: Storing model into memory: " <<"\""<<filename<<"\""<<std::endl; if(m_mesh_data.count(filename)) errorstream<<"Multiple models with name \""<<filename.c_str() <<"\" found; replacing previous model"<<std::endl; m_mesh_data[filename] = data; return true; } errorstream<<"Client: Don't know how to load file \"" <<filename<<"\""<<std::endl; return false; }