Upgrade from 1.0.0 to 1.1.0

C API upgrade

The only breaking changes in the SDK API is the Genvid_SubscribeCommand() and Genvid_UnsubscribeCommand() that now take an additional void * parameter. If this parameter is not needed, just pass NULL to it.

Script Toolbox upgrade

Version 1.1 introduces the new Genvid configuration files to remove the necessity to modify local.py on upgrade. We also allow for the project to be in any directory, hoping it will help you manage your project more easily.

In version 1.0, it was required to add a section to local.py with something like this:

# Add mygame
gameDir = os.path.join("samples", "mygame")
self.GAMES["mygame"] = dict(
    gamedir=gameDir,
    binaries=os.path.join(self.ROOTDIR, gameDir, "app", "x64", "Release", "mygame.exe"),
    gamepath=os.path.join(self.ROOTDIR, gameDir, "app"),
    buildGameCommand=[os.path.join(self.ROOTDIR, gameDir, "run.py"), "build"],
    buildWebCommand=[os.path.join(self.ROOTDIR, gameDir, "web", "build.py"), "build"],
    log=dict(
        stdout=False,
        task="mygame",
    ),
)

You can discard your changes made in local.py and follow these instructions to make your game available with the new configuration system.

Start by creating a project file genvid.hcl under your project folder, e.g., samples/mygame, with the following content:

// Version number.  Don't change it.
version = "1.1"

// Same name as the one used for self.GAMES["mygame"]
name = "mygame"

// The game job.  The name of the job should match the template name.
job "mygame" {
  // Services that the game depend before starting
  depends_on = [
    "nats",
    "compose",
  ]
}

// The game binary, used by the local game job template.
binary "tutorial" {
   // This is equivalent to the content of the field self.GAMES["mygame"]["binaries"]
   path = "{{env "PROJECTDIR" | js}}\\app\\x64\\Release\\mygame.exe"
}

// The game events map-reduce definition.
event "game" {
   path = "{{env "PROJECTDIR" | js}}\\app\\mr.json"
}

// Log for the game.
// This is equivalent to the content of the field self.GAMES["mygame"]["log"].
log "game" {
   task = "mygame"
   stdout = false
}

// The local build script.
script "build" {
  // Those two lines are equivalent to the self.GAMES["mygame"]["buildGameCommand"]
  // and self.GAMES["mygame"]["buildWebCommand"].
  commands = [
    // Build the game
    "\"{{env "PYTHON_EXECUTABLE" | js}}\" \"{{env "PROJECTDIR" | js}}\\run.py\" build",
    // Build the web site
    "\"{{env "PYTHON_EXECUTABLE" | js}}\" \"{{env "PROJECTDIR" | js}}\\web\\build.py\" build",
  ]
}

// What is below was not configurable in 1.0.  You must now include it to
// have the sample working.

// The web server job.
job "web" {}

// The Node.js server binary, used by the local web job template.
binary "node" {
  path = "node"
}

// Standard output of the web server.
log "web" {
  stdout = true
  task = "web"
}

// Standard error output of the web server.
log "weberr" {
  stdout = false
  task = "web"
}

// Some website configuration, used by the local web job template.
website {
  root = "{{env "PROJECTDIR" | js}}\\web"
  script = "{{env "PROJECTDIR" | js}}\\web\\bin\\www"
}

You also need to change one line in the local-services\templates\mygame.nomad.tmpl file. The following section in the previous file:

env
{
  MYGAME_CWD = "{{key "local/game_path" | js}}"
  GLOG_logtostderr = "1"
}

should now be be set as:

env
{
  MYGAME_CWD = "{{print (key "local/project_dir") "/app" | js}}"
  GLOG_logtostderr = "1"
}