Skip to content

Commit

Permalink
Merge pull request #31 from Radulfr4/master
Browse files Browse the repository at this point in the history
Adding a "Free Flight" training mission
  • Loading branch information
BackTrak authored Nov 11, 2017
2 parents 5052e86 + 2a31d40 commit 6010f64
Show file tree
Hide file tree
Showing 12 changed files with 326 additions and 44 deletions.
4 changes: 3 additions & 1 deletion VS2017/training.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<ClCompile Include="..\src\training\Goal.cpp" />
<ClCompile Include="..\src\training\goallist.cpp" />
<ClCompile Include="..\src\training\messageaction.cpp" />
<ClCompile Include="..\src\training\mission10.cpp" />
<ClCompile Include="..\src\training\mission2.cpp" />
<ClCompile Include="..\src\training\mission3.cpp" />
<ClCompile Include="..\src\training\mission4.cpp" />
Expand Down Expand Up @@ -239,6 +240,7 @@
<ClInclude Include="..\src\training\Goal.h" />
<ClInclude Include="..\src\training\goallist.h" />
<ClInclude Include="..\src\training\messageaction.h" />
<ClInclude Include="..\src\training\mission10.h" />
<ClInclude Include="..\src\training\Mission2.h" />
<ClInclude Include="..\src\training\Mission3.h" />
<ClInclude Include="..\src\training\Mission4.h" />
Expand Down Expand Up @@ -293,4 +295,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
8 changes: 5 additions & 3 deletions src/WinTrek/WinTrek.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,7 @@ class TrekWindowImpl :
{
extern TRef<ModifiableNumber> g_pnumberMissionNumber;
int iMission = static_cast<int> (g_pnumberMissionNumber->GetValue ());
ZAssert ((iMission >= 1) && (iMission <= 8)); //TheBored 06-JUL-07: second condition must be (iMission <= (number of training missions))
ZAssert ((iMission >= 1) && (iMission <= 10)); //TheBored 06-JUL-07: second condition must be (iMission <= (number of training missions))
char* strNamespace[] =
{
"",
Expand All @@ -2484,8 +2484,10 @@ class TrekWindowImpl :
"tm_4_enemy_engagement_post",
"tm_5_command_view_post",
"tm_6_practice_arena_post",
"", //TheBored 06-JUL-07: Mish #7, blank because its never used
"tm_8_nanite_post", //TheBored 06-JUL-07: Mish #8 postgame panels
"", //TheBored 06-JUL-07: Mish #7, blank because its never used
"tm_8_nanite_post", //TheBored 06-JUL-07: Mish #8 postgame panels
"",
"tm_6_practice_arena_post" //05-NOV-17: FreeFlight pseudo training mission - use same post slides as tm6 (showing station instead of text in ui-stretch beta)
};
SetUiScreen(CreatePostTrainingSlideshow (GetModeler (), strNamespace[iMission]));
break;
Expand Down
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
18 changes: 15 additions & 3 deletions src/WinTrek/trainingscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class TrainingScreen :
m_pbuttonTrain->SetChecked (true);
#ifdef _DEBUG
if (bStartTraining) {
g_pnumberMissionNumber->SetValue(6);
g_pnumberMissionNumber->SetValue(Training::c_TM_10_Free_Flight);
OnButtonTrain();
}
#endif
Expand Down Expand Up @@ -195,15 +195,27 @@ class TrainingScreen :
case Training::c_TM_4_Enemy_Engagement:
case Training::c_TM_5_Command_View:
case Training::c_TM_6_Practice_Arena:
case Training::c_TM_8_Nanite: //TheBored 06-JUL-07: nanite mission
case Training::c_TM_8_Nanite:
// note that the training slideshow can get the mission number from the global
// value when subsequently launching.
GetWindow ()->screen (ScreenIDTrainSlideshow);
GetWindow()->screen(ScreenIDTrainSlideshow);
break;
case Training::c_TM_10_Free_Flight:
//Skip slideshow -- Let stuff load before changing it
TRef<IMessageBox> pMsgBox = CreateMessageBox("Training simulation initiated...", NULL, false);
GetWindow()->GetPopupContainer()->OpenPopup(pMsgBox, false);
AddEventTarget(&TrainingScreen::OnFreeFlightSwitchOut, GetWindow(), 0.1f);
break;
}
return true;
}

bool OnFreeFlightSwitchOut(void)
{
GetWindow()->StartTraining(Training::c_TM_10_Free_Flight);
return false;
}

bool OnButtonMission(const int iMission)
{
g_pnumberMissionNumber->SetValue(iMission);
Expand Down
4 changes: 2 additions & 2 deletions src/WinTrek/trekigc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2106,7 +2106,7 @@ class ThingSiteImpl : public ThingSitePrivate

if (Training::IsTraining ())
{
if ((trekClient.GetShip ()->GetSide () != side) && (Training::GetTrainingMissionID () != Training::c_TM_6_Practice_Arena))
if ((trekClient.GetShip()->GetSide() != side) && (Training::GetTrainingMissionID() != Training::c_TM_6_Practice_Arena) && (Training::GetTrainingMissionID() != Training::c_TM_10_Free_Flight))
return false;
}
return m_sideVisibility.fVisible();
Expand Down 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 ()))
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
19 changes: 13 additions & 6 deletions src/training/Training.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#include "Mission4.h"
#include "Mission5.h"
#include "Mission6.h"
#include "Mission8.h" //TheBored 06-JUL-07: Adding nanite mission.
#include "Mission8.h" //TheBored 06-JUL-07: Adding nanite mission.
#include "Mission10.h"

namespace Training
{
Expand Down Expand Up @@ -75,11 +76,12 @@ namespace Training
case c_TM_6_Practice_Arena:
g_pMission = new Mission6;
break;
//TheBored 06-JUL-07: adding nanite mission
case c_TM_8_Nanite:
g_pMission = new Mission8;
break;
//End TB
case c_TM_8_Nanite: //TheBored 06-JUL-07: adding nanite mission
g_pMission = new Mission8;
break;
case c_TM_10_Free_Flight:
g_pMission = new Mission10;
break;
case c_TM_7_Live:
g_bIsMission7 = true;
// fall through
Expand Down Expand Up @@ -147,6 +149,11 @@ namespace Training
*/
}

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

//------------------------------------------------------------------------------
int GetTrainingMissionID (void)
{
Expand Down
4 changes: 3 additions & 1 deletion src/training/Training.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ namespace Training
c_TM_5_Command_View = 5,
c_TM_6_Practice_Arena = 6,
c_TM_7_Live = 7,
c_TM_8_Nanite = 8 //TheBored 06-JUL-07: adding nanite mission
c_TM_8_Nanite = 8, //TheBored 06-JUL-07: adding nanite mission
c_TM_10_Free_Flight = 10
};

//------------------------------------------------------------------------------
Expand All @@ -39,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
Loading

0 comments on commit 6010f64

Please sign in to comment.