prevent errors on unknown events

This commit is contained in:
Robert Janetzko 2023-11-17 15:50:14 +01:00
parent 1cbaac47cd
commit bd631ebff9
6 changed files with 62 additions and 56 deletions

View File

@ -1,25 +1,4 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.5/containers/go/.devcontainer/base.Dockerfile ARG VARIANT="1.21-bullseye"
FROM mcr.microsoft.com/devcontainers/go:1-${VARIANT}
# [Choice] Go version (use -bullseye variants on local arm64/Apple Silicon): 1, 1.16, 1.17, 1-bullseye, 1.16-bullseye, 1.17-bullseye, 1-buster, 1.16-buster, 1.17-buster USER vscode
ARG VARIANT="1.18-bullseye"
FROM mcr.microsoft.com/vscode/devcontainers/go:0-${VARIANT}
# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
# [Optional] Uncomment this section to install additional OS packages.
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends graphviz cmake zlib1g-dev genisoimage
RUN cd /tmp && git clone https://github.com/hamstergene/libdmg-hfsplus \
&& cd libdmg-hfsplus && cmake . -B build && make -C build/dmg -j8 && cp build/dmg/dmg /usr/local/bin \
&& rm -rf /tmp/libdmg-hfsplus
# [Optional] Uncomment the next lines to use go get to install anything else you need
USER vscode
# RUN go get -x <your-dependency-or-tool>
# RUN npm install -g @angular/CLI
# [Optional] Uncomment this line to install global node packages.
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
RUN go install github.com/tc-hib/go-winres@latest \
&& go install github.com/goreleaser/goreleaser@latest

View File

@ -1,40 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // For format details, see https://aka.ms/devcontainer.json. For config options, see the
// https://github.com/microsoft/vscode-dev-containers/tree/v0.231.5/containers/go // README at: https://github.com/devcontainers/templates/tree/main/src/go
{ {
"name": "Go", "name": "Go",
"build": { "build": {
"dockerfile": "Dockerfile", "dockerfile": "Dockerfile",
"args": { "args": {
// Update the VARIANT arg to pick a version of Go: 1, 1.18, 1.17 "VARIANT": "1.21"
// Append -bullseye or -buster to pin to an OS version.
// Use -bullseye variants on local arm64/Apple Silicon.
"VARIANT": "1.18",
// Options
"NODE_VERSION": "lts/*"
} }
}, },
"runArgs": [ "customizations": {
"--cap-add=SYS_PTRACE", // Configure properties specific to VS Code.
"--security-opt", "vscode": {
"seccomp=unconfined" // Set *default* container specific settings.json values on container create.
], "settings": {
// Set *default* container specific settings.json values on container create. "go.toolsManagement.checkForUpdates": "local",
"settings": { "go.useLanguageServer": true,
"go.toolsManagement.checkForUpdates": "local", "go.gopath": "/go"
"go.useLanguageServer": true, },
"go.gopath": "/go" "extensions": [
"golang.Go",
"jinliming2.vscode-go-template",
"golang.go"
]
}
}, },
// Add the IDs of extensions you want installed when the container is created. "features": {
"extensions": [ "ghcr.io/devcontainers-contrib/features/apt-get-packages:1": {
"golang.Go", "packages": "genisoimage"
"jinliming2.vscode-go-template", }
"golang.go" }
],
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "go version",
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode",
"features": {}
} }

View File

@ -234,6 +234,7 @@ func parse{{ $obj.Name }}{{ if $plus }}Plus{{ end }}(p *util.XMLParser{{ if $plu
{{- end }} {{- end }}
{{- end }} {{- end }}
default: default:
obj.Details = NewHistoricalEventUnknown(string(data))
p.Skip() p.Skip()
} }
if err != nil { if err != nil {

View File

@ -8,7 +8,7 @@ buildMacOs:
GOOS=darwin GOARCH=amd64 go build -o ../bin/legendsbrowser-mac GOOS=darwin GOARCH=amd64 go build -o ../bin/legendsbrowser-mac
GOOS=darwin GOARCH=arm64 go build -o ../bin/legendsbrowser-mac-m1 GOOS=darwin GOARCH=arm64 go build -o ../bin/legendsbrowser-mac-m1
buildMacOsApp: buildMacOsApp: buildMacOs
mkdir -p /tmp/build/macos mkdir -p /tmp/build/macos
cp -r macos/LegendsBrowser.app /tmp/build/macos/ cp -r macos/LegendsBrowser.app /tmp/build/macos/
GOOS=darwin GOARCH=amd64 go build -o /tmp/build/macos/LegendsBrowser.app/Contents/MacOS/LegendsBrowser GOOS=darwin GOARCH=amd64 go build -o /tmp/build/macos/LegendsBrowser.app/Contents/MacOS/LegendsBrowser

View File

@ -1,6 +1,7 @@
package model package model
import ( import (
"encoding/json"
"fmt" "fmt"
"html/template" "html/template"
"sort" "sort"
@ -289,3 +290,34 @@ func (r *Reference) Html(c *Context) template.HTML {
func (r *River) Id() int { func (r *River) Id() int {
return r.Id_ return r.Id_
} }
type HistoricalEventUnknown struct {
EventType string
}
func NewHistoricalEventUnknown(eventType string) *HistoricalEventUnknown {
return &HistoricalEventUnknown{
EventType: eventType,
}
}
func (x *HistoricalEventUnknown) Type() string { return x.EventType }
func (x *HistoricalEventUnknown) RelatedToEntity(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToHf(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToArtifact(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToSite(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToStructure(siteId, id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToRegion(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToWorldConstruction(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToWrittenContent(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToDanceForm(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToMusicalForm(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToPoeticForm(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToMountain(id int) bool { return false }
func (x *HistoricalEventUnknown) RelatedToIdentity(id int) bool { return false }
func (x *HistoricalEventUnknown) CheckFields() {}
func (x *HistoricalEventUnknown) Html(c *Context) string { return x.EventType }
func (x *HistoricalEventUnknown) MarshalJSON() ([]byte, error) {
return json.Marshal(make(map[string]any))
}

View File

@ -25187,6 +25187,8 @@ func parseHistoricalEvent(p *util.XMLParser) (*HistoricalEvent, error) {
case "written content composed": case "written content composed":
obj.Details, err = parseHistoricalEventWrittenContentComposed(p) obj.Details, err = parseHistoricalEventWrittenContentComposed(p)
default: default:
obj.Details = NewHistoricalEventUnknown(string(data))
p.Skip() p.Skip()
} }
if err != nil { if err != nil {