-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
- The code starting a tutorial race was duplicated in three places. Consolidate it in one place. - When launching the tutorial from the overworld, use the last used input device instead of the keyboard - Restore the old cmake policy. The new way to replace that code suggested by the cmake manual fails CI, and debugging MSVC fantasies without a local install is a nightmare. - Restrict this policy setting to MSVC as that's the only compile path that needs it, avoiding the warning for non-MSVC builds. - Add missing define guards - Remove some extraneous includes
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,7 +160,9 @@ class PlayerProfile : public NoCopy | |
/** Returns the name of this player. */ | ||
const core::stringw& getName() const | ||
{ | ||
#ifdef DEBUG | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
Alayan-stk-2
Author
Collaborator
|
||
assert(m_magic_number == 0xABCD1234); | ||
#endif | ||
return m_local_name; | ||
} // getName | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// SuperTuxKart - a fun racing game with go-kart | ||
// | ||
// Copyright (C) 2024 Alayan | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 3 | ||
// of the License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
|
||
#include "modes/tutorial_utils.hpp" | ||
|
||
#include "config/player_manager.hpp" | ||
#include "config/user_config.hpp" | ||
#include "karts/kart_properties_manager.hpp" | ||
#include "input/device_manager.hpp" | ||
#include "input/input_manager.hpp" | ||
#include "race/race_manager.hpp" | ||
|
||
namespace TutorialUtils | ||
{ | ||
void startTutorial(bool from_overworld) | ||
{ | ||
RaceManager::get()->setNumPlayers(1); | ||
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); | ||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL); | ||
RaceManager::get()->setNumKarts( 1 ); | ||
RaceManager::get()->setTrack( "tutorial" ); | ||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY); | ||
RaceManager::get()->setReverseTrack(false); | ||
|
||
// Use the last used device | ||
InputDevice* device = input_manager->getDeviceManager()->getLatestUsedDevice(); | ||
|
||
// Create player and associate player with device | ||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), device); | ||
|
||
if (kart_properties_manager->getKart(UserConfigParams::m_default_kart) == NULL) | ||
{ | ||
Log::warn("HelpScreen1", "Cannot find kart '%s', will revert to default", | ||
UserConfigParams::m_default_kart.c_str()); | ||
UserConfigParams::m_default_kart.revertToDefaults(); | ||
} | ||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart); | ||
|
||
// ASSIGN should make sure that only input from assigned devices is read. | ||
input_manager->getDeviceManager()->setAssignMode(ASSIGN); | ||
input_manager->getDeviceManager()->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); | ||
|
||
StateManager::get()->enterGameState(); | ||
RaceManager::get()->setupPlayerKartInfo(); | ||
RaceManager::get()->startNew(from_overworld); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SuperTuxKart - a fun racing game with go-kart | ||
// | ||
// Copyright (C) 2024 Alayan | ||
// | ||
// This program is free software; you can redistribute it and/or | ||
// modify it under the terms of the GNU General Public License | ||
// as published by the Free Software Foundation; either version 3 | ||
// of the License, or (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with this program; if not, write to the Free Software | ||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
|
||
#ifndef __HEADER_TUTORIAL_UTILS_HPP__ | ||
#define __HEADER_TUTORIAL_UTILS_HPP__ | ||
|
||
namespace TutorialUtils | ||
{ | ||
void startTutorial(bool from_overworld = false); | ||
} | ||
|
||
#endif |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,7 @@ | |
#include "karts/kart_rewinder.hpp" | ||
#include "main_loop.hpp" | ||
#include "modes/overworld.hpp" | ||
#include "modes/tutorial_utils.hpp" | ||
#include "network/child_loop.hpp" | ||
#include "network/protocols/client_lobby.hpp" | ||
#include "network/network_config.hpp" | ||
|
@@ -82,12 +83,6 @@ | |
#include "utils/translation.hpp" | ||
#include "utils/string_utils.hpp" | ||
|
||
#include <algorithm> | ||
#include <assert.h> | ||
#include <ctime> | ||
#include <sstream> | ||
#include <stdexcept> | ||
|
||
#include <IrrlichtDevice.h> | ||
#include <ISceneManager.h> | ||
|
||
|
@@ -1016,7 +1011,6 @@ void World::updateWorld(int ticks) | |
assert(m_magic_number == 0xB01D6543); | ||
#endif | ||
|
||
|
||
if (m_schedule_pause) | ||
{ | ||
pause(m_scheduled_pause_phase); | ||
|
@@ -1067,41 +1061,8 @@ void World::updateWorld(int ticks) | |
if (m_schedule_tutorial) | ||
{ | ||
m_schedule_tutorial = false; | ||
RaceManager::get()->setNumPlayers(1); | ||
RaceManager::get()->setMajorMode (RaceManager::MAJOR_MODE_SINGLE); | ||
RaceManager::get()->setMinorMode (RaceManager::MINOR_MODE_TUTORIAL); | ||
RaceManager::get()->setNumKarts( 1 ); | ||
RaceManager::get()->setTrack( "tutorial" ); | ||
RaceManager::get()->setDifficulty(RaceManager::DIFFICULTY_EASY); | ||
RaceManager::get()->setReverseTrack(false); | ||
|
||
// Use keyboard 0 by default (FIXME: let player choose?) | ||
InputDevice* device = input_manager->getDeviceManager()->getKeyboard(0); | ||
|
||
// Create player and associate player with keyboard | ||
StateManager::get()->createActivePlayer(PlayerManager::getCurrentPlayer(), | ||
device); | ||
|
||
if (!kart_properties_manager->getKart(UserConfigParams::m_default_kart)) | ||
{ | ||
Log::warn("[World]", | ||
"Cannot find kart '%s', will revert to default.", | ||
UserConfigParams::m_default_kart.c_str()); | ||
UserConfigParams::m_default_kart.revertToDefaults(); | ||
} | ||
RaceManager::get()->setPlayerKart(0, UserConfigParams::m_default_kart); | ||
|
||
// ASSIGN should make sure that only input from assigned devices | ||
// is read. | ||
input_manager->getDeviceManager()->setAssignMode(ASSIGN); | ||
input_manager->getDeviceManager() | ||
->setSinglePlayer( StateManager::get()->getActivePlayer(0) ); | ||
|
||
delete this; | ||
|
||
StateManager::get()->enterGameState(); | ||
RaceManager::get()->setupPlayerKartInfo(); | ||
RaceManager::get()->startNew(true); | ||
TutorialUtils::startTutorial(true /*from overworld*/); | ||
} | ||
else | ||
{ | ||
|
@@ -1123,6 +1084,7 @@ void World::updateWorld(int ticks) | |
|
||
void World::scheduleTutorial() | ||
{ | ||
printf("Tutorial scheduled\n"); | ||
This comment has been minimized.
Sorry, something went wrong.
qwertychouskie
Contributor
|
||
m_schedule_exit_race = true; | ||
m_schedule_tutorial = true; | ||
} // scheduleTutorial | ||
|
Aren't asserts inherently not compiled unless in DEBUG?