This commit is contained in:
Alayan 2019-10-26 02:28:42 +02:00
parent 79c32a5906
commit 50988c6c60
44 changed files with 223 additions and 233 deletions

View File

@ -80,7 +80,7 @@
<spacer width="5" height="4%"/>
<div layout="horizontal-row" width="100%" height="fit">
<checkbox id="perPlayerDifficulty"/>
<checkbox id="enable-handicap"/>
<spacer width="1%" height="100%" />
<label height="100%" I18N="In the general settings" text="Enable per-player handicaps" word_wrap="true"/>
</div>

View File

@ -76,22 +76,21 @@ KartStatsWidget::KartStatsWidget(core::recti area, const int player_id,
m_children.push_back(skill_bar);
}
setValues(props, PLAYER_DIFFICULTY_NORMAL);
setValues(props, HANDICAP_NONE);
move(area.UpperLeftCorner.X, area.UpperLeftCorner.Y,
area.getWidth(), area.getHeight());
} // KartStatsWidget
// -----------------------------------------------------------------------------
void KartStatsWidget::setValues(const KartProperties* props,
PerPlayerDifficulty d)
void KartStatsWidget::setValues(const KartProperties* props, HandicapLevel h)
{
// Use kart properties computed for best difficulty to show the user, so
// that properties don't change according to the the last used difficulty
RaceManager::Difficulty previous_difficulty = race_manager->getDifficulty();
race_manager->setDifficulty(RaceManager::DIFFICULTY_BEST);
KartProperties kp_computed;
kp_computed.copyForPlayer(props, d);
kp_computed.copyForPlayer(props, h);
for (SkillLevelWidget* skills : m_skills)
skills->setVisible(true);

View File

@ -31,7 +31,7 @@
#include "guiengine/widgets/skill_level_widget.hpp"
class KartProperties;
enum PerPlayerDifficulty : uint8_t;
enum HandicapLevel : uint8_t;
namespace GUIEngine
{
@ -102,7 +102,7 @@ namespace GUIEngine
* inside itself */
void setSize(const int x, const int y, const int w, const int h);
void setValues(const KartProperties* props, PerPlayerDifficulty d);
void setValues(const KartProperties* props, HandicapLevel h);
void hideAll();

View File

@ -53,7 +53,7 @@ PlayerKartWidget::PlayerKartWidget(KartSelectionScreen* parent,
m_associated_player = associated_player;
x_speed = y_speed = w_speed = h_speed = 1.0f;
m_ready = false;
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
m_handicap = HANDICAP_NONE;
m_not_updated_yet = true;
m_irrlicht_widget_id = irrlicht_widget_id;
@ -469,12 +469,12 @@ bool PlayerKartWidget::isReady()
} // isReady
// ------------------------------------------------------------------------
/** \return Per player difficulty */
PerPlayerDifficulty PlayerKartWidget::getDifficulty()
/** \return Handicap */
HandicapLevel PlayerKartWidget::getHandicap()
{
assert(m_magic_number == 0x33445566);
return m_difficulty;
} // getDifficulty
return m_handicap;
} // getHandicap
// -------------------------------------------------------------------------
/** Updates the animation (moving/shrinking/etc.) */
@ -627,19 +627,19 @@ GUIEngine::EventPropagation PlayerKartWidget::transmitEvent(Widget* w,
m_associated_player->setPlayerProfile(profile);
if(UserConfigParams::m_per_player_difficulty && spinner_value % 2 != 0)
{
m_difficulty = PLAYER_DIFFICULTY_HANDICAP;
m_handicap = HANDICAP_MEDIUM;
m_model_view->setBadge(ANCHOR_BADGE);
m_kart_stats->setValues(
kart_properties_manager->getKart(m_kart_internal_name),
PLAYER_DIFFICULTY_HANDICAP);
HANDICAP_MEDIUM);
}
else
{
m_difficulty = PLAYER_DIFFICULTY_NORMAL;
m_handicap = HANDICAP_NONE;
m_model_view->unsetBadge(ANCHOR_BADGE);
m_kart_stats->setValues(
kart_properties_manager->getKart(m_kart_internal_name),
PLAYER_DIFFICULTY_NORMAL);
HANDICAP_NONE);
}
m_model_view->getModelViewRenderInfo()->setHue(
m_associated_player->getConstProfile()->getDefaultKartColor());
@ -749,11 +749,11 @@ EventPropagation PlayerKartWidget::onSpinnerConfirmed()
// -------------------------------------------------------------------------
void PlayerKartWidget::enableHandicapForNetwork()
{
m_difficulty = PLAYER_DIFFICULTY_HANDICAP;
m_handicap = HANDICAP_MEDIUM;
m_model_view->setBadge(ANCHOR_BADGE);
m_kart_stats->setValues(
kart_properties_manager->getKart(m_kart_internal_name),
PLAYER_DIFFICULTY_HANDICAP);
HANDICAP_MEDIUM);
core::stringw label = _("%s (handicapped)",
m_player_ident_spinner->getCustomText());
m_player_ident_spinner->setCustomText(label);

View File

@ -43,7 +43,7 @@ namespace GUIEngine
/** Whether this player confirmed their selection */
bool m_ready;
/** If the player is handicapped. */
PerPlayerDifficulty m_difficulty;
HandicapLevel m_handicap;
/** widget coordinates */
int player_name_x, player_name_y, player_name_w, player_name_h;
@ -132,8 +132,8 @@ namespace GUIEngine
bool isReady();
// ------------------------------------------------------------------------
/** \return Per player difficulty */
PerPlayerDifficulty getDifficulty();
/** \return handicap */
HandicapLevel getHandicap();
// -------------------------------------------------------------------------
/** Updates the animation (moving/shrinking/etc.) */

View File

@ -37,12 +37,12 @@
AbstractKart::AbstractKart(const std::string& ident,
int world_kart_id, int position,
const btTransform& init_transform,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri)
: Moveable()
{
m_world_kart_id = world_kart_id;
loadKartProperties(ident, difficulty, ri);
loadKartProperties(ident, handicap, ri);
} // AbstractKart
// ----------------------------------------------------------------------------
@ -73,7 +73,7 @@ void AbstractKart::reset()
// ----------------------------------------------------------------------------
void AbstractKart::loadKartProperties(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri)
{
m_kart_properties.reset(new KartProperties());
@ -84,9 +84,9 @@ void AbstractKart::loadKartProperties(const std::string& new_ident,
new_ident.c_str());
kp = kart_properties_manager->getKart(std::string("tux"));
}
m_kart_properties->copyForPlayer(kp, difficulty);
m_kart_properties->copyForPlayer(kp, handicap);
m_name = m_kart_properties->getName();
m_difficulty = difficulty;
m_handicap = handicap;
m_kart_animation = NULL;
assert(m_kart_properties);
@ -107,14 +107,14 @@ void AbstractKart::loadKartProperties(const std::string& new_ident,
// ----------------------------------------------------------------------------
void AbstractKart::changeKart(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri)
{
// Reset previous kart (including delete old animation above)
reset();
// Remove kart body
Physics::getInstance()->removeKart(this);
loadKartProperties(new_ident, difficulty, ri);
loadKartProperties(new_ident, handicap, ri);
} // changeKart
// ----------------------------------------------------------------------------

View File

@ -80,7 +80,7 @@ private:
// ------------------------------------------------------------------------
void loadKartProperties(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri);
protected:
btTransform m_starting_transform;
@ -90,8 +90,8 @@ protected:
/** The kart properties. */
std::unique_ptr<KartProperties> m_kart_properties;
/** The per-player difficulty. */
PerPlayerDifficulty m_difficulty;
/** The handicap level of this kart. */
HandicapLevel m_handicap;
/** This stores a copy of the kart model. It has to be a copy
* since otherwise incosistencies can happen if the same kart
@ -113,7 +113,7 @@ public:
AbstractKart(const std::string& ident,
int world_kart_id,
int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri);
virtual ~AbstractKart();
// ------------------------------------------------------------------------
@ -143,17 +143,16 @@ public:
// ========================================================================
/** Change to new kart instancely (used in network live join). */
virtual void changeKart(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri);
// ========================================================================
// Access to the per-player difficulty.
// Access to the handicap.
// ------------------------------------------------------------------------
/** Returns the per-player difficulty of this kart. */
const PerPlayerDifficulty getPerPlayerDifficulty() const
{ return m_difficulty; }
/** Returns the handicap of this kart. */
const HandicapLevel getHandicap() const { return m_handicap; }
// ------------------------------------------------------------------------
/** Sets the per-player difficulty. */
void setPerPlayerDifficulty(const PerPlayerDifficulty d) { m_difficulty=d; }
/** Sets the handicap. */
void setHandicap(const HandicapLevel h) { m_handicap=h; }
// ------------------------------------------------------------------------
/** Returns a unique identifier for this kart (name of the directory the

View File

@ -59,11 +59,11 @@
*/
LocalPlayerController::LocalPlayerController(AbstractKart *kart,
const int local_player_id,
PerPlayerDifficulty d)
HandicapLevel h)
: PlayerController(kart)
{
m_has_started = false;
m_difficulty = d;
m_handicap = h;
m_player = StateManager::get()->getActivePlayer(local_player_id);
if(m_player)
m_player->setKart(kart);
@ -433,7 +433,7 @@ core::stringw LocalPlayerController::getName() const
return PlayerController::getName();
core::stringw name = m_player->getProfile()->getName();
if (m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
if (m_handicap != HANDICAP_NONE)
name = _("%s (handicapped)", name);
return name;

View File

@ -51,7 +51,7 @@ private:
* camera object is managed in the Camera class, so no need to free it. */
int m_camera_index;
PerPlayerDifficulty m_difficulty;
HandicapLevel m_handicap;
SFXBase *m_wee_sound;
SFXBuffer *m_bzzt_sound;
@ -68,7 +68,7 @@ private:
public:
LocalPlayerController(AbstractKart *kart,
const int local_player_id,
PerPlayerDifficulty d);
HandicapLevel h);
~LocalPlayerController();
void update (int ticks) OVERRIDE;
bool action (PlayerAction action, int value,

View File

@ -405,7 +405,7 @@ core::stringw PlayerController::getName() const
const RemoteKartInfo& rki = race_manager->getKartInfo(
m_kart->getWorldKartId());
name = rki.getPlayerName();
if (rki.getDifficulty() == PLAYER_DIFFICULTY_HANDICAP)
if (rki.getHandicap() == HANDICAP_MEDIUM)
name = _("%s (handicapped)", name);
}
return name;

View File

@ -1944,7 +1944,7 @@ void SkiddingAI::computeNearestKarts()
target_index = target_index / (num_ai - 1);
}
assert(target_index >= 0 && target_index <= (int)n-1);
assert(target_index >= 0 && target_index <= n-1);
target_overall_distance = overall_distance[target_index];
}
// Now convert 'maximum overall distance' to distance to player.

View File

@ -35,7 +35,7 @@ GhostKart::GhostKart(const std::string& ident, unsigned int world_kart_id,
int position, float color_hue)
: Kart(ident, world_kart_id,
position, btTransform(btQuaternion(0, 0, 0, 1)),
PLAYER_DIFFICULTY_NORMAL,
HANDICAP_NONE,
std::make_shared<RenderInfo>(color_hue, true/*transparent*/))
{
} // GhostKart

View File

@ -113,9 +113,9 @@
*/
Kart::Kart (const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty, std::shared_ptr<RenderInfo> ri)
HandicapLevel handicap, std::shared_ptr<RenderInfo> ri)
: AbstractKart(ident, world_kart_id, position, init_transform,
difficulty, ri)
handicap, ri)
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# pragma warning(1:4355)
@ -231,10 +231,10 @@ void Kart::init(RaceManager::KartType type)
// ----------------------------------------------------------------------------
void Kart::changeKart(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri)
{
AbstractKart::changeKart(new_ident, difficulty, ri);
AbstractKart::changeKart(new_ident, handicap, ri);
m_kart_model->setKart(this);
#ifdef SERVER_ONLY

View File

@ -292,7 +292,7 @@ protected:
public:
Kart(const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri);
virtual ~Kart();
virtual void init(RaceManager::KartType type) OVERRIDE;
@ -336,7 +336,7 @@ public:
virtual void setController(Controller *controller) OVERRIDE;
virtual void setXYZ(const Vec3& a) OVERRIDE;
virtual void changeKart(const std::string& new_ident,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri) OVERRIDE;
// ========================================================================================

View File

@ -48,12 +48,12 @@
float KartProperties::UNDEFINED = -99.9f;
std::string KartProperties::getPerPlayerDifficultyAsString(PerPlayerDifficulty d)
std::string KartProperties::getHandicapAsString(HandicapLevel h)
{
switch(d)
switch(h)
{
case PLAYER_DIFFICULTY_NORMAL: return "normal"; break;
case PLAYER_DIFFICULTY_HANDICAP: return "handicap"; break;
case HANDICAP_NONE: return "normal"; break;
case HANDICAP_MEDIUM: return "handicap"; break;
default: assert(false);
}
return "";
@ -134,7 +134,7 @@ KartProperties::~KartProperties()
* values.
*/
void KartProperties::copyForPlayer(const KartProperties *source,
PerPlayerDifficulty d)
HandicapLevel h)
{
*this = *source;
@ -148,7 +148,7 @@ void KartProperties::copyForPlayer(const KartProperties *source,
// Combine the characteristics for this object. We can't copy it because
// this object has other pointers (to m_characteristic).
combineCharacteristics(d);
combineCharacteristics(h);
}
} // copyForPlayer
@ -230,7 +230,7 @@ void KartProperties::load(const std::string &filename, const std::string &node)
}
getAllData(root);
m_characteristic = std::make_shared<XmlCharacteristic>(root);
combineCharacteristics(PLAYER_DIFFICULTY_NORMAL);
combineCharacteristics(HANDICAP_NONE);
}
catch(std::exception& err)
{
@ -344,7 +344,7 @@ void KartProperties::setHatMeshName(const std::string &hat_name)
} // setHatMeshName
//-----------------------------------------------------------------------------
void KartProperties::combineCharacteristics(PerPlayerDifficulty difficulty)
void KartProperties::combineCharacteristics(HandicapLevel handicap)
{
m_combined_characteristic = std::make_shared<CombinedCharacteristic>();
m_combined_characteristic->addCharacteristic(kart_properties_manager->
@ -361,7 +361,7 @@ void KartProperties::combineCharacteristics(PerPlayerDifficulty difficulty)
m_combined_characteristic->addCharacteristic(characteristic);
m_combined_characteristic->addCharacteristic(kart_properties_manager->
getPlayerCharacteristic(getPerPlayerDifficultyAsString(difficulty)));
getPlayerCharacteristic(getHandicapAsString(handicap)));
m_combined_characteristic->addCharacteristic(m_characteristic.get());
m_cached_characteristic = std::make_shared<CachedCharacteristic>

View File

@ -208,16 +208,16 @@ private:
void load (const std::string &filename,
const std::string &node);
void combineCharacteristics(PerPlayerDifficulty d);
void combineCharacteristics(HandicapLevel h);
public:
/** Returns the string representation of a per-player difficulty. */
static std::string getPerPlayerDifficultyAsString(PerPlayerDifficulty d);
/** Returns the string representation of a handicap level. */
static std::string getHandicapAsString(HandicapLevel h);
KartProperties (const std::string &filename="");
~KartProperties ();
void copyForPlayer (const KartProperties *source,
PerPlayerDifficulty d = PLAYER_DIFFICULTY_NORMAL);
HandicapLevel h = HANDICAP_NONE);
void copyFrom (const KartProperties *source);
void getAllData (const XMLNode * root);
void checkAllSet (const std::string &filename);

View File

@ -46,14 +46,14 @@
KartRewinder::KartRewinder(const std::string& ident,
unsigned int world_kart_id, int position,
const btTransform& init_transform,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri)
: Rewinder(
{
RN_KART,
static_cast<char>(world_kart_id)
})
, Kart(ident, world_kart_id, position, init_transform, difficulty,
, Kart(ident, world_kart_id, position, init_transform, handicap,
ri)
{
m_steering_smoothing_dt = -1.0f;

View File

@ -35,7 +35,7 @@ private:
public:
KartRewinder(const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty,
HandicapLevel handicap,
std::shared_ptr<RenderInfo> ri);
~KartRewinder() {}
virtual void saveTransform() OVERRIDE;

View File

@ -26,9 +26,9 @@
KartWithStats::KartWithStats(const std::string& ident,
unsigned int world_kart_id,
int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty)
HandicapLevel handicap)
: Kart(ident, world_kart_id, position,
init_transform, difficulty, nullptr)
init_transform, handicap, nullptr)
{
} // KartWithStats

View File

@ -75,7 +75,7 @@ public:
unsigned int world_kart_id,
int position,
const btTransform& init_transform,
PerPlayerDifficulty difficulty);
HandicapLevel handicap);
virtual void update(int ticks) OVERRIDE;
virtual void reset() OVERRIDE;
virtual void collectedItem(ItemState *item_state) OVERRIDE;

View File

@ -1376,14 +1376,14 @@ int handleCmdLine(bool has_server_config, bool has_parent_process)
{
NetworkConfig::get()->addNetworkPlayer(
NULL, PlayerManager::get()->getPlayer(i),
PLAYER_DIFFICULTY_NORMAL);
HANDICAP_NONE);
}
}
else
{
NetworkConfig::get()->addNetworkPlayer(
input_manager->getDeviceManager()->getLatestUsedDevice(),
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
PlayerManager::getCurrentPlayer(), HANDICAP_NONE);
}
std::string fixed_ipv6 = StringUtils::findAndReplace(ipv6, "[", " ");
fixed_ipv6 = StringUtils::findAndReplace(fixed_ipv6, "]", " ");

View File

@ -107,13 +107,13 @@ void ProfileWorld::setProfileModeLaps(int laps)
std::shared_ptr<AbstractKart> ProfileWorld::createKart
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType kart_type,
PerPlayerDifficulty difficulty)
HandicapLevel handicap)
{
btTransform init_pos = getStartTransform(index);
std::shared_ptr<KartWithStats> new_kart =
std::make_shared<KartWithStats>(kart_ident, /*world kart id*/ index,
/*position*/ index + 1, init_pos, difficulty);
/*position*/ index + 1, init_pos, handicap);
new_kart->init(RaceManager::KT_AI);
Controller *controller = loadAIController(new_kart.get());
new_kart->setController(controller);

View File

@ -75,7 +75,7 @@ protected:
virtual std::shared_ptr<AbstractKart> createKart
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType type,
PerPlayerDifficulty difficulty);
HandicapLevel handicap);
public:
ProfileWorld();

View File

@ -704,7 +704,7 @@ void ThreeStrikesBattle::loadCustomModels()
for (unsigned int i = 0; i < pos.size(); i++)
{
auto sta = std::make_shared<Kart>(sta_list[i], (int)m_karts.size(),
(int)m_karts.size() + 1, pos[i], PLAYER_DIFFICULTY_NORMAL,
(int)m_karts.size() + 1, pos[i], HANDICAP_NONE,
std::make_shared<RenderInfo>(1.0f));
sta->init(RaceManager::KartType::KT_SPARE_TIRE);
sta->setController(new SpareTireAI(sta.get()));

View File

@ -234,13 +234,13 @@ void World::init()
{
new_kart = createKartWithTeam(kart_ident, i, local_player_id,
global_player_id, race_manager->getKartType(i),
race_manager->getPlayerDifficulty(i));
race_manager->getPlayerHandicap(i));
}
else
{
new_kart = createKart(kart_ident, i, local_player_id,
global_player_id, race_manager->getKartType(i),
race_manager->getPlayerDifficulty(i));
race_manager->getPlayerHandicap(i));
}
new_kart->setBoostAI(race_manager->hasBoostedAI(i));
m_karts.push_back(new_kart);
@ -428,7 +428,7 @@ void World::createRaceGUI()
std::shared_ptr<AbstractKart> World::createKart
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType kart_type,
PerPlayerDifficulty difficulty)
HandicapLevel handicap)
{
unsigned int gk = 0;
if (race_manager->hasGhostKarts())
@ -450,14 +450,14 @@ std::shared_ptr<AbstractKart> World::createKart
if (RewindManager::get()->isEnabled())
{
auto kr = std::make_shared<KartRewinder>(kart_ident, index, position,
init_pos, difficulty, ri);
init_pos, handicap, ri);
kr->rewinderAdd();
new_kart = kr;
}
else
{
new_kart = std::make_shared<Kart>(kart_ident, index, position,
init_pos, difficulty, ri);
init_pos, handicap, ri);
}
new_kart->init(race_manager->getKartType(index));
@ -479,7 +479,7 @@ std::shared_ptr<AbstractKart> World::createKart
else
{
controller = new LocalPlayerController(new_kart.get(),
local_player_id, difficulty);
local_player_id, handicap);
const PlayerProfile* p = StateManager::get()
->getActivePlayer(local_player_id)->getConstProfile();
if (p && p->getDefaultKartColor() > 0.0f)
@ -1430,7 +1430,7 @@ unsigned int World::getNumberOfRescuePositions() const
std::shared_ptr<AbstractKart> World::createKartWithTeam
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType kart_type,
PerPlayerDifficulty difficulty)
HandicapLevel handicap)
{
int cur_red = getTeamNum(KART_TEAM_RED);
int cur_blue = getTeamNum(KART_TEAM_BLUE);
@ -1490,14 +1490,14 @@ std::shared_ptr<AbstractKart> World::createKartWithTeam
if (RewindManager::get()->isEnabled())
{
auto kr = std::make_shared<KartRewinder>(kart_ident, index, position,
init_pos, difficulty, ri);
init_pos, handicap, ri);
kr->rewinderAdd();
new_kart = kr;
}
else
{
new_kart = std::make_shared<Kart>(kart_ident, index, position,
init_pos, difficulty, ri);
init_pos, handicap, ri);
}
new_kart->init(race_manager->getKartType(index));
@ -1506,8 +1506,7 @@ std::shared_ptr<AbstractKart> World::createKartWithTeam
switch(kart_type)
{
case RaceManager::KT_PLAYER:
controller = new LocalPlayerController(new_kart.get(), local_player_id,
difficulty);
controller = new LocalPlayerController(new_kart.get(), local_player_id, handicap);
m_num_players ++;
break;
case RaceManager::KT_NETWORK_PLAYER:

View File

@ -95,7 +95,7 @@ private:
std::shared_ptr<AbstractKart> createKartWithTeam
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType type,
PerPlayerDifficulty difficulty);
HandicapLevel handicap);
protected:
@ -140,7 +140,7 @@ protected:
virtual std::shared_ptr<AbstractKart> createKart
(const std::string &kart_ident, int index, int local_player_id,
int global_player_id, RaceManager::KartType type,
PerPlayerDifficulty difficulty);
HandicapLevel handicap);
/** Pointer to the race GUI. The race GUI is handled by world. */
RaceGUIBase *m_race_gui;

View File

@ -84,8 +84,7 @@ private:
/** Used by client server to determine if the child server is created. */
std::string m_server_id_file;
std::vector<std::tuple<InputDevice*, PlayerProfile*,
PerPlayerDifficulty> > m_network_players;
std::vector<std::tuple<InputDevice*, PlayerProfile*, HandicapLevel> > m_network_players;
NetworkConfig();
@ -151,8 +150,7 @@ public:
// ------------------------------------------------------------------------
void unsetNetworking();
// ------------------------------------------------------------------------
std::vector<std::tuple<InputDevice*, PlayerProfile*,
PerPlayerDifficulty> >&
std::vector<std::tuple<InputDevice*, PlayerProfile*, HandicapLevel> >&
getNetworkPlayers() { return m_network_players; }
// ------------------------------------------------------------------------
bool isAddingNetworkPlayers() const
@ -161,7 +159,7 @@ public:
void doneAddingNetworkPlayers() { m_done_adding_network_players = true; }
// ------------------------------------------------------------------------
bool addNetworkPlayer(InputDevice* device, PlayerProfile* profile,
PerPlayerDifficulty d)
HandicapLevel h)
{
for (auto& p : m_network_players)
{
@ -170,7 +168,7 @@ public:
if (std::get<1>(p) == profile)
return false;
}
m_network_players.emplace_back(device, profile, d);
m_network_players.emplace_back(device, profile, h);
return true;
}
// ------------------------------------------------------------------------

View File

@ -32,7 +32,7 @@
class STKPeer;
enum KartTeam : int8_t;
enum PerPlayerDifficulty : uint8_t;
enum HandicapLevel : uint8_t;
/*! \class NetworkPlayerProfile
* \brief Contains the profile of a player.
@ -52,8 +52,8 @@ private:
uint32_t m_online_id;
/** Per player difficulty. */
std::atomic<PerPlayerDifficulty> m_per_player_difficulty;
/** Handicap level of this player. */
std::atomic<HandicapLevel> m_handicap;
/** The selected kart id. */
std::string m_kart_name;
@ -88,7 +88,7 @@ public:
m_host_id = std::numeric_limits<uint32_t>::max();
m_default_kart_color = 0.0f;
m_online_id = 0;
m_per_player_difficulty.store((PerPlayerDifficulty)0);
m_handicap.store((HandicapLevel)0);
m_local_player_id = 0;
m_team.store(team);
resetGrandPrixData();
@ -97,7 +97,7 @@ public:
NetworkPlayerProfile(std::shared_ptr<STKPeer> peer,
const irr::core::stringw &name, uint32_t host_id,
float default_kart_color, uint32_t online_id,
PerPlayerDifficulty per_player_difficulty,
HandicapLevel handicap,
uint8_t local_player_id, KartTeam team,
const std::string& country_code)
{
@ -106,7 +106,7 @@ public:
m_host_id = host_id;
m_default_kart_color = default_kart_color;
m_online_id = online_id;
m_per_player_difficulty.store(per_player_difficulty);
m_handicap.store(handicap);
m_local_player_id = local_player_id;
m_team.store(team);
m_country_code = country_code;
@ -129,12 +129,10 @@ public:
/** Retuens the local player id for this player. */
uint8_t getLocalPlayerId() const { return m_local_player_id; }
// ------------------------------------------------------------------------
/** Returns the per-player difficulty. */
PerPlayerDifficulty getPerPlayerDifficulty() const
{ return m_per_player_difficulty.load(); }
/** Returns the player's handicap. */
HandicapLevel getHandicap() const { return m_handicap.load(); }
// ------------------------------------------------------------------------
void setPerPlayerDifficulty(PerPlayerDifficulty d)
{ m_per_player_difficulty.store(d); }
void setHandicap(HandicapLevel h) { m_handicap.store(h); }
// ------------------------------------------------------------------------
/** Returns the name of this player. */
const irr::core::stringw& getName() const { return m_player_name; }

View File

@ -320,7 +320,7 @@ void ClientLobby::addAllPlayers(Event* event)
std::vector<std::shared_ptr<NetworkPlayerProfile> >
ClientLobby::decodePlayers(const BareNetworkString& data,
std::shared_ptr<STKPeer> peer,
bool* is_specator) const
bool* is_spectator) const
{
std::vector<std::shared_ptr<NetworkPlayerProfile> > players;
unsigned player_count = data.getUInt8();
@ -331,15 +331,15 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
uint32_t host_id = data.getUInt32();
float kart_color = data.getFloat();
uint32_t online_id = data.getUInt32();
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
HandicapLevel handicap = (HandicapLevel)data.getUInt8();
uint8_t local_id = data.getUInt8();
KartTeam team = (KartTeam)data.getUInt8();
std::string country_code;
data.decodeString(&country_code);
if (is_specator && host_id == STKHost::get()->getMyHostId())
*is_specator = false;
if (is_spectator && host_id == STKHost::get()->getMyHostId())
*is_spectator = false;
auto player = std::make_shared<NetworkPlayerProfile>(peer, player_name,
host_id, kart_color, online_id, ppd, local_id, team, country_code);
host_id, kart_color, online_id, handicap, local_id, team, country_code);
std::string kart_name;
data.decodeString(&kart_name);
player->setKartName(kart_name);
@ -783,7 +783,7 @@ void ClientLobby::updatePlayerList(Event* event)
lp.m_host_id = data.getUInt32();
lp.m_online_id = data.getUInt32();
uint8_t local_id = data.getUInt8();
lp.m_difficulty = PLAYER_DIFFICULTY_NORMAL;
lp.m_handicap = HANDICAP_NONE;
lp.m_local_player_id = local_id;
data.decodeStringW(&lp.m_user_name);
total_players += lp.m_user_name;
@ -804,8 +804,8 @@ void ClientLobby::updatePlayerList(Event* event)
lp.m_icon_id = 5;
if (ready)
lp.m_icon_id = 4;
lp.m_difficulty = (PerPlayerDifficulty)data.getUInt8();
if (lp.m_difficulty == PLAYER_DIFFICULTY_HANDICAP)
lp.m_handicap = (HandicapLevel)data.getUInt8();
if (lp.m_handicap != HANDICAP_NONE)
{
lp.m_user_name = _("%s (handicapped)", lp.m_user_name);
}
@ -815,7 +815,7 @@ void ClientLobby::updatePlayerList(Event* event)
if (is_peer_server_owner)
client_server_owner = true;
auto& local_players = NetworkConfig::get()->getNetworkPlayers();
std::get<2>(local_players.at(local_id)) = lp.m_difficulty;
std::get<2>(local_players.at(local_id)) = lp.m_handicap;
}
data.decodeString(&lp.m_country_code);
m_lobby_players.push_back(lp);
@ -1302,7 +1302,7 @@ void ClientLobby::handleKartInfo(Event* event)
uint32_t host_id = data.getUInt32();
float kart_color = data.getFloat();
uint32_t online_id = data.getUInt32();
PerPlayerDifficulty ppd = (PerPlayerDifficulty)data.getUInt8();
HandicapLevel h = (HandicapLevel)data.getUInt8();
uint8_t local_id = data.getUInt8();
std::string kart_name;
data.decodeString(&kart_name);
@ -1314,7 +1314,7 @@ void ClientLobby::handleKartInfo(Event* event)
rki.setHostId(host_id);
rki.setDefaultKartColor(kart_color);
rki.setOnlineId(online_id);
rki.setPerPlayerDifficulty(ppd);
rki.setHandicap(h);
rki.setLocalPlayerId(local_id);
rki.setKartName(kart_name);
rki.setCountryCode(country_code);

View File

@ -31,7 +31,7 @@
enum PeerDisconnectInfo : unsigned int;
enum KartTeam : int8_t;
enum PerPlayerDifficulty : uint8_t;
enum HandicapLevel : uint8_t;
class BareNetworkString;
class Server;
@ -42,7 +42,7 @@ struct LobbyPlayer
int m_local_player_id;
uint32_t m_host_id;
KartTeam m_kart_team;
PerPlayerDifficulty m_difficulty;
HandicapLevel m_handicap;
uint32_t m_online_id;
/* Icon used in networking lobby, see NetworkingLobby::loadedFromFile. */
int m_icon_id;
@ -138,7 +138,7 @@ private:
std::vector<std::shared_ptr<NetworkPlayerProfile> >
decodePlayers(const BareNetworkString& data,
std::shared_ptr<STKPeer> peer = nullptr,
bool* is_specator = NULL) const;
bool* is_spectator = NULL) const;
public:
ClientLobby(const TransportAddress& a, std::shared_ptr<Server> s);
virtual ~ClientLobby();

View File

@ -129,7 +129,7 @@ void LobbyProtocol::configRemoteKart(
!is_local);
rki.setGlobalPlayerId(i);
rki.setDefaultKartColor(profile->getDefaultKartColor());
rki.setPerPlayerDifficulty(profile->getPerPlayerDifficulty());
rki.setHandicap(profile->getHandicap());
rki.setOnlineId(profile->getOnlineId());
if (race_manager->teamEnabled())
rki.setKartTeam(profile->getTeam());
@ -210,7 +210,7 @@ void LobbyProtocol::addLiveJoiningKart(int kart_id, const RemoteKartInfo& rki,
int live_join_util_ticks) const
{
AbstractKart* k = World::getWorld()->getKart(kart_id);
k->changeKart(rki.getKartName(), rki.getDifficulty(),
k->changeKart(rki.getKartName(), rki.getHandicap(),
rki.getKartTeam() == KART_TEAM_RED ?
std::make_shared<RenderInfo>(1.0f) :
rki.getKartTeam() == KART_TEAM_BLUE ?

View File

@ -1436,7 +1436,7 @@ void ServerLobby::encodePlayers(BareNetworkString* bns,
.addUInt32(player->getHostId())
.addFloat(player->getDefaultKartColor())
.addUInt32(player->getOnlineId())
.addUInt8(player->getPerPlayerDifficulty())
.addUInt8(player->getHandicap())
.addUInt8(player->getLocalPlayerId())
.addUInt8(
race_manager->teamEnabled() ? player->getTeam() : KART_TEAM_NONE)
@ -1630,7 +1630,7 @@ std::vector<std::shared_ptr<NetworkPlayerProfile> >
nullptr, rki.getPlayerName(),
std::numeric_limits<uint32_t>::max(),
rki.getDefaultKartColor(),
rki.getOnlineId(), rki.getDifficulty(),
rki.getOnlineId(), rki.getHandicap(),
rki.getLocalPlayerId(), KART_TEAM_NONE,
rki.getCountryCode());
player->setKartName(rki.getKartName());
@ -2606,8 +2606,8 @@ void ServerLobby::computeNewRankings()
double player1_time = race_manager->getKartRaceTime(i);
double player1_factor =
computeRankingFactor(race_manager->getKartInfo(i).getOnlineId());
double player1_handicap = ( w->getKart(i)->getPerPlayerDifficulty()
== PLAYER_DIFFICULTY_HANDICAP ) ? HANDICAP_OFFSET : 0;
double player1_handicap = ( w->getKart(i)->getHandicap()
== HANDICAP_NONE ) ? 0 : HANDICAP_OFFSET;
for (unsigned j = 0; j < player_count; j++)
{
@ -2627,8 +2627,8 @@ void ServerLobby::computeNewRankings()
double player2_scores = new_scores[j];
double player2_time = race_manager->getKartRaceTime(j);
double player2_handicap = ( w->getKart(j)->getPerPlayerDifficulty()
== PLAYER_DIFFICULTY_HANDICAP ) ? HANDICAP_OFFSET : 0;
double player2_handicap = ( w->getKart(j)->getHandicap()
== HANDICAP_NONE ) ? 0 : HANDICAP_OFFSET;
// Compute the result and race ranking importance
double player_factors = std::min(player1_factor,
@ -3196,13 +3196,12 @@ void ServerLobby::handleUnencryptedConnection(std::shared_ptr<STKPeer> peer,
if (name.empty())
name = L"unnamed";
float default_kart_color = data.getFloat();
PerPlayerDifficulty per_player_difficulty =
(PerPlayerDifficulty)data.getUInt8();
HandicapLevel handicap = (HandicapLevel)data.getUInt8();
auto player = std::make_shared<NetworkPlayerProfile>
(peer, i == 0 && !online_name.empty() && !peer->isAIPeer() ?
online_name : name,
peer->getHostId(), default_kart_color, i == 0 ? online_id : 0,
per_player_difficulty, (uint8_t)i, KART_TEAM_NONE,
handicap, (uint8_t)i, KART_TEAM_NONE,
country_code);
if (ServerConfig::m_team_choosing)
{
@ -3424,7 +3423,7 @@ void ServerLobby::updatePlayerList(bool update_when_reset_server)
if (p && p->isAIPeer())
boolean_combine |= (1 << 4);
pl->addUInt8(boolean_combine);
pl->addUInt8(profile->getPerPlayerDifficulty());
pl->addUInt8(profile->getHandicap());
if (ServerConfig::m_team_choosing &&
race_manager->teamEnabled())
pl->addUInt8(profile->getTeam());
@ -4543,14 +4542,14 @@ void ServerLobby::changeHandicap(Event* event)
}
uint8_t local_id = data.getUInt8();
auto& player = event->getPeer()->getPlayerProfiles().at(local_id);
uint8_t difficulty_id = data.getUInt8();
if (difficulty_id >= PLAYER_DIFFICULTY_COUNT)
uint8_t handicap_id = data.getUInt8();
if (handicap_id >= HANDICAP_COUNT)
{
Log::warn("ServerLobby", "Wrong handicap %d.", difficulty_id);
Log::warn("ServerLobby", "Wrong handicap %d.", handicap_id);
return;
}
PerPlayerDifficulty d = (PerPlayerDifficulty)difficulty_id;
player->setPerPlayerDifficulty(d);
HandicapLevel h = (HandicapLevel)handicap_id;
player->setHandicap(h);
updatePlayerList();
} // changeHandicap
@ -4708,7 +4707,7 @@ void ServerLobby::handleKartInfo(Event* event)
ns->addUInt8(LE_KART_INFO).addUInt32(live_join_util_ticks)
.addUInt8(kart_id) .encodeString(rki.getPlayerName())
.addUInt32(rki.getHostId()).addFloat(rki.getDefaultKartColor())
.addUInt32(rki.getOnlineId()).addUInt8(rki.getDifficulty())
.addUInt32(rki.getOnlineId()).addUInt8(rki.getHandicap())
.addUInt8((uint8_t)rki.getLocalPlayerId())
.encodeString(rki.getKartName()).encodeString(rki.getCountryCode());
peer->sendPacket(ns, true/*reliable*/);

View File

@ -22,13 +22,13 @@
void RemoteKartInfo::copyFrom(std::shared_ptr<NetworkPlayerProfile> p,
unsigned local_id)
{
m_kart_name = p->getKartName();
m_user_name = p->getName();
m_local_player_id = local_id;
m_host_id = p->getHostId();
m_difficulty = p->getPerPlayerDifficulty();
m_kart_name = p->getKartName();
m_user_name = p->getName();
m_local_player_id = local_id;
m_host_id = p->getHostId();
m_handicap = p->getHandicap();
m_default_kart_color = p->getDefaultKartColor();
m_online_id = p->getOnlineId();
m_country_code = p->getCountryCode();
m_profile = p;
m_online_id = p->getOnlineId();
m_country_code = p->getCountryCode();
m_profile = p;
} // copyFrom

View File

@ -35,12 +35,12 @@ enum KartTeam : int8_t
KART_TEAM_BLUE=1,
};
/** Game difficulty per player. */
enum PerPlayerDifficulty : uint8_t
/** Handicap per player. */
enum HandicapLevel : uint8_t
{
PLAYER_DIFFICULTY_NORMAL = 0,
PLAYER_DIFFICULTY_HANDICAP,
PLAYER_DIFFICULTY_COUNT
HANDICAP_NONE = 0,
HANDICAP_MEDIUM,
HANDICAP_COUNT
};
class NetworkPlayerProfile;
@ -54,7 +54,7 @@ class RemoteKartInfo
uint32_t m_host_id;
KartTeam m_kart_team;
bool m_network_player;
PerPlayerDifficulty m_difficulty;
HandicapLevel m_handicap;
float m_default_kart_color;
uint32_t m_online_id;
std::string m_country_code;
@ -67,7 +67,7 @@ public:
m_local_player_id(player_id), m_global_player_id(-1),
m_host_id(host_id), m_kart_team(KART_TEAM_NONE),
m_network_player(network),
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
m_handicap(HANDICAP_NONE),
m_default_kart_color(0.0f), m_online_id(0)
{}
RemoteKartInfo(const std::string& kart_name) : m_kart_name(kart_name),
@ -75,14 +75,14 @@ public:
m_global_player_id(-1),
m_host_id(std::numeric_limits<uint32_t>::max()),
m_kart_team(KART_TEAM_NONE), m_network_player(false),
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
m_handicap(HANDICAP_NONE),
m_default_kart_color(0.0f), m_online_id(0)
{}
RemoteKartInfo() : m_kart_name(""), m_user_name(""),
m_local_player_id(-1), m_global_player_id(-1),
m_host_id(std::numeric_limits<uint32_t>::max()),
m_kart_team(KART_TEAM_NONE), m_network_player(false),
m_difficulty(PLAYER_DIFFICULTY_NORMAL),
m_handicap(HANDICAP_NONE),
m_default_kart_color(0.0f), m_online_id(0)
{}
void setKartName(const std::string& n) { m_kart_name = n; }
@ -93,8 +93,7 @@ public:
void setKartTeam(KartTeam team) { m_kart_team = team; }
void setNetworkPlayer(bool value) { m_network_player = value; }
void setDefaultKartColor(float value) { m_default_kart_color = value; }
void setPerPlayerDifficulty(PerPlayerDifficulty value)
{ m_difficulty = value; }
void setHandicap(HandicapLevel value) { m_handicap = value; }
void setOnlineId(uint32_t id) { m_online_id = id; }
uint32_t getHostId() const { return m_host_id; }
int getLocalPlayerId() const { return m_local_player_id; }
@ -103,7 +102,7 @@ public:
const std::string& getKartName() const { return m_kart_name; }
const irr::core::stringw& getPlayerName() const { return m_user_name; }
KartTeam getKartTeam() const { return m_kart_team; }
PerPlayerDifficulty getDifficulty() const { return m_difficulty; }
HandicapLevel getHandicap() const { return m_handicap; }
float getDefaultKartColor() const { return m_default_kart_color; }
uint32_t getOnlineId() const { return m_online_id; }
void setCountryCode(const std::string& id) { m_country_code = id; }

View File

@ -97,14 +97,14 @@ RaceManager::RaceManager()
setSpareTireKartNum(0);
} // RaceManager
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Destructor for the race manager.
*/
RaceManager::~RaceManager()
{
} // ~RaceManager
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Resets the race manager in preparation for a new race. It sets the
* counter of finished karts to zero. It is called by world when
* restarting a race.
@ -144,7 +144,7 @@ void RaceManager::setDefaultAIKartList(const std::vector<std::string>& ai_list)
}
} // setDefaultAIKartList
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Sets a player kart (local and non-local).
* \param player_id Id of the player.
* \param ki Kart info structure for this player.
@ -164,7 +164,7 @@ void RaceManager::setPlayerKart(unsigned int player_id,
m_player_karts[player_id] = rki;
} // setPlayerKart
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Sets additional information for a player to indicate which soccer team it
* belongs to.
*/
@ -175,18 +175,17 @@ void RaceManager::setKartTeam(unsigned int player_id, KartTeam team)
m_player_karts[player_id].setKartTeam(team);
} // setKartTeam
//-----------------------------------------------------------------------------
/** Sets the per-player difficulty for a player.
//---------------------------------------------------------------------------------------------
/** Sets the handicap for a player.
*/
void RaceManager::setPlayerDifficulty(unsigned int player_id,
PerPlayerDifficulty difficulty)
void RaceManager::setPlayerHandicap(unsigned int player_id, HandicapLevel handicap)
{
assert(player_id < m_player_karts.size());
m_player_karts[player_id].setPerPlayerDifficulty(difficulty);
} // setPlayerDifficulty
m_player_karts[player_id].setHandicap(handicap);
} // setPlayerHandicap
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Returns a pointer to the kart which has a given GP rank.
* \param n The rank (1 to number of karts) to look for.
*/
@ -198,7 +197,7 @@ const AbstractKart *RaceManager::getKartWithGPRank(unsigned int n)
return NULL;
} // getKLartWithGPRank
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Returns the GP rank (between 1 and number of karts) of a local player.
* \param player_id Local id of the player.
*/
@ -215,7 +214,7 @@ int RaceManager::getLocalPlayerGPRank(const int player_id) const
return -1;
} // getLocalPlayerGPRank
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Sets the number of players and optional the number of local players.
* \param num Number of players.
* \param local_players Number of local players, only used from networking.
@ -253,7 +252,7 @@ RaceManager::Difficulty
return DIFFICULTY_HARD;
} // convertDifficulty
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Sets the difficulty to use.
* \param diff The difficulty to use.
*/
@ -262,7 +261,7 @@ void RaceManager::setDifficulty(Difficulty diff)
m_difficulty = diff;
} // setDifficulty
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Sets a single track to be used in the next race.
* \param track The identifier of the track to use.
*/
@ -274,7 +273,7 @@ void RaceManager::setTrack(const std::string& track)
m_coin_target = 0;
} // setTrack
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Computes the list of random karts to be used for the AI.
* If a command line option specifies karts, they will be used first
*/
@ -318,7 +317,7 @@ void RaceManager::computeRandomKartList()
} // computeRandomKartList
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Starts a new race or GP (or other mode).
* It sets up the list of player karts, AI karts, GP tracks if relevant
* etc.
@ -404,7 +403,7 @@ void RaceManager::startNew(bool from_overworld)
for(unsigned int i = 0; i < m_num_ghost_karts; i++)
{
m_kart_status.push_back(KartStatus(ReplayPlay::get()->getGhostKartName(i),
i, -1, -1, init_gp_rank, KT_GHOST, PLAYER_DIFFICULTY_NORMAL));
i, -1, -1, init_gp_rank, KT_GHOST, HANDICAP_NONE));
init_gp_rank ++;
}
}
@ -415,7 +414,7 @@ void RaceManager::startNew(bool from_overworld)
for(unsigned int i = 0; i < ai_kart_count; i++)
{
m_kart_status.push_back(KartStatus(m_ai_kart_list[i], i, -1, -1,
init_gp_rank, KT_AI, PLAYER_DIFFICULTY_NORMAL));
init_gp_rank, KT_AI, HANDICAP_NONE));
init_gp_rank ++;
if(UserConfigParams::m_ftl_debug)
{
@ -434,7 +433,7 @@ void RaceManager::startNew(bool from_overworld)
m_player_karts[i].getLocalPlayerId(),
m_player_karts[i].getGlobalPlayerId(),
init_gp_rank, kt,
m_player_karts[i].getDifficulty()));
m_player_karts[i].getHandicap()));
if(UserConfigParams::m_ftl_debug)
{
Log::debug("RaceManager", "[ftl] rank %d kart %s", init_gp_rank,
@ -472,7 +471,7 @@ void RaceManager::startNew(bool from_overworld)
startNextRace();
} // startNew
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Starts the next (or first) race.
* It sorts the kart status data structure
* according to the number of points, and then creates the world().
@ -634,7 +633,7 @@ void RaceManager::startNextRace()
main_loop->renderGUI(8200);
} // startNextRace
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Start the next race or go back to the start screen
* If there are more races to do, starts the next race, otherwise
* calls exitRace to finish the race.
@ -662,7 +661,7 @@ void RaceManager::next()
}
} // next
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Saves the current GP to the config.
*/
void RaceManager::saveGP()
@ -710,7 +709,7 @@ void RaceManager::saveGP()
user_config->saveConfig();
} // saveGP
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** This class is only used in computeGPRanks, but the C++ standard
* forbids the usage of local data type in templates, so we have to
@ -796,7 +795,7 @@ void RaceManager::computeGPRanks()
}
} // computeGPRanks
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Exit a race (and don't start the next one)
* \note In GP, displays the GP result screen first
* \param delete_world If set deletes the world.
@ -910,7 +909,7 @@ void RaceManager::exitRace(bool delete_world)
m_track_number = 0;
} // exitRace
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** A kart has finished the race at the specified time (which can be
* different from World::getWorld()->getClock() in case of setting
* extrapolated arrival times). This function is only called from
@ -946,7 +945,7 @@ void RaceManager::kartFinishedRace(const AbstractKart *kart, float time)
m_num_finished_players++;
} // kartFinishedRace
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Rerun the same race again
* This is called after a race is finished, and it will adjust
* the number of points and the overall time before restarting the race.
@ -962,7 +961,7 @@ void RaceManager::rerunRace()
World::getWorld()->reset(true /* restart */);
} // rerunRace
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Higher-level method to start a GP without having to care about
* the exact startup sequence
*/
@ -978,7 +977,7 @@ void RaceManager::startGP(const GrandPrixData &gp, bool from_overworld,
startNew(from_overworld);
}
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Higher-level method to start a GP without having to care about
* the exact startup sequence.
* \param trackIdent Internal name of the track to race on
@ -1026,7 +1025,7 @@ void RaceManager::startSingleRace(const std::string &track_ident,
startNew(from_overworld);
} // startSingleRace
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Fills up the remaining kart slots with AI karts.
*/
void RaceManager::setupPlayerKartInfo()
@ -1034,7 +1033,7 @@ void RaceManager::setupPlayerKartInfo()
computeRandomKartList();
} // setupPlayerKartInfo
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** \brief Function to start the race with only ghost kart(s) and watch.
* \param trackIdent Internal name of the track to race on
* \param num_laps Number of laps to race, or -1 if number of laps is
@ -1060,7 +1059,7 @@ void RaceManager::startWatchingReplay(const std::string &track_ident,
for(int i = 0; i < m_num_karts; i++)
{
m_kart_status.push_back(KartStatus(ReplayPlay::get()->getGhostKartName(i),
i, -1, -1, init_gp_rank, KT_GHOST, PLAYER_DIFFICULTY_NORMAL));
i, -1, -1, init_gp_rank, KT_GHOST, HANDICAP_NONE));
init_gp_rank ++;
}
@ -1068,7 +1067,7 @@ void RaceManager::startWatchingReplay(const std::string &track_ident,
startNextRace();
} // startWatchingReplay
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
void RaceManager::configGrandPrixResultFromNetwork(NetworkString& ns)
{
setMajorMode(MAJOR_MODE_GRAND_PRIX);
@ -1123,7 +1122,7 @@ void RaceManager::configGrandPrixResultFromNetwork(NetworkString& ns)
}
} // configGrandPrixResultFromNetwork
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
void RaceManager::clearNetworkGrandPrixResult()
{
if (m_major_mode != MAJOR_MODE_GRAND_PRIX)
@ -1137,7 +1136,7 @@ void RaceManager::clearNetworkGrandPrixResult()
} // clearNetworkGrandPrixResult
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Returns a (translated) name of a minor race mode.
* \param mode Minor race mode.
*/
@ -1165,7 +1164,7 @@ const core::stringw RaceManager::getNameOf(const MinorRaceModeType mode)
}
} // getNameOf
//-----------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
/** Returns the specified difficulty as a string. */
core::stringw RaceManager::getDifficultyName(Difficulty diff) const
{

View File

@ -268,20 +268,20 @@ public:
int m_gp_rank;
/** Boosted status (AI only). */
bool m_boosted_ai;
/** The difficulty for this player. */
PerPlayerDifficulty m_difficulty;
/** The handicap for this player. */
HandicapLevel m_handicap;
/** Kart color of player (used in gp win / lose screen). */
float m_color;
KartStatus(const std::string& ident, const int& prev_finish_pos,
int local_player_id, int global_player_id,
int init_gp_rank, KartType kt,
PerPlayerDifficulty difficulty) :
HandicapLevel handicap) :
m_ident(ident), m_score(0), m_last_score(0),
m_overall_time(0.0f), m_last_time(0.0f),
m_kart_type(kt),
m_local_player_id(local_player_id),
m_global_player_id(global_player_id),
m_gp_rank(init_gp_rank), m_difficulty(difficulty)
m_gp_rank(init_gp_rank), m_handicap(handicap)
{ m_boosted_ai = false; m_color = 0.0f; }
}; // KartStatus
@ -372,9 +372,9 @@ public:
*/
void setKartTeam(unsigned int player_id, KartTeam team);
/** Sets the per-player difficulty for a player.
/** Sets the handicap for a player.
*/
void setPlayerDifficulty(unsigned int player_id, PerPlayerDifficulty difficulty);
void setPlayerHandicap(unsigned int player_id, HandicapLevel handicap);
/** In case of non GP mode set the track to use.
* \param track Pointer to the track to use.
@ -643,10 +643,10 @@ public:
return m_kart_status[kart].m_kart_type;
} // getKartType
// ----------------------------------------------------------------------------------------
PerPlayerDifficulty getPlayerDifficulty(int kart) const
HandicapLevel getPlayerHandicap(int kart) const
{
return m_kart_status[kart].m_difficulty;
} // getPlayerDifficulty
return m_kart_status[kart].m_handicap;
} // getPlayerHandicap
// ----------------------------------------------------------------------------------------
bool hasBoostedAI(int kart) const
{
@ -846,7 +846,7 @@ public:
void addSpareTireKart(const std::string& name)
{
m_kart_status.push_back(KartStatus(name, 0, -1, -1,
-1, KT_SPARE_TIRE, PLAYER_DIFFICULTY_NORMAL));
-1, KT_SPARE_TIRE, HANDICAP_NONE));
m_num_spare_tire_karts++;
m_num_karts++;
} // addSpareTireKart

View File

@ -130,7 +130,7 @@ void NetworkPlayerDialog::beforeAddingWidgets()
{
m_handicap_widget = getWidget<IconButtonWidget>("remove");
m_handicap_widget->setVisible(true);
if (m_per_player_difficulty == PLAYER_DIFFICULTY_NORMAL)
if (m_handicap == HANDICAP_NONE)
{
//I18N: In the network player dialog
m_handicap_widget->setText(_("Enable handicap"));
@ -257,14 +257,14 @@ GUIEngine::EventPropagation
else if (m_handicap_widget &&
selection == m_handicap_widget->m_properties[PROP_ID])
{
PerPlayerDifficulty new_difficulty = PLAYER_DIFFICULTY_NORMAL;
if (m_per_player_difficulty == PLAYER_DIFFICULTY_NORMAL)
HandicapLevel new_handicap = HANDICAP_NONE;
if (m_handicap == HANDICAP_NONE)
{
new_difficulty = PLAYER_DIFFICULTY_HANDICAP;
new_handicap = HANDICAP_MEDIUM;
}
NetworkString change_handicap(PROTOCOL_LOBBY_ROOM);
change_handicap.addUInt8(LobbyProtocol::LE_CHANGE_HANDICAP)
.addUInt8(m_local_id).addUInt8(new_difficulty);
.addUInt8(m_local_id).addUInt8(new_handicap);
STKHost::get()->sendToServer(&change_handicap, true/*reliable*/);
m_self_destroy = true;
return GUIEngine::EVENT_BLOCK;

View File

@ -48,7 +48,7 @@ private:
const uint8_t m_local_id;
PerPlayerDifficulty m_per_player_difficulty;
HandicapLevel m_handicap;
const core::stringw m_name;
@ -81,9 +81,9 @@ public:
NetworkPlayerDialog(uint32_t host_id, uint32_t online_id, uint8_t local_id,
const core::stringw& name,
const std::string& country_code,
bool allow_change_team, PerPlayerDifficulty d)
bool allow_change_team, HandicapLevel h)
: ModalDialog(0.8f,0.8f), m_host_id(host_id), m_online_id(online_id),
m_local_id(local_id), m_per_player_difficulty(d),
m_local_id(local_id), m_handicap(h),
m_name(name), m_country_code(country_code),
m_allow_change_team(allow_change_team), m_self_destroy(false),
m_open_report_textbox(false),

View File

@ -112,12 +112,12 @@ GUIEngine::EventPropagation
const unsigned pid = m_profiles->getValue();
assert(pid < PlayerManager::get()->getNumPlayers());
PlayerProfile* p = m_available_players[pid];
const PerPlayerDifficulty d = m_handicap->getState() ?
PLAYER_DIFFICULTY_HANDICAP : PLAYER_DIFFICULTY_NORMAL;
if (NetworkConfig::get()->addNetworkPlayer(m_device, p, d))
const HandicapLevel h = m_handicap->getState() ?
HANDICAP_MEDIUM : HANDICAP_NONE;
if (NetworkConfig::get()->addNetworkPlayer(m_device, p, h))
{
core::stringw name = p->getName();
if (d == PLAYER_DIFFICULTY_HANDICAP)
if (h != HANDICAP_NONE)
name = _("%s (handicapped)", name);
NetworkingLobby::getInstance()->addSplitscreenPlayer(name);
m_self_destroy = true;

View File

@ -834,7 +834,7 @@ void KartSelectionScreen::updateKartStats(uint8_t widget_id,
if (kp != NULL)
{
w->setValues(kp, m_kart_widgets[widget_id].getDifficulty());
w->setValues(kp, m_kart_widgets[widget_id].getHandicap());
w->update(0);
}
else
@ -1260,9 +1260,9 @@ void KartSelectionScreen::allPlayersDone()
race_manager->setPlayerKart(n, selected_kart);
// Set per player difficulty if needed
// Set handicap if needed
if (m_multiplayer && UserConfigParams::m_per_player_difficulty)
race_manager->setPlayerDifficulty(n, m_kart_widgets[n].getDifficulty());
race_manager->setPlayerHandicap(n, m_kart_widgets[n].getHandicap());
}
// ---- Switch to assign mode

View File

@ -54,7 +54,7 @@ void NetworkKartSelectionScreen::init()
for (auto& p : NetworkConfig::get()->getNetworkPlayers())
{
joinPlayer(std::get<0>(p), std::get<1>(p));
if (std::get<2>(p) == PLAYER_DIFFICULTY_HANDICAP)
if (std::get<2>(p) == HANDICAP_MEDIUM)
{
m_kart_widgets.get(m_kart_widgets.size() -1)
->enableHandicapForNetwork();

View File

@ -597,7 +597,7 @@ void NetworkingLobby::eventCallback(Widget* widget, const std::string& name,
m_player_list->getSelectionInternalName()).m_country_code,
m_allow_change_team,
m_player_names.at(
m_player_list->getSelectionInternalName()).m_difficulty);
m_player_list->getSelectionInternalName()).m_handicap);
} // click on a user
else if (name == m_send_button->m_properties[PROP_ID])
{

View File

@ -98,7 +98,7 @@ void OnlineScreen::init()
{
NetworkConfig::get()->addNetworkPlayer(
input_manager->getDeviceManager()->getLatestUsedDevice(),
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
PlayerManager::getCurrentPlayer(), HANDICAP_NONE);
NetworkConfig::get()->doneAddingNetworkPlayers();
}
} // init
@ -170,7 +170,7 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
NetworkConfig::get()->cleanNetworkPlayers();
NetworkConfig::get()->addNetworkPlayer(
input_manager->getDeviceManager()->getLatestUsedDevice(),
PlayerManager::getCurrentPlayer(), PLAYER_DIFFICULTY_NORMAL);
PlayerManager::getCurrentPlayer(), HANDICAP_NONE);
NetworkConfig::get()->doneAddingNetworkPlayers();
}
else

View File

@ -106,11 +106,11 @@ void OptionsScreenGeneral::init()
stats->setActive(false);
chat->setActive(false);
}
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
difficulty->setState( UserConfigParams::m_per_player_difficulty );
CheckBoxWidget* handicap = getWidget<CheckBoxWidget>("enable-handicap");
assert( handicap != NULL );
handicap->setState( UserConfigParams::m_per_player_difficulty );
// I18N: Tooltip in the UI menu. Use enough linebreaks to make sure the text fits the screen in low resolutions.
difficulty->setTooltip(_("In multiplayer mode, players can select handicapped\n(more difficult) profiles on the kart selection screen"));
handicap->setTooltip(_("In multiplayer mode, players can select handicapped\n(more difficult) profiles on the kart selection screen"));
CheckBoxWidget* show_login = getWidget<CheckBoxWidget>("show-login");
assert( show_login!= NULL );
@ -240,11 +240,11 @@ void OptionsScreenGeneral::eventCallback(Widget* widget, const std::string& name
assert( show_login != NULL );
UserConfigParams::m_always_show_login_screen = show_login->getState();
}
else if (name=="perPlayerDifficulty")
else if (name=="enable-handicap")
{
CheckBoxWidget* difficulty = getWidget<CheckBoxWidget>("perPlayerDifficulty");
assert( difficulty != NULL );
UserConfigParams::m_per_player_difficulty = difficulty->getState();
CheckBoxWidget* handicap = getWidget<CheckBoxWidget>("enable-handicap");
assert( handicap != NULL );
UserConfigParams::m_per_player_difficulty = handicap->getState();
}
#ifdef MOBILE_STK
else if (name=="assets_settings")