The bad thing is that I see no way to prevent also the shipDockedWithStation and the missionScreenOpportunity from firing when you already do a launchPlayer in going to dock. I have no clue how to prevent it.
In the enterDock code I now added a check that prevents further execution when it detects the status STATUS_LAUNCHING. I added a logline just before. However, before the code even reaches that logline, the shipDockedWithStation and the missionScreenOpportunity have already fired. Puzzling.....
Oolites C code
Code: Select all
- (void) enterDock:(StationEntity *)station
{
if ([self status] == STATUS_DEAD) return;
[self setStatus:STATUS_DOCKING];
dockedStation = station;
[self doScriptEvent:OOJSID("shipWillDockWithStation") withArgument:station];
OOLog(@"dumpState.playerEntity", @"Status on enterDock: %@", OOStringFromEntityStatus([self status]));
if ([self status] == STATUS_LAUNCHING) return; // a JS script has abrupt the docking.
Code: Select all
this.shipWillDockWithStation = function (station)
{
if (player.ship.docked && player.ship.dockedStation)
log(this.name, "Player will dock at: "+player.ship.dockedStation.displayName + ", with status: "+ player.ship.status);
if (player.ship.dockedStation) player.ship.launch();
}
this.shipDockedWithStation = function (station)
{
if (player.ship.docked && player.ship.dockedStation)
log(this.name, "Player has docked at: "+player.ship.dockedStation.displayName);
}
this.missionScreenOpportunity = function()
{
log(this.name,"missionScreenOpportunity has fired")
}
Code: Select all
[eric's test handlers] OOJSGlobal.m:247: Player launched from station: Coriolis Station
[eric's test handlers] OOJSGlobal.m:247: Player will dock at: Coriolis Station, with status: STATUS_DOCKING <----- A
[eric's test handlers] OOJSGlobal.m:247: Player has docked at: Coriolis Station
[eric's test handlers] OOJSGlobal.m:247: missionScreenOpportunity has fired
[eric's test handlers] OOJSGlobal.m:247: Player will launch from station: Coriolis Station < ---- B
[dumpState.playerEntity] PlayerEntity.m:4730: Status on enterDock: STATUS_LAUNCHING
[eric's test handlers] OOJSGlobal.m:247: Player launched from station: Coriolis Station
Anyhow, I look a bit further if is can break anything and when okay it will go in trunk and in 1.76.1