Skip to content

Commit

Permalink
Merge pull request #2 from Radulfr4/TakeMeTo
Browse files Browse the repository at this point in the history
Take me to fix.
  • Loading branch information
Radulfr4 authored Nov 8, 2017
2 parents 93529b5 + c69f6e2 commit 2a31d40
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 17 deletions.
38 changes: 27 additions & 11 deletions src/WinTrek/teampane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,19 +1241,35 @@ public TrekClientEventSink
//
// assert (pplayer->SideID() != SIDE_TEAMLOBBY);
{
if (Training::IsTraining ())
if (Training::IsTraining())
{
ImissionIGC* pCore = trekClient.GetCore ();
IshipIGC* pShip = pCore->GetShip (shipID);
IclusterIGC* pCluster = pShip->GetCluster ();
if (!pCluster)
if (Training::CommandViewEnabled())
{
IstationIGC* pStation = pShip->GetStation ();
assert (pStation);
pCluster = pStation->GetCluster ();
assert (pCluster);
ImissionIGC* pCore = trekClient.GetCore();
IshipIGC* pShip = pCore->GetShip(shipID); //pplayer->GetShip() should be the same
IclusterIGC* pCluster = pShip->GetCluster();
const Vector* ppos;
if (!pCluster)
{
IstationIGC* pStation = pShip->GetStation();
assert(pStation);
pCluster = pStation->GetCluster();
assert(pCluster);
debugf("Ship is in station in %s.\n", pCluster->GetName());
ppos = pStation && pStation->SeenBySide(trekClient.GetSide()) ? &(pStation->GetPosition()) : NULL;
}
else
ppos = pShip && pShip->SeenBySide(trekClient.GetSide()) ? &(pShip->GetPosition()) : NULL;

IclusterIGC* pClusterShip = trekClient.GetShip()->GetCluster();
if ((pClusterShip == NULL) || (pClusterShip == pCluster)) { //check if in station or in the same sector
if (GetWindow()->GetViewMode() != TrekWindow::vmCommand)
GetWindow()->SetViewMode(TrekWindow::vmCommand);

//trekClient.RequestViewCluster (pCluster, pplayer->GetShip()); //fails for ships in stations
trekClient.SetViewCluster(pCluster, ppos);
}
}
trekClient.RequestViewCluster (pCluster, pplayer->GetShip());
}
else if (pplayer->GetShipStatus().GetSectorID() != NA)
{
Expand All @@ -1279,7 +1295,7 @@ public TrekClientEventSink
}
}

GetWindow()->GetConsoleImage()->GetConsoleData()->PickShip(pplayer->GetShip());
GetWindow()->GetConsoleImage()->GetConsoleData()->PickShip(pplayer->GetShip()); //Select the ship
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/WinTrek/trekigc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4235,7 +4235,7 @@ void WinTrekClient::ReceiveChat(IshipIGC* pshipSender,
if (Training::IsTraining ())
{
// prevent players from giving commands to themselves
if (pshipSender && (oidRecipient == pshipSender->GetObjectID ()) && (Training::GetTrainingMissionID() != Training::c_TM_10_Free_Flight))
if (pshipSender && (oidRecipient == pshipSender->GetObjectID ()) && !Training::CommandViewEnabled())
pmodelTarget = NULL;

// send out the chat we are getting to see if we are waiting for it...
Expand Down
5 changes: 5 additions & 0 deletions src/training/Training.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ namespace Training
*/
}

//------------------------------------------------------------------------------
bool CommandViewEnabled(void) {
return g_pMission ? g_pMission->GetCommandViewEnabled() : false;
}

//------------------------------------------------------------------------------
int GetTrainingMissionID (void)
{
Expand Down
1 change: 1 addition & 0 deletions src/training/Training.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace Training
void SetSkipPostSlideshow (void);
bool IsTraining (void);
bool IsInstalled (void);
bool CommandViewEnabled(void);
int GetTrainingMissionID (void);
SectorID GetStartSectorID (void);
void SetupShipAndCamera (void);
Expand Down
8 changes: 4 additions & 4 deletions src/training/mission10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ namespace Training
void Mission10::CreateUniverse(void)
{
LoadUniverse("training_3", 488, 1030); // a fighter 3

// activate all the starting weapons
trekClient.fGroupFire = true;
trekClient.fGroupFire = true; // activate all the starting weapons

// put the commander ship in the station
ImissionIGC* pCore = trekClient.GetCore();
Expand All @@ -70,7 +68,9 @@ namespace Training
//------------------------------------------------------------------------------
Condition* Mission10::CreateMission(void)
{
debugf("Creating mission.");
debugf("Creating mission 10.\n");
m_commandViewEnabled = true;

GoalList* pGoalList = new GoalList;

// wait .1 seconds, so stuff is initialized
Expand Down
9 changes: 8 additions & 1 deletion src/training/trainingmission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ namespace Training
m_pDeadCondition (0),
m_commanderID (NA),
m_pChatCondition (0),
m_bSkipPostSlideShow (false)
m_bSkipPostSlideShow (false),
m_commandViewEnabled(false)
{
// get the window pointer
TrekWindow* pWindow = GetWindow ();
Expand Down Expand Up @@ -490,6 +491,12 @@ namespace Training
m_bSkipPostSlideShow = true;
}

//------------------------------------------------------------------------------
bool TrainingMission::GetCommandViewEnabled(void)
{
return m_commandViewEnabled;
}

//------------------------------------------------------------------------------
void TrainingMission::LoadUniverse (const ZString& name, HullID hullID, StationID homeStationID)
{
Expand Down
2 changes: 2 additions & 0 deletions src/training/trainingmission.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace Training
void AddPartToShip (PartID part, Mount mount, short ammo = 0);
IshipIGC* CreateDrone (const ZString& name, ShipID shipID, HullID hullID, SideID sideID, PilotType pilotType);
void SetSkipPostSlideshow (void);
bool GetCommandViewEnabled(void);

protected:
virtual void CreateUniverse (void) = 0;
Expand All @@ -71,6 +72,7 @@ namespace Training
TrekWindow::ViewMode m_deadViewMode;
TrekWindow::CameraMode m_deadCameraMode;
bool m_bSkipPostSlideShow;
bool m_commandViewEnabled;
};

//------------------------------------------------------------------------------
Expand Down

0 comments on commit 2a31d40

Please sign in to comment.