Commit Graph

1751 Commits

Author SHA1 Message Date
Tom Stellard 5373da9c30 Refactor job_change_country() 2021-07-27 14:41:40 -04:00
Tom Stellard d84b8683ed Refactor fixture_remove_rrs() 2021-07-27 14:41:40 -04:00
Tom Stellard 05ac1ccb7c Refactor fixture_write_league_fixtures() 2021-07-27 14:41:40 -04:00
Tom Stellard 8ea51d65a1 Refactor cup_load_choose_team_from_cup() 2021-07-27 14:41:40 -04:00
Tom Stellard 273ca50688 json: Add command for getting the country's leagues 2021-07-27 14:41:40 -04:00
Tom Stellard 8df2c6b98c Fix Sweden league3 definitions
league3a and league3b have different promotion cups so the loser should
not have the option of going to the other league.
2021-07-27 14:41:40 -04:00
Tom Stellard 67f5bbb212 Make Liechtenstein choose_team in the Europa Cup optional
There is no alternative to the cup winner since there is no national
league.
2021-07-27 14:41:40 -04:00
Tom Stellard e5b5b3b757 Fix Switzerland definitions
Promotion games should specify a loser_sid if the losers just return to
their current leagues.  Also, specify the correct of teams that advance.
2021-07-27 14:41:40 -04:00
Tom Stellard 0fcf53e82b Fix Portugal definitions
Promotion games should specify a loser_sid if the losers just return to
their current leagues.
2021-07-27 14:41:40 -04:00
Tom Stellard 6b4645a612 Fix Germany definitions
Promotion games should specify a loser_sid if the losers just return to
their current leagues.
2021-07-27 14:41:40 -04:00
Tom Stellard 6fe3fc306e Fix slovenia1 choose_team in cup_uefa_el definition
We need to handle the case when the 2nd place slovenia1 team qualifies
for the champions league and the 3rd (or even 4th if the 3rd also
qualifies) place team needs to take its spot in uefa_el.
2021-07-27 14:41:40 -04:00
Tom Stellard 4d4d73caa0 Allow optional tag to be used when selecting teams from cups
This fixes a segfault caused by the uefa_el definitions when there
aren't enough teams in uefa_cl to fill all the spots in the choose_team
definition.
2021-07-27 14:41:40 -04:00
Tom Stellard b126786553 Add helper cup_choose_team_compute_{start,end}_idx helper functions 2021-07-27 14:41:40 -04:00
Tom Stellard 87b5a77ab2 Initialize current_interest after setting the random seed
The way when we run benchmark.sh --verify, the current_interest value
will always be the same.
2021-07-27 14:41:40 -04:00
Tom Stellard 98b76cd999 workflows: Stop building/testing on Ubuntu 16.04
General support for this release has ended.
2021-07-27 14:41:40 -04:00
Tom Stellard bde97fd39a workflows: Build packages on more operating systems
Also create a release and upload packages when there is a new tag.
2021-06-18 00:08:42 -04:00
Tom Stellard b44ad7f168 package.sh: Allow custom tar names 2021-06-18 00:08:42 -04:00
Tom Stellard 78e774cd98 cmake: Compile with -fcommon
Newer versions of gcc and clang default to fno-common and
our global variable usage requires -fcommon.
2021-06-18 00:08:42 -04:00
Tom Stellard 2bd484d69c package.sh: Don't pass -B option to cmake
Older versions of cmake don't support this.
2021-06-18 00:08:42 -04:00
Tom Stellard 8b38034e15 cmake: Pass RUNTIME DIRECTORY to bygfoot install target
This is required by some versions of cmake.
2021-06-18 00:08:42 -04:00
Tom Stellard c62cbe01c6 Remove usage of g_ptr_array_foreach()
This function does not appear to provide any benefits compared to a
standard loop, and it may prevent some compiler optimizations, like
inlining.
2021-04-11 08:21:23 -07:00
Tom Stellard 5c3e3522c0 json: Fix bug serializing team pointers 2021-04-11 08:21:23 -07:00
Tom Stellard 34defb6642 Use teams from country_list for international jobs
This way we don't need to generate teams sepearately for jobs.
2021-04-03 15:43:39 -07:00
Tom Stellard 804185f354 Parse strategy conditions once when loading them from xml
This way strategy_live_game_check() only needs to evaluate the condition
and does not need to reparse it over and over again.

This reduces the number of instructions reported by
./test/benchmark.sh --benchmark by ~35%.
2021-03-30 10:20:11 -04:00
Tom Stellard 72549415cc Refactor strategy_live_game_check() 2021-03-30 10:20:11 -04:00
Tom Stellard ff343e94d3 Try to avoid calling team_get_fixture() from player_is_banned()
team_get_fixture() is expensive and we can avoid this call in the
majority of cases.

This reduces the number of instructions reported by
./test/benchmark.sh --benchmark by ~40%.
2021-03-27 09:23:22 -04:00
Tom Stellard 879190e971 Fix item size for Player cards array 2021-03-27 09:23:22 -04:00
Tom Stellard 068308636e test: Add benchmark.sh script for collecting benchmark data 2021-03-26 22:47:26 -04:00
Tom Stellard 8a701be6a1 Complete json serialization support for all Bygfoot objects 2021-03-26 22:47:26 -04:00
Tom Stellard d4de1a66e1 workflows: Disable for pushes to non-default branches 2021-03-20 08:31:47 -07:00
Tom Stellard 34db509a84 workflows: Link with correct zlib when building windows packages 2021-03-05 21:11:14 -08:00
Tom Stellard dc595ced26 workflows: Run some simple tests 2021-03-05 23:38:28 -05:00
Tom Stellard 42dd94ea30 workflows: Fix Windows build 2021-03-05 23:38:28 -05:00
Tom Stellard 080dcfe308 CMake: Copy support files into build directory
This makes it possible to run bygfoot from the build directory.
2021-03-05 23:38:28 -05:00
Tom Stellard 95a1507f6a Import all Europe definitions from forums
This includes all teams and also the uefa cup definitions.  All team
names have been replaced with bygfoot friendly names.
2021-03-05 23:38:28 -05:00
Tom Stellard 0f25c31ee5 Fix bug in query_cup_begins()
The function incorrectly assumed that cups where all the scheduled games
had been played wre complete, and did not take into account the fact
that games for later rounds may not have been scheduled yet.
2021-03-05 23:38:28 -05:00
Tom Stellard 4ad92b9884 Avoid infinite loop in job_pick_team_from_country()
This function was looping forever if all the national teams were added
to the job list.
2021-03-05 23:38:28 -05:00
Tom Stellard fdc15fdf8a Add optional tag 2021-03-05 23:38:28 -05:00
Tom Stellard a3a9e1bacc Add cup sid to debug printfs 2021-03-05 23:38:28 -05:00
Tom Stellard 38aa82d99b Iterate over cup rounds in reverse order when selecting teams
Some cups allow teams to qualify in multiple ways and we want to
always select teams into the highest round possible.
2021-03-05 23:38:28 -05:00
Tom Stellard be9b591c0e Add alternatives tag to choose_team
This allows you to specify an alternative choose_team in the case the
first choose_team does not match any teams.  This can happen if a team
qualifies for another cup in the same cup group.  You may list an
unlimited number of alternatives with this new tag.  Here is an example of
how to use it:

<choose_team>
  <choose_team_sid>faroe_islands_cup</choose_team_sid>
  <number_of_teams>1</number_of_teams>
  <start_idx>1</start_idx>
  <end_idx>1</end_idx>
  <alternatives>
    <choose_team>
      <choose_team_sid>faroe_islands1</choose_team_sid>
      <number_of_teams>1</number_of_teams>
      <start_idx>1</start_idx>
      <end_idx>1</end_idx>
    </choose_team>
  </alternatives>
</choose_team>

This example chooses the winner of the faroe_islands_cup, but if that
team is not eligible for the cup, then it will choose the winner of the
faroe_islands1 league.
2021-03-05 23:38:28 -05:00
Tom Stellard 8a3100a28c Add support for specifying cups in choose_team_sid tag for generated teams
This makes it possible to include national cup winners in international
cups.
2021-03-05 23:38:28 -05:00
Tom Stellard 347d74a3c4 Load all league and team names at the beginning of the game
This way we don't have to reload the country xml definitions every time
we have to generate a new team.
2021-03-05 23:38:28 -05:00
Tom Stellard 37b9d8bf46 Refactor cup_reset() 2021-03-05 23:38:28 -05:00
Tom Stellard f56e1b64be Refactor cup_load_choose_team_generate() 2021-03-05 23:38:28 -05:00
Tom Stellard 4248c08b7a Allow the user's country's league sids in choose_team tags
This allows for consistent and accurate international cup definitions,
because the draws will be the same no matter what the country a user
has choosen.

So now if a user is playing Faroe Islands, for example, a choose_team with an
sid of faroe_islands1, will select a team from the Faroe Islands.
Previously, this sid would have been ignored and the only way for a
user team to play in an international cup was if it used the special
LEAGUE* or CUP* sid.

As a result of this change, the 'generate' property of CupChooseTeam is
now infered based on the sid, so the generated tag no longer has an
effect in the definition files.
2021-03-05 23:38:28 -05:00
Tom Stellard 306482d403 Refactor cup_get_team_pointers() 2021-03-05 23:38:28 -05:00
Tom Stellard 013df8dd93 Add json interface
This adds an initial version of a json interface to bygfoot.  This
is still in development so the interface may change in the future.  This
interface can be used for writing tests or for communication between a
client and server.

To use the interface, you can pass a json file with commands to bygfoot
using the --json option.
2021-03-05 23:38:28 -05:00
Tom Stellard aa5d19b863 Move country file validation out of main_init()
We only need to do this validation on program startup and main_init()
may be called multiple times (e.g. if someone starts multiple new games
without exiting)
2021-03-05 23:38:28 -05:00
Tom Stellard b76f817c93 Add Bygfoot* parameter to start_week* functions
In the future, this structure will hold the bygfoot global state.
2021-03-05 23:38:28 -05:00