queryciv3

package
v0.4.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2021 License: MIT Imports: 12 Imported by: 0

README

queryciv3

QueryCiv3 implements a GraphQL API into a Civ3 SAV & BIQ file combination.

It is currently used by both /cmd/c3sat and /cmd/cia3. It originally handled the http server and still has that functionality, but I've tried to make it more an http handler provider.

The following information is copied from the old root readme.md and it not fully up-to-date, but it's not wrong, either.

More recent examples and use can be found in /cmd/cia3/html/cia3.js , although that's a rather ugly long file in early 2020.

Queries defined

  • Direct data queries with section header and ordinal, offset from start of section and count of values
    • bytes - Returns byte array, assumes all bytes are unsinged
    • int16s - Returns int16 array, assumes all int16s are signed
    • int32s - Returns int16 array, assumes all int32s are signed
    • hexString - Like bytes but returns hex string, e.g. "0100FFFF"
    • base64 - Like bytes but base64-encoded
  • civ3 - The first interpreted query returning named values. Use the GraphQL client or example below to see the available values

Example queries

  • Starting locations of players

      {
          int32s(section: "WRLD", nth: 2, offset: 36, count: 32)
      }
    
  • Tile's trade network ID by civ; nth should be a multiple of 4

      {
          int16s(section: "TILE", nth: 4, offset: 26, count: 32)
      }
    
  • Get map generation values

      {
          civ3 {
              worldSeed
              size
              barbariansFinal
              landMassFinal
              oceanCoverageFinal
              climateFinal
              temperatureFinal
              ageFinal
          }
      }
    

Documentation

Index

Constants

View Source
const Signed = true

to make calling functions readable

View Source
const Unsigned = false

Variables

This section is empty.

Functions

func ChangeDefaultBicPath

func ChangeDefaultBicPath(path string) error

ChangeSavePath updates the package saveGame structure with save file data at <path>

func ChangeSavePath

func ChangeSavePath(path string) error

ChangeSavePath updates the package saveGame structure with save file data at <path>

func CivString

func CivString(b []byte) (string, error)

CivString Finds null-terminated string and converts from Windows-1252 to UTF-8

func GraphQlHandler

func GraphQlHandler() (http.Handler, error)

GraphQlHandler returns a GraphQL http handler

func Query

func Query(query, path string) (string, error)

func ReadInt16

func ReadInt16(offset int, signed bool) int

deprecating in favor of *saveGameType.readInt16()

func ReadInt32

func ReadInt32(offset int, signed bool) int

deprecating in favor of *saveGameType.readInt32()

func ReadInt8

func ReadInt8(offset int, signed bool) int

deprecating in favor of *saveGameType.readInt8()

func SectionOffset

func SectionOffset(sectionName string, nth int) (int, error)

deprecating in favor of *saveGameType.sectionOffset()

func Server

func Server(path string, bindAddress, bindPort string) error

func WorldSettings

func WorldSettings(path string) ([][3]string, error)

Adapting this from the parseciv3 module to pull data this module's way

To keep the existing seed command without having to gql everything

WorldSettings Returns the information needed to regenerate the map presuming the map was originally generated by Civ3 and not later edited

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL