/** 写回 */ public void write() { Ctrl.print("保存场景", config.id); if (_stream == null) { _stream = new BytesWriteStream(); } else { _stream.clear(); } _stream.writeLen(elements.size()); foreach (int k in elements.getSortedKeyList()) { ScenePlaceElementConfig scenePlaceElementConfig = elements.get(k).config; scenePlaceElementConfig.writeBytesSimple(_stream); } string path = SceneEditorWindow.getScenePlaceFilePath(config.id); FileUtils.writeFileForBytesWriteStream(path, _stream); }
/** 写合并项 */ 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"); }