Commit Graph

588 Commits

Author SHA1 Message Date
Tom Stellard 80f57abba9 Fix build with glib < 2.62 2020-12-24 10:43:39 -08:00
Tom Stellard 3ca25bc3df Make VERS macro overrideable on the command line
This will allow custom version strings when building.
2020-12-24 10:43:39 -08:00
Tom Stellard aca4039893 Fix reserve team promotion rules when using promotion games 2020-12-24 10:43:39 -08:00
Tom Stellard eb15df7cd9 Allow using rank_start and rank_end tags for prom_games
This adds the same functionality already supported by the prom_rel
tags to support reserve team promotion rules for promotion games.
This allows you to specify a larger range of teams to promte than
the number of teams defined with the number_of_teams tag, so that
if a team is ineligible for promotion than other teams can be
substituted.  For example, if you wanted to promote at most 2
of the top 3 teams, you could do:

<prom_games>
  <prom_games_number_of_advance>2</prom_games_number_of_advance>
  <rank_start>1</rank_start>
  <rank_end>3</rank_end>
</prom_games>

Note that the rank_start and rank_end tags are not supported when using
the prom_games_loser_sid tag.
2020-12-24 10:43:39 -08:00
Tom Stellard 6061cd0938 cups: Fix a bug in cups with only 2 teams playing in the first round
A cup in wich all teams get byes except for two in the first round
would not have any additional rounds added, because the teams with
byes were not being counted in the total number of teams remaining.
2020-12-24 10:43:39 -08:00
Tom Stellard 9d2440be85 Exclude reserve teams from cups by default
If you need to define a cup that includes reserve teams, you can add the
include_reserve_teams property to the cup definition.
2020-12-24 10:43:39 -08:00
Tom Stellard 344bc82b53 Simplify some duplicated code in cup_load_choose_team_from_league() 2020-12-24 10:43:39 -08:00
Tom Stellard 996bccc739 Implement promotion and relegation rules for reserve teams
This adds some new rules for promoting and relegating reserve
teams:

+ Reserve teams will not be promoted into a league that contains its
  first team or a higher-level reserve team.
+ If a first team or higher-level reserve team is relegated to a league
  with a lower reserve team, then that reserve team will also be relegated.

In order to enable these rules, you must add the
<reserve_promotion_rules>default</reserve_promotion_rules> tag to your
contry xml file, and also define reserve teams in your league/team_defs
file using the <first_team> and <reserve_level> tags.
2020-12-24 10:43:39 -08:00
Tom Stellard f928273875 Add first_team and reserve_level tags to team element
The first_team tag can be used to indicate that a team is a 'reserve
team'.  The value for this new tag is the name of the first team
for this reserve team.  The reserve_level is used to indicate if this
is the 2nd, 3rd, 4th, etc. team for the first team. For example:

<team>
  <team_name>Blue</team_name>
</team>
<team>
  <team_name>Blue 2</team_name>
  <first_team>Blue</first_team>
  <reserve_level>2</reserve_level>
</team>
<team>
  <team_name>Blue 3</team_name>
  <first_team>Blue</first_team>
  <reserve_level>3</reserve_level>
</team>
2020-12-24 10:43:39 -08:00
Tom Stellard 8bca18d8a2 Add number_of_teams tag to prom_rel_element
This tag is intended to be used for leagues that may have some teams in
the league that are ineligible for promotions (e.g. reserve teams).
Often these leagues will promote 2 of the top 3 teams or something
similar, so if one team is ineligible, the league would still be able
to promote 2 teams.  Below is an example of how to model this scenario
with the new tag:

<prom_rel_element>
  <rank_start>1</rank_start>
  <rank_end>3</rank_end>
  <number_of_teams>2</number_of_teams>
</prom_rel_element>
2020-12-24 10:43:39 -08:00
Tom Stellard a31ea36c08 Cache some commonly used constants
All constants were stored in a g_datalist structure, which has very slow
lookups.  This was not ideally for constansts used during game play
which are accessed thousands of times.  Caching these values makes the
game simulations about 2 times faster.
2020-12-24 10:43:39 -08:00
Tom Stellard f23d0a733a Remove use of deprecated glib type 2020-12-24 10:43:39 -08:00
Tom Stellard 9aa4099375 Fix unused variable from d195a59c80 2020-12-24 10:43:39 -08:00
Tom Stellard 5dc2c6ab46 Optimize team_get_fixture()
When searching for a team's next fixture, only search in leagues that the team
is actually in.  This improves performance a lot in countries with many leagues.
I see about a 7x speed up simulating the first 6 weeks of English leagues using
billys_boots 2019/2020 definitions from the forums.
2020-12-24 10:43:39 -08:00
Tom Stellard c1bc51a33b Simplify team_get_fixture() with an early continue 2020-12-24 10:43:39 -08:00
Tom Stellard d2a82fe888 Simplify code in team_get_fixture() to make it more readable 2020-12-24 10:43:39 -08:00
Tom Stellard 863fefd371 Make team_get_fixture() return const pointer 2020-12-24 10:43:39 -08:00
Tom Stellard bc506ef7c4 Make fixture_get() return const pointer 2020-12-24 10:43:39 -08:00
Tom Stellard 3b54d38578 Add --random-seed option
This flag can be used to set the seed for the random number generator.  This
is mainly meant for testing.
2020-12-24 10:43:39 -08:00
Tom Stellard 981cd51ef2 Validate country definitions on startup
Try to load all the country definitions on startup to ensure that they
are all valid.  Invalid XML can cause bygfoot to abort when simulating
matches and make users lose any unsaved progress.
2020-12-24 10:43:39 -08:00
Tom Stellard bfa6430bef Speed up game simulations by using g_datalist_id_get_data()
g_datalist_id_get_data() performs much better than g_datalist_get_data()
because it uses a hash based lookup instead of string compare.
I tested this by starting a game with an English Premier league team
and then simulating to week 6.  According to perf's cycle counts, this
patch makes this test case about 10 times faster.

There is still room for improvement.  We currently re-compute the GQuark
value for every lookup, but we could pre-compute the GQuark once for each
option key and then use that value when looking up the data.
2020-12-24 10:43:39 -08:00
Tom Stellard 315689583c zip: Remove usage of OF macros
These are only needed to support very old K&R C compilers[1].  gentoo has also
renamed these macros in its zlib package[2] which means this code was failing
to compile there.

[1] https://trac.osgeo.org/gdal/ticket/6220
[2] https://bugs.gentoo.org/383179
2020-12-24 10:43:39 -08:00
gunnar_g bde900dfdd Fixed bug request 3257236, always show news after a match 2012-02-07 11:56:55 +00:00
gunnar_g 8bafb64b70 Add the boost and style to the default team (ticket 2778645 ) 2012-02-02 15:40:22 +00:00
gunnar_g 974b4b357e Added G_MODULE_EXPORT to all callbacks methods. Otherwise they are not useable on windows 2011-08-29 11:17:53 +00:00
gunnar_g b48c14cc9a Continue on windres integration for windows 2011-08-05 11:57:21 +00:00
gunnar_g 0d42794ca2 windres configuration in the makefile. Hope this works on windows 2011-08-05 10:52:29 +00:00
gunnar_g c209f635c0 link the zip sources in directly without making a library. Let\'s hope windows knows how to cope with this 2011-07-29 11:17:24 +00:00
gunnar_g 4e7d92c61c Correctly call pkg-config to set gmodule CFLAGS 2011-07-26 11:44:14 +00:00
gunnar_g 89bba29615 delete autosave files with the same autosave number 2011-05-19 21:44:05 +00:00
gunnar_g cd4a2283d7 the default team was restored even if no match was played 2011-05-19 19:26:11 +00:00
gunnar_g 3b04f321d1 Don't try to free up memory when you use that data later to tell the user why the application forcibly quits 2011-05-17 12:19:50 +00:00
gunnar_g a9a928c5b9 fixed the automatic storing of the default team 2011-05-04 20:29:44 +00:00
gunnar_g 439a047ba6 Fixed memorable matches. They were broken after the zipfile changes 2011-05-04 10:45:32 +00:00
gunnar_g 58de9d0540 remove unused form item 2011-02-19 22:12:15 +00:00
gunnar_g 1645c4a264 Put the zip debug messages in between ifdef debug 2011-02-19 21:55:47 +00:00
gunnar_g 8d9b2e203a The new zip file implementation is ready, still need to put the messages returned by it in debug mode 2011-02-16 20:57:48 +00:00
gunnar_g 72910b1f55 switching to a zip library instead of an executed command - there are still issues 2011-01-22 21:30:21 +00:00
gunnar_g a00650e7fe Show the flags also for non international competitions 2011-01-21 12:09:57 +00:00
gunnar_g 4d8cdd4869 Switched to internal zipping/unzipping routines. 2010-11-26 12:22:35 +00:00
gunnar_g e7f38d6064 Switched to internal zipping/unzipping routines. 2010-11-26 12:16:10 +00:00
gunnar_g 3e447a0b31 Fixed the makefile so that english news and lg_commentary are updated 2010-10-28 10:39:51 +00:00
gunnar_g e732612baf Pushed xml translations to the po files 2010-10-27 20:25:13 +00:00
gunnar_g 8f0e6bcd96 Pushed xml translations to the po files 2010-10-27 19:44:27 +00:00
gunnar_g c3bbc78a4c Fixed the memorable match seg fault, bug 2857927 2010-04-12 11:28:32 +00:00
gunnar_g e52918edf2 Removed the glade refence (this code is not generated anymore) 2010-04-02 10:51:14 +00:00
gunnar_g 5d13f20683 Now with the format really changed 2010-04-02 10:49:15 +00:00
gunnar_g e5121fe3c3 Updated the formatting 2010-04-02 10:45:33 +00:00
gunnar_g ebad6522ca Remove the interface header file as it doesn't exist anymore 2010-04-02 10:41:19 +00:00
gunnar_g cad59262ce Fix for tracker id 2942033: Spectator Bugs in Multiplayer-Games
Patch by rookie86
2010-01-29 07:38:11 +00:00