message: add write string safe
diff: @@ -84,13 +84,22 @@ export namespace GameSetting {
  export function readFromString(str: string): GameSetting | undefined {
  return readFromStringRaw(str) as GameSetting
  }
  + export function writeToStringSafe(setting: GameSetting | any, original: string): string {
  + const model = readFromStringRaw(original) as any
  + for (const key in model) {
  + if (model.hasOwnProperty(key) && setting.hasOwnProperty(key)) {
  + model[key] = setting[key]
  + }
  + }
  + return writeToString(model)
  + }
  export function writeToString(setting: GameSetting | any): string {
  return Object.keys(setting).map(key => {
  const val = (setting as any)[key];
  if (typeof val !== 'string')
  return `${key}:${JSON.stringify(val)}`
  else return `${key}:${val}`
  - }).join('\n')
  + }).join(os.EOL)
  }
  }
  