From 2833cf3796502f2a4f6e6309fe87b45b21b99098 Mon Sep 17 00:00:00 2001 From: Anders Gidenstam Date: Sun, 13 Jan 2013 00:34:57 +0100 Subject: [PATCH] Improved handling of ground handling models and disabled the bomb impact model. --- Systems/scenario-network.nas | 35 +++++++++++++++++++++++++++-------- Systems/submarine-scout.nas | 23 ++++++++++++----------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/Systems/scenario-network.nas b/Systems/scenario-network.nas index 1d69ac9..afc27c0 100644 --- a/Systems/scenario-network.nas +++ b/Systems/scenario-network.nas @@ -1,9 +1,8 @@ ############################################################################### -## $Id$ ## ## Submarine Scout airship ## -## Copyright (C) 2007 - 2009 Anders Gidenstam (anders(at)gidenstam.org) +## Copyright (C) 2007 - 2013 Anders Gidenstam (anders(at)gidenstam.org) ## This file is licensed under the GPL license v2 or later. ## ############################################################################### @@ -23,9 +22,10 @@ var handle_message = func (sender, msg) { # print("Submarine_Scout: Bomb impact!"); var pos = Binary.decodeCoord(substr(msg, 1)); # debug.dump(pos); - geo.put_model("Aircraft/Submarine_Scout/Models/flare.osg", - pos.lat(), pos.lon(), pos.alt(), - 0, 0, 0); +# FIXME: Need a new model and find the actual path to it. +# geo.put_model("Aircraft/Submarine_Scout/Models/flare.osg", +# pos.lat(), pos.lon(), pos.alt(), +# 0, 0, 0); } if (type == message_id["place_ground_crew"][0]) { # print("Submarine_Scout: Ground crew for "~ sender.getPath() ~ @@ -62,6 +62,8 @@ var remote_ground_crew = { ################################################## init : func { me.model = {}; + me.model_path = + me.find_model_path("Submarine_Scout/Models/GroundCrew/wire-party.xml"); }, ################################################## place_remote_ground_crew : func (key, pos1, pos2, heading) { @@ -70,10 +72,10 @@ var remote_ground_crew = { if (me.model[key][0] != nil) me.model[key][0].remove(); if (me.model[key][1] != nil) me.model[key][1].remove(); me.model[key][0] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (me.model_path, pos1, heading + 135.0); me.model[key][1] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (me.model_path, pos2, heading - 135.0); }, ################################################## @@ -81,8 +83,25 @@ var remote_ground_crew = { if (!contains(me.model, key)) return; if (me.model[key][0] != nil) me.model[key][0].remove(); if (me.model[key][1] != nil) me.model[key][1].remove(); - } + }, ################################################## + # filename should include the aircraft's directory. + find_model_path : func (filename) { + # FIXME WORKAROUND: Search for the model in all aircraft dirs. + var base = "/" ~ filename; + var file = props.globals.getNode("/sim/fg-root").getValue() ~ + "/Aircraft" ~ base; + if (io.stat(file) != nil) { + return file; + } + foreach (var d; + props.globals.getNode("/sim").getChildren("fg-aircraft")) { + file = d.getValue() ~ base; + if (io.stat(file) != nil) { + return file; + } + } + } }; remote_ground_crew.init(); diff --git a/Systems/submarine-scout.nas b/Systems/submarine-scout.nas index b86245b..dbf43e9 100644 --- a/Systems/submarine-scout.nas +++ b/Systems/submarine-scout.nas @@ -2,7 +2,7 @@ ## ## Submarine Scout airship ## -## Copyright (C) 2007 - 2012 Anders Gidenstam (anders(at)gidenstam.org) +## Copyright (C) 2007 - 2013 Anders Gidenstam (anders(at)gidenstam.org) ## This file is licensed under the GPL license v2 or later. ## ############################################################################### @@ -137,10 +137,11 @@ var resolve_impact = func (n) { node.getNode("impact/longitude-deg").getValue(), node.getNode("impact/elevation-m").getValue()); broadcast.send(message_id["bomb_impact"] ~ Binary.encodeCoord(pos)); - geo.put_model("Aircraft/Submarine_Scout/Models/flare.osg", - pos.lat(), pos.lon(), pos.alt(), - node.getNode("impact/heading-deg").getValue(), - 0, 0); +# FIXME: Need a new model. +# geo.put_model(getprop("/sim/aircraft-dir") ~ "/Models/flare.osg", +# pos.lat(), pos.lon(), pos.alt(), +# node.getNode("impact/heading-deg").getValue(), +# 0, 0); } controls.trigger = func(b) { @@ -230,10 +231,10 @@ var ground_crew = { if (me.model.local[0] != nil) me.model.local[0].remove(); if (me.model.local[1] != nil) me.model.local[1].remove(); me.model.local[0] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (getprop("/sim/aircraft-dir") ~ "/Models/GroundCrew/wire-party.xml", me.pos[0], me.heading + 135.0); me.model.local[1] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (getprop("/sim/aircraft-dir") ~ "/Models/GroundCrew/wire-party.xml", me.pos[1], me.heading - 135.0); broadcast.send(message_id["place_ground_crew"] ~ Binary.encodeCoord(me.pos[0]) ~ @@ -247,10 +248,10 @@ var ground_crew = { if (me.model[key][0] != nil) me.model[key][0].remove(); if (me.model[key][1] != nil) me.model[key][1].remove(); me.model[key][0] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (getprop("/sim/aircraft-dir") ~ "/Models/GroundCrew/wire-party.xml", pos1, heading + 135.0); me.model[key][1] = geo.put_model - ("Aircraft/Submarine_Scout/Models/GroundCrew/wire-party.xml", + (getprop("/sim/aircraft-dir") ~ "/Models/GroundCrew/wire-party.xml", pos2, heading - 135.0); }, ################################################## @@ -463,9 +464,9 @@ var dialog = { content.set("default-padding", 5); props.globals.initNode("sim/about/text", "Royal Naval Air Service Submarine Scout Zero airship for FlightGear\n" ~ - "Copyright (C) 2007 - 2012 Anders Gidenstam\n\n" ~ + "Copyright (C) 2007 - 2013 Anders Gidenstam\n\n" ~ "FlightGear flight simulator\n" ~ - "Copyright (C) 1996 - 2012 http://www.flightgear.org\n\n" ~ + "Copyright (C) 1996 - 2013 http://www.flightgear.org\n\n" ~ "This is free software, and you are welcome to\n" ~ "redistribute it under certain conditions.\n" ~ "See the GNU GENERAL PUBLIC LICENSE Version 2 for the details.",