(data []byte, comments map[string][]string)
| 238 | } |
| 239 | |
| 240 | func insertCombatComments(data []byte, comments map[string][]string) []byte { |
| 241 | if len(comments) == 0 { |
| 242 | return data |
| 243 | } |
| 244 | |
| 245 | lines := strings.Split(string(data), "\n") |
| 246 | var result []string |
| 247 | |
| 248 | for _, line := range lines { |
| 249 | trimmed := strings.TrimSpace(line) |
| 250 | if len(line) > 0 && line[0] != ' ' && line[0] != '\t' && trimmed != "" && strings.Contains(line, ":") { |
| 251 | key := strings.TrimSpace(line[:strings.Index(line, ":")]) |
| 252 | if commentLines, ok := comments[key]; ok { |
| 253 | result = append(result, commentLines...) |
| 254 | } |
| 255 | } |
| 256 | result = append(result, line) |
| 257 | } |
| 258 | |
| 259 | return []byte(strings.Join(result, "\n")) |
| 260 | } |
| 261 | |
| 262 | // SaveItemSpec persists an existing ItemSpec back to its data file and updates |
| 263 | // the in-memory cache. The ItemId must already be set. |
no outgoing calls
no test coverage detected