Skip to content

Commit

Permalink
Improved handling of ground handling models and disabled the bomb imp…
Browse files Browse the repository at this point in the history
…act model.
  • Loading branch information
andgi committed Jan 15, 2013
1 parent b0c250e commit 2833cf3
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 19 deletions.
35 changes: 27 additions & 8 deletions 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.
##
###############################################################################
Expand All @@ -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() ~
Expand Down Expand Up @@ -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) {
Expand All @@ -70,19 +72,36 @@ 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);
},
##################################################
remove_remote_ground_crew : func (key) {
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();

Expand Down
23 changes: 12 additions & 11 deletions Systems/submarine-scout.nas
Expand Up @@ -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.
##
###############################################################################
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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]) ~
Expand All @@ -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);
},
##################################################
Expand Down Expand Up @@ -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.",
Expand Down

0 comments on commit 2833cf3

Please sign in to comment.