Commit graph

5272 commits

Author SHA1 Message Date
ef04856f25
cmake: Replace SVN versioning with git-describe(1)
Now that the project has been migrated from SVN to Git,
the complex logic to determine the project version is now no longer
needed, since Git can achieve the same effect with git-describe(1). [1]

TODO: CPack-related code should be also updated accordingly.

[1]: https://git-scm.com/docs/git-describe
2024-12-31 06:50:42 +01:00
58a4692905
CMakeLists.txt: Remove obsolete < 3.0.2 checks
CMake 3.0.2 was released over ten years ago. [1] It is therefore assumed
that more modern CMake versions are already widely available.

[1]: https://cmake.org/files/v3.0/
2024-12-31 06:25:57 +01:00
9a21275afc
Reload GfRaceManagers on downloadsmenu exit
This is required since _vecAcceptedCarCategoryIds must be reloaded so
that car categories are refreshed when entering the driver selection
menu.
2024-12-31 06:14:07 +01:00
a0c2dcc761
Reload tracks on downloadsmenu exit 2024-12-31 06:14:07 +01:00
bc95fd8f25
unitmain.cpp: Do not error on failed getCategory
The game would already ignore drivers with a non-existing car.
2024-12-31 06:14:07 +01:00
6fb613cc89
cmake: Do not install anything as DATA
Since the migration from SVN to Git, the data/ directory was put into a
separate repository, so that the engine repository should never install
anything there.
2024-12-31 06:14:07 +01:00
e93d3a9900
cmake: Leave SD_DATADIR empty if undefined
Otherwise, if the speed-dreams-data package is not found, SD_DATADIR
would expand to "/", which is a valid directory that the game would
attempt to look up.
2024-12-31 06:14:06 +01:00
d831bacfba
tgf/tgf.cpp: Return empty tgtPath on empty srcPath
Otherwise, even if srcPath is empty, a trailing '/' would be appended to
tgtPath, and therefore it would not be possible to get an empty data
directory if SD_DATADIR is undefined or empty.
2024-12-31 06:14:06 +01:00
522022fe1f
Remove xmlversion
This command line tool was meant to generate a XML file (typically,
version.xml) containing the version numbers for a list of files defined
by the SD_INSTALL_FILES CMake macro. Then, the game would read this XML
file and copy files around if an update was needed.

Unfortunately, this introduced a circular dependency between the engine
and data repositories, as the engine repository would rely on the data
directory to know the file list, and the data repository would rely on
the xmlversion executable to be available, and therefore the engine
repository.

Ultimately, none of this was needed: it is much simpler to define a
static, line-separated list of files in the data repository, and then
let the game figure out the versioning by itself. This renders
xmlversion entirely redundant, and therefore breaks the circular
dependency. As a bonus, some overly complex CMake stuff could be
removed.
2024-12-31 06:14:06 +01:00
91b7a3bb41
tgf/params.cpp: Return -1 on error
Otherwise, it would be impossible to distinguish an error from version
number '0', which is also valid.
2024-12-31 06:14:06 +01:00
63489e627e
install.cmake: Remove obsolete macros
Car/track installation is handled by the speed-dreams-data package.
2024-12-31 06:14:06 +01:00
cf18241a16
cmake: Get SD_DATADIR from speed-dreams-data package
So far, the game assets were located in the same repository as the game
engine. Since data and engine are split into different repositories, now
this project requires users to assign the CMAKE_PREFIX_PATH variable [1]
to indicate the location, only in the case of non-standard locations.

[1]: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html
2024-12-31 06:14:06 +01:00
f593eee939
Rename COPYING.txt to LICENSE 2024-12-31 06:14:05 +01:00
f9b820229f
Replace README.txt with README.md 2024-12-31 06:14:05 +01:00
7bd0fe9fa9
CMakeLists.txt: Do not depend on data/ 2024-12-31 05:23:42 +01:00
4d53ae9ce6
Add .gitignore 2024-12-31 05:23:42 +01:00
fec5fc09d3 drivers/CMakeLists.txt: Remove urbanski
Even if urbanski is a good example of a minimalistic implementation that
can be used for learning, it is far from a competitive driver and is
highly prone to crash in race, which would affect user experience
negatively.

Therefore, it is better to leave the source code available for reference
purposes, but do not include it into the build so that urbanski-drivers
cannot be selected.


Former-commit-id: 277281ef785291f0e7deb262e2c2c3b8f9cffc3b
Former-commit-id: efde653b918a8a4df65ac23b15025e4aeefc9275
2024-12-25 08:06:45 +01:00
65861b65dd Remove bt, K1999, hymie and kilo2008
These drivers are considered obsolete and were not even built any more.


Former-commit-id: 951cff0a690a7fe9320ed767863495266bac5159
Former-commit-id: 923e07a5ee892d5dab22593934c98958fdd63ed7
2024-12-25 08:06:44 +01:00
91d844529b simplix: Remove static buffers, use .json
Having statically allocated buffers in this context was not only
unnecessary, but also dangerous because these strings would be shared
among all TDriver instances, even if they really should not, since every
TDriver instance belongs to a different driver, and therefore different
parameters.

Also, since racing lines are now dumped into JSON files, it makes sense
to reflect this into the file extension, too, so that text editors can
easily recognise the syntax.


Former-commit-id: 3421b724bfc040f288fe61ffc0fc78fe5a25cd4f
Former-commit-id: 0844542eecaa950c1f96a860e2fcd21d6807059a
2024-12-25 08:06:44 +01:00
79765ddb87 unitclothoid.cpp: Rewrite points load/save
Since oPathPoints is defined as a std::vector, dumping TPathPt instances
as Plain Old Data is not valid any more. In fact, C++ compilers would
already warn that offsetof(3) could not be safely used with TPathPt
members since it never was Plain Old Data, but this warning was
suppressed only because raw pointer manipulation had been used instead
of offsetof(3).

On the other hand, dumping binary data is inherently non-portable and
not human-readable, so this commit suggests to dump such data in JSON
format, as cJSON is already used by the project and XML is bad, among
many other things, to store arbitrarily large arrays.


Former-commit-id: 4a447adb452dd9ae85ca4cce9993cbe9ad0487f6
Former-commit-id: b462a614ed53f1938eadb4680a10ef57576b29d9
2024-12-25 08:06:44 +01:00
d801a160f1 unitlane.cpp: Remove reference to TDriver
Otherwise, copying TLane objects using the default copy operation would
not be possible.


Former-commit-id: be7ac7e2191792ad8e43766ea39f745591f10916
Former-commit-id: 4d17b9524cd539c0dca0220108dea1d7a38e9f9b
2024-12-25 08:06:44 +01:00
8a6b2aadc7 simplix: Replace arrays with std::vector
Former-commit-id: 8b4302b8b5bbd9c7aed3d29fdf2f3c820c1573c5
Former-commit-id: 3c72d5837afce3fd38aaf2055ef9b3d2a45a134b
2024-12-25 08:06:44 +01:00
4a36fd8de7 unitlane.h: Remove dummy member
Former-commit-id: 51dc81acf9d63f7d546d0937bd1fd8543dced110
Former-commit-id: 270770ed620a887b1e5e3442f5777c45cab34c50
2024-12-25 08:06:43 +01:00
70acd3d39d unitstrategy.cpp: Use std::string::c_str
Former-commit-id: 4728473b0d6e7cffcdc44c51632d2677efb8b70b
Former-commit-id: 25db904cdebe501c4db16eaf2bf963631e54e6a4
2024-12-25 08:06:43 +01:00
9af00aa398 unitclothoid: const-qualify TClothoidLane::GetWeather
Former-commit-id: c42308e360bd00209ec962fd62fd7c7029e9e429
Former-commit-id: 25f42663812c6cb8467c361cf136061305fb4132
2024-12-25 08:06:43 +01:00
f1c266b487 simplix: Refactor a few things
- Replace some non-const-correct char * to std::string to avoid
potential dangling pointers and manual memory management.
- oCommonData was deemed redundant, so unitcommondata.{cpp,h} have been
removed.
- There was no need to define non-default destructors or operator= for
TCarParam.
- oSideScaleMu and oSideScaleBrake were always set to 0.95f instead of
0.97f by all categories, so assume these values as defaults and remove
both TDriver::ScaleSide and these variables altogether.
- Since robots now allocated driver data dynamically i.e., without
any arbitrary limits, oExtended was deemed redundant.


Former-commit-id: 6f64dba41e036e37345bfba1d2de75bdb347a976
Former-commit-id: bd10700dae55653ef15936f3613c942a8ec753a7
2024-12-25 08:06:43 +01:00
b70c47d274 simplix: Set oRacingLine as std::vector
Former-commit-id: 9f1b1e376ad6959e683f016b5d253eb885bc08d1
Former-commit-id: 0da217a412a5b19a24cc3b23a6259521c1cc18cf
2024-12-25 08:06:43 +01:00
65a0e9bc92 simplix: Remove static variables
Similarly to other driver implementations, simplix relied on
arbitrarily-sized buffers to store driver data, instead of allocating it
dynamically.

Furthermore, simplix relied on having per-category copies of its shared
library (e.g.: simplix_ls1, simplix_sc) to perform per-category
initializations and store them into statically allocated variables.
This has been fixed so that per-category initializations are perfomed
from the driver side, which means that one shared library can be used
for all car categories.

Since drivers are now re-indexed on every call to GfDrivers::reload,
IndexOffset is no longer needed.


Former-commit-id: f621a13850e08c9f36c90286d6548ed0c117290b
Former-commit-id: 6d93fe0a4d4130712e08a1d75336b4286bcf3039
2024-12-25 08:06:43 +01:00
3bc1d9b5c3 dandroid: Simplify driver track/car parameters
Most of dandroid's private parameters are shared among cars and even
entire categories, and only a small fraction of such parameters are ever
changed.

Therefore, this commit suggests sane defaults so as to remove all
redundant parameters in order to greatly simplify dandroid-based driver
parameters. Also, it adds the possibility to set per-category
parameters.


Former-commit-id: a052f11ff35809692afbc17c62c62efc65e00412
Former-commit-id: e98696da43da0967a8af167540da4733754f71ce
2024-12-25 08:06:42 +01:00
9c2e389c7d usr: Reorder initialiser list
C++ requires members to be initialised in the same order as they are
listed on the class definition. Otherwise, some compilers might throw a
warning message.


Former-commit-id: 3e05446ec7f0924384c84fe521800bac7a685cfb
Former-commit-id: 51f964c03df3bc1fd5988db2a39acae7984e5531
2024-12-25 08:06:41 +01:00
41ed56d1f6 usr: Allow default values
So far, usr would crash the game if parameters were missing for a
specific car, track or weather code. Since dynamically generated
drivers introduce a combinatory explosion, it is no longer acceptable to
crash on missing parameters, so now sane defaults are assumed.


Former-commit-id: 7975c8252737cd565fad3a1abb8b8684f8628782
Former-commit-id: ed19385aa318ffd24e86b254ebe75aac45657540
2024-12-25 08:06:40 +01:00
38e0ab0584 Remove robot clones
Robot clones were shared library duplicates with a different name that
the game would rely on to perform different actions based on the car
category.

Not only this was a hacky solution, but it also involved around 50
extra libraries loaded into the game, which means higher resource
consumption and slower startup time, as well as making driver management
more difficult to the much higher of directories involved in
data/drivers/.

Now, only 1 shared library per robot is defined.


Former-commit-id: 4c5141000bc9b46363a16c0928e90b14f40a430a
Former-commit-id: 773f3d6987da3f6ef8e78e0f0276e2d4bf2b07f2
2024-12-25 07:38:02 +01:00
ee1deeaf00 Remove career mode
Career mode was meant as an alternative championship mode with
dynamically generated drivers, but it is now redundant since dynamically
generated drivers are available to all racing modes.


Former-commit-id: 6f989742df5d35d8ac578e9e985653387585ec8a
Former-commit-id: ae91a723182e29f2ded228dfcc6da9466a950fe7
2024-12-25 07:38:02 +01:00
8014db4013 legacymenu: Update driver handling in downloader
Dynamically generated drivers have introduced a few breaking changes:

- Now, all drivers, whether generated or not, are stored into
GfLocalDir.
- Driver indexes, and therefore directory names, are recalculated every
time GfDrivers::reload is called, so the in-game must find the next
available index number on a given subdirectory.
- As a consequence of this, the file-based timestamp mechanism used in
cars and tracks cannot be used for drivers, since the directory name can
(and will) change at any time. Instead, GfDrivers::self() is looked up.


Former-commit-id: 05dcbec981a449be50e8656f105481b77881508b
Former-commit-id: c965c211b9e427f37317c84c16a6746f1b817eff
2024-12-25 07:38:01 +01:00
30144d1dfd shadow: Use std::vector in LearnedGraph
shadow's LearnedGraph relied on manual memory management and non-default
copy operators, which is error-prone (in fact, m_pAxis was being leaked)
and does not provide any benefits over std::vector.


Former-commit-id: 0ade39d572f94ba718556072a2ea3da15b9aabfe
Former-commit-id: ef035240597399743265a4c17a2ee47399956976
2024-12-25 07:38:01 +01:00
42a85d9f70 shadow: Move s_shared to Driver
Defining a m_pShared as a per-object pointer that always points to the
same object is redundant, and can introduce a risk for dangling
pointers.

Instead, s_shared (now, m_pShared) has been defined as a static member
in Driver.


Former-commit-id: 1f0baed4cfba1ddc47dc905d1791780164a23cc7
Former-commit-id: 7f8bdec56810b51ed8dde0d76e5aac4d462e6e87
2024-12-25 07:38:01 +01:00
00adba4eac shadow: Read skill from GfLocalDir (fixup)
Former-commit-id: 5075e9abe0fe435857382da309153f287480c103
Former-commit-id: 0d36d7303233b3251ab0bf9cf8a23f8f53384904
2024-12-25 07:38:01 +01:00
913168351f shadow: Remove unneeded operator overloads
An excessive use of operator= overloads was defined so as to copy
common parameters from Path-derived classes, such as ClothoidPath and
PitPath. However, this could be simplified since the default copy
operator would suffice.


Former-commit-id: c8954549c68036713840357c6851aec68ce713cb
Former-commit-id: bd91f618590a9f3dcc1c5cfec2ae995536840526
2024-12-25 07:38:01 +01:00
a7bad18d40 shadow: Fix out-of-bounds access
Even if shadow was defined with OOP in mind, for some unknown reason
Driver::Drive relied on a statically allocated array with an arbitrary
size of MAX_MOD_ITF elements (20). Because now the game supports a
virtually unlimited number of drivers (aka interfaces), it was possible
to read past the last_srslip array and cause undefined behaviour.

As hinted above, this array did not make any sense since last_srslip
should be part of each Driver object, and not a statically allocated
array.


Former-commit-id: e365060392b1d08c40a1e3d27f0e113d5a31594d
Former-commit-id: d8954641d78f83d198493e7cb36ffe3db9ef0a55
2024-12-25 07:38:01 +01:00
a596778f28 Look for driver name instead of index
Since driver indexes are now recalculated every time GfDrivers::reload
is called, they can be no longer relied on. Instead, driver names are
now used to find a specific driver, since names are set on creation.


Former-commit-id: 7a1d950db421e3cffee05736e0c31948cf534e4c
Former-commit-id: a6e0b38cbffb89ee9a47c1da926fc5959f1b7424
2024-12-25 07:38:00 +01:00
ca14f297ed CarModel.cpp: Add missing initialisers
Former-commit-id: cde7ed296281a1103d8a9554ec986355dafa1da5
Former-commit-id: d7dad55ee9517d9b27e135fc5974fb741f994238
2024-12-25 07:38:00 +01:00
3f0e4fd664 dandroid/driver.cpp: Read parameters from GfLocalDir
Driver parameters (name, short name, code, etc.) are now stored into
GfLocalDir by GfDrivers::reload.


Former-commit-id: c02545750adda862a4c31f837dc6e710a256cdb7
Former-commit-id: a258d6510bb7da1402b3fca3e82a2d1d7a56a2f3
2024-12-25 07:38:00 +01:00
916c316e58 src/drivers: Remove static limitations
So far, every robot would set up an arbitrary limit on the number of
drivers that could be defined. Not only it was an inefficient approach
because of the fixed-size statically allocated buffers this would incur,
but also there is no reason why this should not be allocated
dynamically.

Now, the internal data structures for each robot are generated
dynamically depending on the number of drivers defined by its parameter
file.


Former-commit-id: 65682fb3d457e2a38fe62cd5b2f00e908bb6aca8
Former-commit-id: 10d86064d066c96f0061080b9ec817e39548277f
2024-12-25 07:38:00 +01:00
4ae0ad6f44 shadow: Remove useless struct
Former-commit-id: 75cc75dfe59c0a08dbea011abb56396345f718c6
Former-commit-id: 46f66e8a0518f903c23a7f8b55b0f60e4c0328b5
2024-12-25 07:38:00 +01:00
6c00aa0c84 src/drivers: Read parameters from GfLocalDir
Since drivers can be now dynamically generated and this requires write
permissions, they are now always stored into GfLocalDir instead of
GfDataDir.


Former-commit-id: 2dac3225c4710caa2afa5da36cbbe5a9b86d3be8
Former-commit-id: 317f9d9b04b4ff7f78e3da15c82f1b77c894415c
2024-12-25 07:37:59 +01:00
afa040bf31 driverselect: Implement driver generation
Now, drivers from any category, robot type or car model can be generated
or deleted from the driver selection menu.


Former-commit-id: 41f2eec41a9ce23d84fe3779c496223c5a19da9b
Former-commit-id: 1957959d6bb70cc75caf980e9931c089b3d0d17c
2024-12-25 07:37:59 +01:00
825f2a645e drivers.cpp drivers.h
Former-commit-id: b72e3170374cb5daf950083f7124ec5805278966
Former-commit-id: bea07017d34527f2f2b7c486ab6ce1f375f87c26
2024-12-25 07:37:59 +01:00
8fe30c47f9 drivers.cpp: const-qualify pCurModule
Former-commit-id: 87f479cc083005205ed50a6d8259c4e637d055bf
Former-commit-id: 654d6f0815e86f955cc4cf143abcbd736abc72f6
2024-12-25 07:37:59 +01:00
1f604ffa93 Reload car list on exiting the in-game downloader
Since cars can be now downloaded from the in-game download manager,
the internal list of cars must be updated without having to restart the
game.


Former-commit-id: 0f5f9a71ad85129e7640df853cbdf9e917c4e5a8
Former-commit-id: c9482b032444635021a00970310ccca57d49fe50
2024-12-25 07:37:59 +01:00
295d66e383 driverselect.cpp: List driver type even if empty
Former-commit-id: 815c1ecedd310daa17d72b2839363f5cdd7fc1d5
Former-commit-id: 6ddcdc956d19b3cb52642a2d6fc7beaf4dab34aa
2024-12-25 07:37:59 +01:00