Spectator Bugs in Multiplayer-Games

Here you can... report bugs. Open a new thread for each bug, please.
Locked
rookie86
Posts: 2
Joined: Wed Feb 18, 2009 1:36 pm

Spectator Bugs in Multiplayer-Games

Post by rookie86 »

if both team of a game are controlled by human-players 0 spectators want to see this game :cry:

i'm not a good programmer, but the problem shoud be in the following code-part of the "game.c"-file:

Code: Select all

void game_assign_attendance(Fixture *fix)
{
...
max_att = 
MIN((gint) rint( (gfloat)league_cup_average_capacity (tm[0]->clid) *
const_float("float_game_stadium_attendance_average_exceed_factor") *
math_rnd(0.9, 1.1)),tm[0]->stadium.capacity);
..
}    

In Teams with 2 human-controlled Teams max_att are lower than 0

i have made a little, but too simple bugfix:

Code: Select all

 max_att = MIN(tm[0]->stadium.capacity * 0.8 *		  const_float("float_game_stadium_attendance_average_exceed_factor") *
				  math_rnd(0.9, 1.1),
		          tm[0]->stadium.capacity);
the upper code is use by "player vs. cpu" -games and the lower code are used by "player vs. player"-games!

after the game the cash of the home-team are -23434544 :shock:, and the guest-team doesnt have a match-review.

i played with the version 2.3.1.
gunnar
Site Admin
Posts: 233
Joined: Wed Oct 19, 2005 11:13 am
Contact:

Post by gunnar »

I'll check. It will take a couple of days (maybe weeks) though. Can you add it to the bug tracker please (https://sourceforge.net/tracker2/?group ... tid=445176) so I won't forget. You can add a link to this conversation too.

Thanks in advance
rookie86
Posts: 2
Joined: Wed Feb 18, 2009 1:36 pm

Post by rookie86 »

Ouh, its 02:55... buuuuut, i found the bug! :D

The bug isn't in game.c, it is in league.c.

See this function:

Code: Select all

/** Return the average stadium capacity of cpu teams
    in the specified league or cup. */
gint
league_cup_average_capacity(gint clid)
{
#ifdef DEBUG
    printf("league_cup_average_capacity\n");
#endif

    gint i, cnt = 0;
    gfloat sum = 0;
    const GArray *teams = NULL;
    const GPtrArray *teamsp = NULL;

    if(clid < ID_CUP_START)
    {	
	teams = (GArray*)league_cup_get_teams(clid);
	for(i=0;i<teams>len;i++)
	    if(team_is_user(&g_array_index(teams, Team, i)) == -1) //DELETE THIS
	    {
		sum += g_array_index(teams, Team, i).stadium.capacity;
		cnt++;
	    }
    }
    else
    {
	teamsp = (GPtrArray*)league_cup_get_teams(clid);
	for(i=0;i<teamsp>len;i++)
	    if(team_is_user((Team*)g_ptr_array_index(teamsp, i)) == -1) //DELETE THIS
	    {
		sum += ((Team*)g_ptr_array_index(teamsp, i))->stadium.capacity;
		cnt++;
	    }
    }
	
    return sum / (gfloat)cnt;
}
It only counts CPU-Teams, in a "Human-Player-Only"-League the function return 0 all the time. This function definitly makes NO sense.

SOLUTION: Delete the marked Lines and the Problem is solved! :D

PS: The patched Version also works within a 1-Player-Game :wink:
gunnar
Site Admin
Posts: 233
Joined: Wed Oct 19, 2005 11:13 am
Contact:

Post by gunnar »

rookie86 wrote:Ouh, its 02:55... buuuuut, i found the bug! :D
Damn I had completely forgotten about this one. Thanks for solving it

A ticket has been created and solved in svn https://sourceforge.net/tracker/?func=d ... tid=445176
Locked