Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Descent3/Mission.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ void InitDefaultMissionFromCLI() {
int mission_arg = FindArg("-mission");
if (mission_arg > 0) {
std::filesystem::path filename = std::filesystem::path(GameArgs[mission_arg + 1]).filename().replace_extension(".mn3");
LoadMission((const char*)filename.u8string().c_str());
LoadMission(filename);

int level_arg = FindArg("-loadlevel");
if (level_arg > 0) {
Expand Down Expand Up @@ -902,7 +902,7 @@ bool DemoMission(int mode = 0) {
}
#endif

bool LoadMission(const char *mssn) {
bool LoadMission(const std::filesystem::path& mssn) {
Times_game_restored = 0;
LOG_INFO << "In LoadMission()";
#if (defined(OEM) || defined(DEMO))
Expand Down Expand Up @@ -942,7 +942,7 @@ bool LoadMission(const char *mssn) {
// Open MN3 if filename passed was a mn3 file.
if (IS_MN3_FILE(mssn)) {
mission = mssn;
pathname = std::filesystem::path("missions") / mission;
pathname = "missions" / mission;
} else {
mission = mssn;
pathname = mssn;
Expand Down Expand Up @@ -1771,7 +1771,7 @@ bool GetMissionInfo(const std::filesystem::path &msnfile, tMissionInfo *msn) {
return true;
}

const char *GetMissionName(const char *mission) {
const char *GetMissionName(const std::filesystem::path &mission) {
tMissionInfo msninfo{};
static char msnname[MSN_NAMELEN];
msnname[0] = 0;
Expand All @@ -1783,7 +1783,7 @@ const char *GetMissionName(const char *mission) {
return msnname;
}

bool IsMissionMultiPlayable(const char *mission) {
bool IsMissionMultiPlayable(const std::filesystem::path &mission) {
tMissionInfo msninfo{};
if (GetMissionInfo(mission, &msninfo)) {
return msninfo.multi;
Expand Down Expand Up @@ -1875,8 +1875,8 @@ void mn3_Close() {
// Return values:
// -1 Bad match -- this level and this mod shouldn't be played together!
// MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants
int MissionGetKeywords(const char *mission, char *keywords) {
ASSERT(mission);
int MissionGetKeywords(const std::filesystem::path &mission, char *keywords) {
ASSERT(!mission.empty());
ASSERT(keywords);

char msn_keywords[NUM_KEYWORDS][KEYWORD_LEN];
Expand All @@ -1893,7 +1893,7 @@ int MissionGetKeywords(const char *mission, char *keywords) {

memset(msn_keywords, 0, sizeof(msn_keywords));
memset(mod_keywords, 0, sizeof(mod_keywords));
LOG_DEBUG.printf("MissionGetKeywords(%s,%s)", mission, keywords);
LOG_DEBUG << "MissionGetKeywords(" << mission << ", " << keywords << ")";
if (!GetMissionInfo(mission, &msn_info)) {
return -1;
}
Expand Down Expand Up @@ -1956,7 +1956,7 @@ int MissionGetKeywords(const char *mission, char *keywords) {
}
// We never found one we needed, so return -1;
if (!found_keyword) {
LOG_WARNING.printf("%s keyword needed in %s not found!", mod_keyword, mission);
LOG_WARNING << mod_keyword << " keyword needed in " << mission << " not found!";
return -1;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Descent3/Mission.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ bool mn3_Open(const std::filesystem::path &mn3file);
void mn3_Close();

// Get the name field out of the mission file
const char *GetMissionName(const char *mission);
const char *GetMissionName(const std::filesystem::path &mission);

// initializes mission system.
void InitMission();
Expand All @@ -301,7 +301,7 @@ void InitDefaultMissionFromCLI();
void ResetMission();

// loads and verifies a mission as the current mission, returns if valid of not.
bool LoadMission(const char *msn);
bool LoadMission(const std::filesystem::path& mssn);

// initializes a level's script.
void InitLevelScript();
Expand All @@ -328,7 +328,7 @@ bool InitMissionScript();
void ShowProgressScreen(const char *str, const char *str2 = nullptr, bool flip = true);

// See if a mission file is multiplayer playable.
bool IsMissionMultiPlayable(const char *mission);
bool IsMissionMultiPlayable(const std::filesystem::path &mission);

/**
* Fill information about a mission.
Expand All @@ -343,7 +343,7 @@ bool GetMissionInfo(const std::filesystem::path &msnfile, tMissionInfo *msn);
// Return values:
// -1 Bad match -- this level and this mod shouldn't be played together!
// MAX_NET_PLAYERS -- This is playable with any number of teams the mod wants
int MissionGetKeywords(const char *mission, char *keywords);
int MissionGetKeywords(const std::filesystem::path &mission, char *keywords);

#ifdef EDITOR
// Used by editor to load all necessary elements for level playing for systems
Expand Down
2 changes: 0 additions & 2 deletions Descent3/dedicated_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,6 @@ static int RunServerConfigs();
static int DedicatedServerLex(const char *command);
static void SetCVarNone(int index);

extern int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams);

extern char Multi_message_of_the_day[];
extern char PXO_hosted_lobby_name[];
// These define the types of variables that can be set in the code through
Expand Down
2 changes: 1 addition & 1 deletion Descent3/demofile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ int DemoReadHeader() {
// Now load the mission
Osiris_DisableCreateEvents();
IsRestoredGame = true;
if (LoadMission((const char *)demo_mission)) {
if (LoadMission(demo_mission)) {
mng_LoadAddonPages();

SetCurrentLevel(level_num);
Expand Down
2 changes: 1 addition & 1 deletion Descent3/gamesave.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ bool GetGameStateInfo(const std::filesystem::path &pathname, char *description,
int LGSXlateTables(CFILE *fp);

// loads in level's mission and level.
int LGSMission(const char *msnname, int level);
int LGSMission(const std::filesystem::path &msnname, int level);

// initializes rooms
int LGSRooms(CFILE *fp);
Expand Down
6 changes: 3 additions & 3 deletions Descent3/loadstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,13 @@ int LGSXlateTables(CFILE *fp) {
}

// loads in level's mission and level.
int LGSMission(const char *msnname, int level) {
int LGSMission(const std::filesystem::path &msnname, int level) {
// we will free the mission.
// Free any game objects/etc that needs to be done when ending a level here.
FreeScriptsForLevel();

Osiris_DisableCreateEvents();
if (LoadMission((const char *)msnname)) {
if (LoadMission(msnname)) {
SetCurrentLevel(level);
Player_num = 0; // Reset player num
Players[Player_num].ship_index = FindShipName(DEFAULT_SHIP);
Expand All @@ -509,7 +509,7 @@ int LGSMission(const char *msnname, int level) {
mng_LoadAddonPages();

InitPlayerNewShip(Player_num, INVRESET_ALL);
InitCameraViews(1); // Turn off all camera views, including rear views
InitCameraViews(true); // Turn off all camera views, including rear views
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other instances left using an int argument out there in gamesequence.cpp if you mind fixing as well


if (!LoadAndStartCurrentLevel()) {
Int3();
Expand Down
41 changes: 14 additions & 27 deletions Descent3/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,40 +1107,28 @@ bool MenuNewGame() {
int n_missions, res;
bool found = false;
bool retval = true;
std::filesystem::path mission_name;

#ifdef DEMO
if (LoadMission("d3demo.mn3")) {
CurrentPilotUpdateMissionStatus(true);
// go into game mode.
SetGameMode(GM_NORMAL);
SetFunctionMode(GAME_MODE);
return true;
} else {
DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK);
return false;
}
mission_name = "d3demo.mn3";
#else
if ((!FindArg("-mission")) && (!FirstGame) && (-1 == Current_pilot.find_mission_data(TRAINING_MISSION_NAME))) {

FirstGame = true;

if (LoadMission("training.mn3")) {
CurrentPilotUpdateMissionStatus(true);
// go into game mode.
SetGameMode(GM_NORMAL);
SetFunctionMode(GAME_MODE);
return true;
} else {
DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK);
return false;
}
mission_name = "training.mn3";
} else if (FirstGame) {
// Already trained
FirstGame = false;
#ifdef OEM
if (LoadMission(OEM_MISSION_FILE))
mission_name = OEM_MISSION_FILE;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find the d3oem.mn3 anywhere, we could even delete the #ifdef OEM I think (and even DEMO?)

#else
if (LoadMission("d3.mn3"))
#endif
{
mission_name = "d3.mn3";
#endif // OEM
}
#endif // DEMO

if (!mission_name.empty()) {
if (LoadMission(mission_name)) {
CurrentPilotUpdateMissionStatus(true);
// go into game mode.
SetGameMode(GM_NORMAL);
Expand Down Expand Up @@ -1245,7 +1233,7 @@ bool MenuNewGame() {
if (index >= 0 && index < filelist.size()) {
nameptr = filelist[index];
}
if (nameptr.empty() || !LoadMission((const char*)nameptr.u8string().c_str())) {
if (nameptr.empty() || !LoadMission(nameptr)) {
DoMessageBox(TXT_ERROR, TXT_ERRLOADMSN, MSGBOX_OK);
retval = false;
} else {
Expand Down Expand Up @@ -1278,7 +1266,6 @@ bool MenuNewGame() {
menu.Destroy();

return retval;
#endif
}

// DisplayLevelWarpDlg
Expand Down
1 change: 0 additions & 1 deletion Descent3/multi_dll_mgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ extern uint8_t NewUIWindow_alpha;
extern void DoScreenshot();
extern void UpdateAndPackGameList(void);
extern bool Multi_Gamelist_changed;
int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams);
void ShowNetgameInfo(network_game *game);
// The exported DLL function call prototypes
#if defined(POSIX)
Expand Down
7 changes: 1 addition & 6 deletions Descent3/multi_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -821,14 +821,9 @@ void MultiStartServer(int playing, char *scriptname, int dedicated_server_num_te
MultiGetShipChecksum(i);
}

// Checks if the selected mission and script are compatible
// Return values:
//-1 Not compatible!
//>=0 Number of teams supported for this mod & level

#define SCRIPTBADFORMISSION (-1)

int CheckMissionForScript(char *mission, char *script, int dedicated_server_num_teams) {
int CheckMissionForScript(const std::filesystem::path &mission, char *script, int dedicated_server_num_teams) {
char mod_keys[MAX_KEYWORDLEN];
if (!GetDLLRequirements(script, mod_keys, MAX_KEYWORDLEN)) {
return SCRIPTBADFORMISSION;
Expand Down
9 changes: 9 additions & 0 deletions Descent3/multi_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ void MultiDoServerFrame();
// Set the local machine as a server
void MultiStartServer(int playing, char *scriptname, int dedicated_server_num_teams = -1);

/**
* Checks if the selected mission and script are compatible
* @param mission requested mission
* @param script script name
* @param dedicated_server_num_teams requested number of teams from dedicated server
* @return number of teams supported for this mod & level (>=0) or -1 if mission incompatible
*/
int CheckMissionForScript(const std::filesystem::path &mission, char *script, int dedicated_server_num_teams);

// Disconnects all players that haven't been heard from in a while
// Server only
void MultiDisconnectDeadPlayers();
Expand Down
12 changes: 6 additions & 6 deletions netcon/includes/con_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ MultiStartClient_fp DLLMultiStartClient;
typedef void (*rend_GetRenderState_fp)(rendering_state *rstate);
rend_GetRenderState_fp DLLrend_GetRenderState;

typedef bool (*LoadMission_fp)(char *msn);
typedef bool (*LoadMission_fp)(const std::filesystem::path& msn);
LoadMission_fp DLLLoadMission;

typedef void (*ddio_MakePath_fp)(char *newPath, const char *absolutePathHeader, const char *subDir, ...);
Expand Down Expand Up @@ -476,7 +476,7 @@ HotSpotCreate_fp DLLHotSpotCreate;
typedef int (*PollUI_fp)(void);
PollUI_fp DLLPollUI;

typedef const char *(*GetMissionName_fp)(const char *mission);
typedef const char *(*GetMissionName_fp)(const std::filesystem::path &mission);
GetMissionName_fp DLLGetMissionName;

typedef void (*RemoveUITextItem_fp)(void *item);
Expand Down Expand Up @@ -597,7 +597,7 @@ DatabaseWriteInt_fp DLLDatabaseWriteInt;
typedef void (*DoScreenshot_fp)();
DoScreenshot_fp DLLDoScreenshot;

typedef bool (*IsMissionMultiPlayable_fp)(const char *mission);
typedef bool (*IsMissionMultiPlayable_fp)(const std::filesystem::path &mission);
IsMissionMultiPlayable_fp DLLIsMissionMultiPlayable;

// returns width of text in current font.
Expand Down Expand Up @@ -690,7 +690,7 @@ MultiLevelSelection_fp DLLMultiLevelSelection;
typedef bool (*DoPlayerMouselookCheck_fp)(uint32_t flags);
DoPlayerMouselookCheck_fp DLLDoPlayerMouselookCheck;

typedef int (*CheckMissionForScript_fp)(char *mission, char *script, int dedicated_server_num_teams);
typedef int (*CheckMissionForScript_fp)(const std::filesystem::path &mission, char *script, int dedicated_server_num_teams);
CheckMissionForScript_fp DLLCheckMissionForScript;

typedef void (*ShowNetgameInfo_fp)(network_game *game);
Expand Down Expand Up @@ -1209,11 +1209,11 @@ int StartMultiplayerGameMenu() {
for (auto const &i : search_paths) {
DLLddio_DoForeachFile(i.first, i.second, [&mi, &list_1](const std::filesystem::path &path) {
std::filesystem::path mission_name = path.filename();
if (DLLIsMissionMultiPlayable((const char*)mission_name.u8string().c_str()) &&
if (DLLIsMissionMultiPlayable(mission_name) &&
(stricmp("d3_2.mn3", (const char*)mission_name.u8string().c_str()) != 0)) {
DLLmprintf(0, "Found a mission: %s\n", (const char*)mission_name.u8string().c_str());
mi = (msn_list *)DLLmem_malloc(sizeof(msn_list));
strcpy(mi->msn_name, DLLGetMissionName((const char*)mission_name.u8string().c_str()));
strcpy(mi->msn_name, DLLGetMissionName(mission_name));
strcpy(mi->msn_file, (const char*)mission_name.u8string().c_str());
mi->ti = DLLCreateNewUITextItem(mi->msn_name, UICOL_LISTBOX_LO, -1);
AddMsnItem(mi);
Expand Down
Loading