/** 清空场景编辑器数据 */ public static void clearSceneEditorData() { //清空目录 FileUtils.clearDir(ShineToolGlobal.scenePlacePath); FileUtils.deleteFile(ShineToolGlobal.serverSavePath + "/config/scenePlaceEditor.bin"); FileUtils.deleteFile(ShineToolGlobal.clientSavePath + "/config/scenePlaceEditor.bin"); FileUtils.deleteFile(ShineToolGlobal.serverSavePath + "/config/mapInfo.bin"); FileUtils.deleteFile(ShineToolGlobal.clientSavePath + "/config/mapInfo.bin"); //调用configExport ToolFileUtils.executeServerTool("configExport"); Ctrl.print("清空完毕"); }
/** 写合并项 */ private void writeCombine() { if (_sceneList == null) { return; } Ctrl.print("writeCombine"); IntSet sceneSet = new IntSet(); BytesWriteStream stream = new BytesWriteStream(); stream.writeLen(_sceneList.length()); for (int i = 0; i < _sceneList.length(); i++) { SceneConfig config = _sceneList.get(i); sceneSet.add(config.id); stream.writeInt(config.id); string path = getScenePlaceFilePath(config.id); byte[] bytes = FileUtils.readFileForBytes(path); if (bytes != null) { stream.writeByteArr(bytes); } else { stream.writeLen(0); } BytesWriteStream clientStream = new BytesWriteStream(); BaseC.config.writeConfigVersion(clientStream); clientStream.writeInt(config.id); if (bytes != null) { clientStream.writeByteArr(bytes); } else { clientStream.writeLen(0); } if (CommonSetting.configNeedCompress) { clientStream.compress(); } FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.sourceCommonConfigDirPath + "/scenePlaceEditor/" + config.id + ".bin", clientStream); } // FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.serverSavePath+"/config/scenePlaceEditor.bin",stream); FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.clientSavePath + "/config/scenePlaceEditor.bin", stream); //调用configExport ToolFileUtils.executeServerTool("configExport"); //移除无用的 string[] fileList = FileUtils.getFileList(ShineToolGlobal.sourceCommonConfigDirPath + "/scenePlaceEditor/", "bin"); foreach (string v in fileList) { int sid = int.Parse(FileUtils.getFileFrontName(FileUtils.getFileName(v))); if (!sceneSet.contains(sid)) { FileUtils.deleteFile(v); } } }
/** 写合并项 */ private void writeMapCombine() { if (_sceneList == null) { return; } Ctrl.print("writeCombine"); BytesWriteStream stream = new BytesWriteStream(); IntObjectMap <SceneMapConfig> dic = SceneMapConfig.getDic(); stream.writeLen(dic.size()); foreach (int k in dic.getSortedKeyList()) { SceneMapConfig config = dic.get(k); stream.writeInt(config.id); if (CommonSetting.serverMapNeedGrid || CommonSetting.clientMapNeedGrid) { string path = getMapGridFilePath(config.id); byte[] bytes = FileUtils.readFileForBytes(path); if (bytes != null) { stream.writeLen(bytes.Length); stream.writeByteArr(bytes); } else { stream.writeLen(0); } if (CommonSetting.clientMapNeedGrid) { BytesWriteStream clientStream = new BytesWriteStream(); BaseC.config.writeConfigVersion(clientStream); clientStream.writeInt(config.id); if (bytes != null) { clientStream.writeLen(bytes.Length); clientStream.writeByteArr(bytes); } else { clientStream.writeLen(0); } byte[] buf = clientStream.getBuf(); int len = clientStream.length(); if (CommonSetting.configNeedCompress) { clientStream.compress(); } BytesReadStream rs = new BytesReadStream(clientStream.getBuf(), 0, clientStream.length()); rs.unCompress(); byte[] rBuf = rs.getBuf(); int rLen = rs.length(); if (len == rLen) { bool isSame = true; for (int i = 0; i < len; i++) { if (buf[i] != rBuf[i]) { isSame = false; break; } } } FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.sourceCommonConfigDirPath + "/mapInfo/" + config.id + ".bin", clientStream); } } if (CommonSetting.serverMapNeedRecast) { string path = getMapNavFilePath(config.id); byte[] bytes = FileUtils.readFileForBytes(path); if (bytes != null) { stream.writeLen(bytes.Length); stream.writeByteArr(bytes); } else { stream.writeLen(0); } } } //写出服务器端配置 FileUtils.writeFileForBytesWriteStream(ShineToolGlobal.serverSavePath + "/config/mapInfo.bin", stream); //调用configExport ToolFileUtils.executeServerTool("configExport"); }