bool upgradeFilesInTemp() { // Get path to temp files string tempFilePath = "temp/"; if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { tempFilePath = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + tempFilePath; } else { Config &config = Config::getInstance(); string userData = config.getString("UserData_Root",""); if(userData != "") { endPathWithSlash(userData); } tempFilePath = userData + tempFilePath; } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Temp files path [%s]\n",tempFilePath.c_str()); // Move all files into binary folder bool anyFailures = false; vector<string> fileList = getFolderTreeContentsListRecursively(tempFilePath, "", false, NULL); for(unsigned int index = 0; index < fileList.size(); ++index) { string fileName = fileList[index]; string newFileName = Properties::getApplicationPath() + extractFileFromDirectoryPath(fileName); bool result = renameFile(fileName,newFileName); if(result == false) { printf("FAILED Rename: [%s] to [%s] result = %d errno = %d\n",fileName.c_str(),newFileName.c_str(),result,errno); anyFailures = true; } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Rename: [%s] to [%s] result = %d\n",fileName.c_str(),newFileName.c_str(),result); } if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Successfully updated!\n"); return (fileList.size() > 0 && anyFailures == false); }
void NetworkInterface::DisplayErrorMessage(string sErr, bool closeSocket) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] sErr [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sErr.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] sErr [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sErr.c_str()); if(closeSocket == true && getSocket() != NULL) { close(); } if(pCB_DisplayMessage != NULL) { pCB_DisplayMessage(sErr.c_str(), false); } else { throw megaglest_runtime_error(sErr); } }
void Renderer::init() { assertGl(); GraphicsFactory *gf= GraphicsInterface::getInstance().getFactory(); if(gf == NULL) { gf= new GraphicsFactoryGl(); GraphicsInterface::getInstance().setFactory(gf); } Config &config = Config::getInstance(); if(config.getBool("CheckGlCaps")){ if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); checkGlCaps(); } if(glActiveTexture == NULL) { char szBuf[8096]=""; snprintf(szBuf,8096,"Error: glActiveTexture == NULL\nglActiveTexture is only supported if the GL version is 1.3 or greater,\nor if the ARB_multitexture extension is supported!"); throw megaglest_runtime_error(szBuf); } modelRenderer= gf->newModelRenderer(); textureManager= gf->newTextureManager(); particleRenderer= gf->newParticleRenderer(); //resources particleManager= gf->newParticleManager(); modelManager = gf->newModelManager(); modelManager->setTextureManager(textureManager); //red tex customTextureRed= textureManager->newTexture2D(); customTextureRed->getPixmap()->init(1, 1, 3); customTextureRed->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.f, 0.f)); //blue tex customTextureBlue= textureManager->newTexture2D(); customTextureBlue->getPixmap()->init(1, 1, 3); customTextureBlue->getPixmap()->setPixel(0, 0, Vec3f(0.f, 0.f, 1.f)); //green tex customTextureGreen= textureManager->newTexture2D(); customTextureGreen->getPixmap()->init(1, 1, 3); customTextureGreen->getPixmap()->setPixel(0, 0, Vec3f(0.f, 0.5f, 0.f)); //yellow tex customTextureYellow= textureManager->newTexture2D(); customTextureYellow->getPixmap()->init(1, 1, 3); customTextureYellow->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 0.f)); //white tex customTextureWhite= textureManager->newTexture2D(); customTextureWhite->getPixmap()->init(1, 1, 3); customTextureWhite->getPixmap()->setPixel(0, 0, Vec3f(1.f, 1.f, 1.f)); //cyan tex customTextureCyan= textureManager->newTexture2D(); customTextureCyan->getPixmap()->init(1, 1, 3); customTextureCyan->getPixmap()->setPixel(0, 0, Vec3f(0.f, 1.f, 0.8f)); //orange tex customTextureOrange= textureManager->newTexture2D(); customTextureOrange->getPixmap()->init(1, 1, 3); customTextureOrange->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 0.f)); //magenta tex customTextureMagenta= textureManager->newTexture2D(); customTextureMagenta->getPixmap()->init(1, 1, 3); customTextureMagenta->getPixmap()->setPixel(0, 0, Vec3f(1.f, 0.5f, 1.f)); glClearColor(red, green, blue, alpha); //backgroundcolor constant 0.3 //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); /* once the GL context is valid : */ //GLint alpha_bits; //glGetIntegerv(GL_ALPHA_BITS, &alpha_bits); //printf("#1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits); glEnable(GL_TEXTURE_2D); glFrontFace(GL_CW); glEnable(GL_CULL_FACE); glEnable(GL_DEPTH_TEST); glEnable(GL_ALPHA_TEST); //glAlphaFunc(GL_GREATER, 0.5f); glAlphaFunc(GL_GREATER, 0.0f); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); Vec4f diffuse= Vec4f(1.0f, 1.0f, 1.0f, 1.0f); Vec4f ambient= Vec4f(0.3f, 0.3f, 0.3f, 1.0f); Vec4f specular= Vec4f(0.1f, 0.1f, 0.1f, 1.0f); glLightfv(GL_LIGHT0,GL_AMBIENT, ambient.ptr()); glLightfv(GL_LIGHT0,GL_DIFFUSE, diffuse.ptr()); glLightfv(GL_LIGHT0,GL_SPECULAR, specular.ptr()); glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); glEnable(GL_COLOR_MATERIAL); assertGl(); }
void NetworkInterface::clearHighlightedCellList() { static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__); MutexSafeWrapper safeMutex(networkAccessMutex,mutexOwnerId); if(highlightedCellList.empty() == false) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] markedCellList.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,markedCellList.size()); highlightedCellList.clear(); } }
bool NetworkInterface::receiveMessage(NetworkMessage* networkMessage){ if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__); Socket* socket= getSocket(false); return networkMessage->receive(socket); }
NetworkMessageType NetworkInterface::getNextMessageType(int waitMilliseconds) { Socket* socket= getSocket(false); int8 messageType= nmtInvalid; if(socket != NULL && ((waitMilliseconds <= 0 && socket->hasDataToRead() == true) || (waitMilliseconds > 0 && socket->hasDataToReadWithWait(waitMilliseconds) == true))) { //peek message type int dataSize = socket->getDataToRead(); if(dataSize >= (int)sizeof(messageType)) { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] socket->getDataToRead() dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,dataSize); int iPeek = socket->peek(&messageType, sizeof(messageType)); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] socket->getDataToRead() iPeek = %d, messageType = %d [size = %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,iPeek,messageType,sizeof(messageType)); } else { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] PEEK WARNING, socket->getDataToRead() messageType = %d [size = %d], dataSize = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType,sizeof(messageType),dataSize); } //sanity check new message type if(messageType < 0 || messageType >= nmtCount) { if(getConnectHasHandshaked() == true) { throw megaglest_runtime_error("Invalid message type: " + intToStr(messageType)); } else { if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Invalid message type = %d (no packet handshake yet so ignored)\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,messageType); } } } return static_cast<NetworkMessageType>(messageType); }