1.0.0 から 1.1.0 へのアップグレード
C API の更新
SDK API での唯一の大きな変更は、 Genvid_SubscribeCommand()
と Genvid_UnsubscribeCommand()
で、 void *
パラメータが追加されている点です。このパラメータが必要でない場合、 NULL
を渡します。
スクリプトツールボックスの更新
バージョン 1.1 では、新しい Genvid 設定ファイル を実装し、更新に local.py
の変更が必要なくなりました。プロジェクトを任意のディレクトリに格納でき、これまで以上にプロジェクト管理が容易になりました。
バージョン 1.0 では、 local.py
に以下のようなセクションを追加する必要がありました。
# 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",
),
)
local.py
の変更を破棄して、指示に従って、新しい 設定システム でゲームを利用できるようになります。
最初に、プロジェクトフォルダ (例: samples/mygame
) に、以下のコンテンツのプロジェクトファイル genvid.hcl
を作成します。
// 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"
}
local-services\templates\mygame.nomad.tmpl
ファイルの 1 行を変更する必要があります。古いファイルの以下のセクションを、
env
{
MYGAME_CWD = "{{key "local/game_path" | js}}"
GLOG_logtostderr = "1"
}
次のように設定します。
env
{
MYGAME_CWD = "{{print (key "local/project_dir") "/app" | js}}"
GLOG_logtostderr = "1"
}