Fix a bug in whosResponsible() which caused execution of AI scripts on a client instead of the host in some cases.

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4540 4a71c877-e1ca-e34f-864e-861f7616d084
master
Roman C 2008-04-07 17:31:57 +00:00
parent 72240c1958
commit 674db841fa
3 changed files with 12 additions and 23 deletions

View File

@ -97,9 +97,6 @@ typedef struct
unsigned int bytes;
} NETBUFSOCKET;
/// This is the hardcoded dpid (player ID) value for the hosting player.
#define HOST_DPID 1
#define PLAYER_HOST 1
// ////////////////////////////////////////////////////////////////////////

View File

@ -157,6 +157,9 @@ typedef struct {
uint32_t bHost; // true if we are hosting the session
} NETPLAY;
/// This is the hardcoded dpid (player ID) value for the hosting player.
#define HOST_DPID 1
// ////////////////////////////////////////////////////////////////////////
// variables

View File

@ -487,7 +487,6 @@ BOOL isHumanPlayer(UDWORD player)
UDWORD whosResponsible(UDWORD player)
{
UDWORD c;
SDWORD i;
c = ANYPLAYER;
if (isHumanPlayer(player))
@ -502,26 +501,16 @@ UDWORD whosResponsible(UDWORD player)
else
{
// crawl down array to find a responsible fellow,
for(i=player; i>=0; i--)
{
if(isHumanPlayer(i))
{
c = i;
}
}
// else crawl up to find a responsible fellow
if(c == ANYPLAYER)
{
for(i=player; i<MAX_PLAYERS; i++)
{
if(isHumanPlayer(i))
{
c = i;
}
}
}
SDWORD player;
// find the host using HOST_DPID
for(player=0;player <= MAX_PLAYERS && c == ANYPLAYER;player++)
{
if(player2dpid[player] == HOST_DPID)
{
c = player;
}
}
}
if(c == ANYPLAYER)
{