added comments

This commit is contained in:
Doc
2025-08-18 12:48:48 +02:00
parent 2af5bd222e
commit bb9a47cd6d
2 changed files with 19 additions and 0 deletions

View File

@@ -1,3 +1,5 @@
// Extrahieren der "Rohen" Lump-Bytes einer WAD-Datei
// siehe def Lumps: https://doomwiki.org/wiki/Lump
package wad
import (
@@ -31,6 +33,7 @@ type Wad struct {
path string
}
// Öffnen der WAD und checks
func Open(path string) (*Wad, error) {
f, err := os.Open(path)
if err != nil {
@@ -90,6 +93,7 @@ func Open(path string) (*Wad, error) {
return w, nil
}
// WAD Closing
func (w *Wad) Close() error {
if w == nil || w.f == nil {
return nil
@@ -101,6 +105,7 @@ func (w *Wad) Close() error {
func (w *Wad) Dir() []DirEntry { return w.dir }
// Lessen der Lump roh Bytes
func (w *Wad) ReadLump(i int) (name string, data []byte, err error) {
if i < 0 || i >= len(w.dir) {
return "", nil, fmt.Errorf("lump index out of range: %d", i)
@@ -118,6 +123,7 @@ func (w *Wad) ReadLump(i int) (name string, data []byte, err error) {
return name, buf, nil
}
// Extrahieren der Lump Namen aus den rohen Bytes
func (w *Wad) ReadLumpByName(name string) ([]byte, int, error) {
want := strings.ToUpper(name)
for i, d := range w.dir {
@@ -129,6 +135,7 @@ func (w *Wad) ReadLumpByName(name string) ([]byte, int, error) {
return nil, -1, fmt.Errorf("lump %q not found", want)
}
// Finden der Map( start und ende) in der WAD
func (w *Wad) FindMap(marker string) (start, end int, err error) {
m := strings.ToUpper(marker)
start = -1
@@ -151,6 +158,7 @@ func (w *Wad) FindMap(marker string) (start, end int, err error) {
return start, end, nil
}
// Laden der Map Lumps
func (w *Wad) LoadMapLumps(marker string, names ...string) (map[string][]byte, error) {
start, end, err := w.FindMap(marker)
if err != nil {