WFUTError WFUTClient::calculateUpdates(const ChannelFileList &server, const ChannelFileList &system, const ChannelFileList &local, ChannelFileList &updates, const std::string &prefix) { const FileMap &server_map = server.getFiles(); const FileMap &system_map = system.getFiles(); const FileMap &local_map = local.getFiles(); FileMap::const_iterator I = server_map.begin(); FileMap::const_iterator Iend = server_map.end(); for (; I != Iend; ++I) { const FileObject &server_obj = I->second; // Server side deleted? Just ignore for now if (server_obj.deleted) { UpdateReason.emit(server_obj.filename, WFUT_UPDATE_DELETED); continue; } // find the matching local one FileMap::const_iterator sys_iter = system_map.find(I->first); FileMap::const_iterator loc_iter = local_map.find(I->first); if (loc_iter == local_map.end()) { if (sys_iter == system_map.end()) { // No local version, or system version UpdateReason.emit(server_obj.filename, WFUT_UPDATE_NO_LOCAL); updates.addFile(server_obj); } else if (server_obj.version > sys_iter->second.version) { // Servere version is newer than sys version, and no local version UpdateReason.emit(server_obj.filename, WFUT_UPDATE_SERVER_SYSTEM); updates.addFile(server_obj); } else { // Assume the sys location is valid, so no need to update // No update required UpdateReason.emit(server_obj.filename, WFUT_UPDATE_NONE); } } else if (server_obj.version > loc_iter->second.version) { UpdateReason.emit(server_obj.filename, WFUT_UPDATE_SERVER_LOCAL); updates.addFile(server_obj); } else { // According to xml files, the local version is the same as the server // Lets check that it exists and has a matching CRC value. uLong crc32; if (calcCRC32(prefix + loc_iter->second.filename.c_str(), crc32) == -1) { // Can't read file, so lets add it UpdateReason.emit(server_obj.filename, WFUT_UPDATE_MISSING); updates.addFile(server_obj); } else { // Do a CRC check and warn user that the file is modified. if (crc32 != server_obj.crc32) { // Modified! UpdateReason.emit(server_obj.filename, WFUT_UPDATE_MODIFIED); } else { // No update required UpdateReason.emit(server_obj.filename, WFUT_UPDATE_NONE); } } } } return WFUT_NO_ERROR; }
bool EQPacketFormat::validate() { m_isValid = ((m_packet != NULL) && (crc32() == calcCRC32())); return m_isValid; }
bool Material::load(Param* param, const domCommon_color_or_texture_type* dom_common_c_or_t_type){ if(dom_common_c_or_t_type->getColor()){ param->type = Param::Param_Color; param->color[0] = static_cast<float>(dom_common_c_or_t_type->getColor()->getValue().get(0)); param->color[1] = static_cast<float>(dom_common_c_or_t_type->getColor()->getValue().get(1)); param->color[2] = static_cast<float>(dom_common_c_or_t_type->getColor()->getValue().get(2)); param->color[3] = static_cast<float>(dom_common_c_or_t_type->getColor()->getValue().get(3)); } else if(dom_common_c_or_t_type->getTexture()){ param->type = Param::Param_Texture; try{ param->sampler = new Sampler; } catch(std::bad_alloc& e){ Log_e("could not allocate memory.\n"); return false; } const char* sampler = dom_common_c_or_t_type->getTexture()->getTexture(); const char* texcoord = dom_common_c_or_t_type->getTexture()->getTexcoord(); #ifdef DEBUG param->sampler->texture.clear(); param->sampler->texture.append(sampler); param->sampler->texcoord.clear(); param->sampler->texcoord.append(texcoord); #endif // <constant> or <lambert> or <phong> or <blinn> daeElement* dae_elem = const_cast<domCommon_color_or_texture_type*>(dom_common_c_or_t_type)->getParent(); // <technique> dae_elem = dae_elem->getParent(); // <profile_COMMON> dae_elem = dae_elem->getParent(); const domProfile_COMMON* dom_prof_common = dynamic_cast<domProfile_COMMON*>(dae_elem); // <newparam> for <sampler*> domCommon_newparam_type* dom_newparam_type = find(dom_prof_common->getNewparam_array(), sampler); if(!dom_newparam_type) return false; if(!dom_newparam_type->getSampler2D()) // とりあえずSampler2Dのみ return false; if(!dom_newparam_type->getSampler2D()->getSource()) return false; const char* surface = dom_newparam_type->getSampler2D()->getSource()->getValue(); // <newparam> for <surface*> dom_newparam_type = find(dom_prof_common->getNewparam_array(), surface); if(!dom_newparam_type->getSurface()) return false; if(!dom_newparam_type->getSurface()->getFx_surface_init_common()) return false; // テクスチャを1枚制限にしているので最初の要素だけ抜き出す if(!dom_newparam_type->getSurface()->getFx_surface_init_common()->getInit_from_array().getCount()) return false; const char* image = dom_newparam_type->getSurface()->getFx_surface_init_common()->getInit_from_array().get(0)->getValue().getID(); #ifdef DEBUG param->sampler->image.clear(); param->sampler->image.append(image); #endif #if 1 daeDatabase* dae_db = const_cast<domCommon_color_or_texture_type*>(dom_common_c_or_t_type)->getDAE()->getDatabase(); domImage* dom_image; if(dae_db->getElement((daeElement**)&dom_image, 0, image, "image") != DAE_OK){ Log_e("element <image> %s not found.\n", image); return false; } const char* filepath = dom_image->getInit_from()->getValue().getPath(); std::string image_name; getFileName(&image_name, filepath); std::string temp; temp.append(path); temp.append(image_name); param->sampler->image_uid = calcCRC32(reinterpret_cast<const unsigned char*>(temp.c_str())); #endif } return true; }