Skip to content

Commit 61f7c1e

Browse files
committed
Fix GitHub Issue #71: Confusing starting numbers in two player mode
1 parent 02668d8 commit 61f7c1e

File tree

4 files changed

+17
-21
lines changed

4 files changed

+17
-21
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Bug fixes:
1313
* Fix GitHub Issue #66: Editor displays legacy track path on startup
1414
- Effective only on Linux/Unix
1515
* Fix GitHub Issue #69: Cars teleport above and below bridges when driving horizontally in Radiator
16+
* Fix GitHub Issue #71: Confusing starting numbers in two player mode
1617

1718
Other:
1819

src/game/carfactory.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,24 @@
1717

1818
#include <MCAssetManager>
1919

20-
std::unique_ptr<Car> CarFactory::buildCar(size_t index, size_t numCars, Game & game)
20+
std::unique_ptr<Car> CarFactory::buildCar(size_t index, size_t carCount, Game & game)
2121
{
2222
const int defaultPower = 200000; // This in Watts
2323
const float defaultDrag = 2.5f;
2424

25-
static const size_t NUM_CARS = numCars;
2625
static std::map<size_t, std::string> carImageMap = {
27-
{ NUM_CARS - 1, "carBlack" },
28-
{ NUM_CARS - 2, "carOrange" },
29-
{ NUM_CARS - 3, "carRed" },
30-
{ NUM_CARS - 4, "carBlue" },
31-
{ NUM_CARS - 5, "carDarkGreen" },
32-
{ NUM_CARS - 6, "carBrown" },
33-
{ NUM_CARS - 7, "carCyan" },
34-
{ NUM_CARS - 8, "carViolet" },
35-
{ NUM_CARS - 9, "carGreen" },
36-
{ NUM_CARS - 10, "carDarkRed" },
26+
{ 0, "carPink" },
3727
{ 1, "carGrey" },
38-
{ 0, "carPink" }
28+
{ 2, "carDarkRed" },
29+
{ 3, "carGreen" },
30+
{ 4, "carViolet" },
31+
{ 5, "carCyan" },
32+
{ 6, "carBrown" },
33+
{ 7, "carDarkGreen" },
34+
{ 8, "carBlue" },
35+
{ 9, "carRed" },
36+
{ 10, "carOrange" },
37+
{ 11, "carBlack" }
3938
};
4039

4140
Car::Description desc;
@@ -60,8 +59,8 @@ std::unique_ptr<Car> CarFactory::buildCar(size_t index, size_t numCars, Game & g
6059
// Introduce some variance to the power of computer players so that the
6160
// slowest cars have less power than the human player and the fastest
6261
// cars have more power than the human player.
63-
desc.power = defaultPower / 2 + (index + 1) * defaultPower / NUM_CARS;
64-
desc.accelerationFriction = (0.3f + 0.4f * float(index + 1) / NUM_CARS) * Game::instance().difficultyProfile().accelerationFrictionMultiplier(false);
62+
desc.power = defaultPower / 2 + (index + 1) * defaultPower / carCount;
63+
desc.accelerationFriction = (0.3f + 0.4f * float(index + 1) / carCount) * Game::instance().difficultyProfile().accelerationFrictionMultiplier(false);
6564
desc.dragQuadratic = defaultDrag;
6665

6766
return std::make_unique<Car>(desc, MCAssetManager::surfaceManager().surface(carImage), index, false);

src/game/carfactory.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <memory>
2323

2424
namespace CarFactory {
25-
std::unique_ptr<Car> buildCar(size_t index, size_t numCars, Game & game);
25+
std::unique_ptr<Car> buildCar(size_t index, size_t carCount, Game & game);
2626
}
2727

2828
#endif // CARFACTORY_HPP

src/game/graphicsfactory.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@
3030

3131
MCSurface & GraphicsFactory::generateNumberSurface(size_t index)
3232
{
33-
static const std::vector<std::string> numberPlates(
34-
{ "1", "11", "10", "9", "8", "7", "6", "5", "4", "3", "2", "x" });
35-
assert(index < numberPlates.size());
36-
3733
const int pixmapWidth = 32;
3834
const int pixmapHeight = 32;
3935

@@ -55,7 +51,7 @@ MCSurface & GraphicsFactory::generateNumberSurface(size_t index)
5551
pixmapWidth,
5652
pixmapHeight,
5753
Qt::AlignCenter,
58-
numberPlates.at(index).c_str());
54+
std::to_string(index + 1).c_str());
5955

6056
painter.end();
6157

0 commit comments

Comments
 (0)