Transmit and set local color array. Fixes picking of team color bug.
Transmit player map position & handle picking of players correctly. fixes ticket:1075 Enable/disable AIs on maps. fixes ticket:1065 (r8410) git-svn-id: https://warzone2100.svn.sourceforge.net/svnroot/warzone2100/trunk@8524 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
7620fcbdad
commit
a72cb7295a
|
@ -1416,6 +1416,7 @@ void NETBroadcastPlayerInfo(uint32_t index)
|
||||||
NETstring(NetPlay.players[index].name, sizeof(NetPlay.players[index].name));
|
NETstring(NetPlay.players[index].name, sizeof(NetPlay.players[index].name));
|
||||||
NETuint32_t(&NetPlay.players[index].heartattacktime);
|
NETuint32_t(&NetPlay.players[index].heartattacktime);
|
||||||
NETint32_t(&NetPlay.players[index].colour);
|
NETint32_t(&NetPlay.players[index].colour);
|
||||||
|
NETint32_t(&NetPlay.players[index].position);
|
||||||
NETint32_t(&NetPlay.players[index].team);
|
NETint32_t(&NetPlay.players[index].team);
|
||||||
NETbool(&NetPlay.players[index].ready);
|
NETbool(&NetPlay.players[index].ready);
|
||||||
NETuint32_t(&NetPlay.hostPlayer);
|
NETuint32_t(&NetPlay.hostPlayer);
|
||||||
|
@ -2304,11 +2305,14 @@ static BOOL NETprocessSystemMessage(void)
|
||||||
NETstring(NetPlay.players[index].name, sizeof(NetPlay.players[index].name));
|
NETstring(NetPlay.players[index].name, sizeof(NetPlay.players[index].name));
|
||||||
NETuint32_t(&NetPlay.players[index].heartattacktime);
|
NETuint32_t(&NetPlay.players[index].heartattacktime);
|
||||||
NETint32_t(&NetPlay.players[index].colour);
|
NETint32_t(&NetPlay.players[index].colour);
|
||||||
|
NETint32_t(&NetPlay.players[index].position);
|
||||||
NETint32_t(&NetPlay.players[index].team);
|
NETint32_t(&NetPlay.players[index].team);
|
||||||
NETbool(&NetPlay.players[index].ready);
|
NETbool(&NetPlay.players[index].ready);
|
||||||
NETuint32_t(&NetPlay.hostPlayer);
|
NETuint32_t(&NetPlay.hostPlayer);
|
||||||
NETend();
|
NETend();
|
||||||
debug(LOG_NET, "Receiving MSG_PLAYER_INFO for player %u (%s)", (unsigned int)index, NetPlay.players[index].allocated ? "human" : "AI");
|
debug(LOG_NET, "Receiving MSG_PLAYER_INFO for player %u (%s)", (unsigned int)index, NetPlay.players[index].allocated ? "human" : "AI");
|
||||||
|
// update the color to the local array
|
||||||
|
setPlayerColour(index, NetPlay.players[index].colour);
|
||||||
|
|
||||||
// If we're the game host make sure to send the updated
|
// If we're the game host make sure to send the updated
|
||||||
// data to all other clients as well.
|
// data to all other clients as well.
|
||||||
|
|
|
@ -1464,7 +1464,7 @@ static void addColourChooser(UDWORD player)
|
||||||
iV_GetImageHeight(FrontImages,IMAGE_WEE_GUY), //h
|
iV_GetImageHeight(FrontImages,IMAGE_WEE_GUY), //h
|
||||||
"Player number", IMAGE_WEE_GUY, IMAGE_WEE_GUY, 10 + i);
|
"Player number", IMAGE_WEE_GUY, IMAGE_WEE_GUY, 10 + i);
|
||||||
|
|
||||||
if(isHumanPlayer(i) && i!=selectedPlayer)
|
if(isHumanPlayer(NetPlay.players[i].position) && i!=selectedPlayer )
|
||||||
{
|
{
|
||||||
widgSetButtonState(psWScreen,MULTIOP_PLAYCHOOSER+i ,WBUT_DISABLE);
|
widgSetButtonState(psWScreen,MULTIOP_PLAYCHOOSER+i ,WBUT_DISABLE);
|
||||||
}
|
}
|
||||||
|
@ -1611,12 +1611,14 @@ static BOOL changeColour(UBYTE player, UBYTE col)
|
||||||
|
|
||||||
for (i = 0; i < MAX_PLAYERS; i++)
|
for (i = 0; i < MAX_PLAYERS; i++)
|
||||||
{
|
{
|
||||||
if (NetPlay.players[i].colour == col)
|
if (getPlayerColour(i) == col)
|
||||||
{
|
{
|
||||||
debug(LOG_NET, "Swapping colours between players %d(%d) and %d(%d)",
|
debug(LOG_NET, "Swapping colours between players %d(%d) and %d(%d)",
|
||||||
player, getPlayerColour(player), i, getPlayerColour(i));
|
player, getPlayerColour(player), i, getPlayerColour(i));
|
||||||
setPlayerColour(i, getPlayerColour(player));
|
setPlayerColour(i, getPlayerColour(player));
|
||||||
|
NetPlay.players[i].colour = getPlayerColour(player);
|
||||||
setPlayerColour(player, col);
|
setPlayerColour(player, col);
|
||||||
|
NetPlay.players[player].colour = col;
|
||||||
NETBroadcastPlayerInfo(player);
|
NETBroadcastPlayerInfo(player);
|
||||||
NETBroadcastPlayerInfo(i);
|
NETBroadcastPlayerInfo(i);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1651,6 +1653,7 @@ static BOOL SendPositionRequest(UBYTE player, UBYTE position)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
debug(LOG_NET, "Requesting the host to change our position. From %d to %d", player, position);
|
||||||
// clients tell the host which position they want
|
// clients tell the host which position they want
|
||||||
NETbeginEncode(NET_POSITIONREQUEST, NET_HOST_ONLY);
|
NETbeginEncode(NET_POSITIONREQUEST, NET_HOST_ONLY);
|
||||||
NETuint8_t(&player);
|
NETuint8_t(&player);
|
||||||
|
@ -1695,14 +1698,14 @@ BOOL recvPositionRequest()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NETbeginDecode(NET_COLOURREQUEST);
|
NETbeginDecode(NET_POSITIONREQUEST);
|
||||||
NETuint8_t(&player);
|
NETuint8_t(&player);
|
||||||
NETuint8_t(&position);
|
NETuint8_t(&position);
|
||||||
NETend();
|
NETend();
|
||||||
|
debug(LOG_NET, "Host received position request from player %d to %d", player, position);
|
||||||
if (player > MAX_PLAYERS || position > MAX_PLAYERS)
|
if (player > MAX_PLAYERS || position > MAX_PLAYERS)
|
||||||
{
|
{
|
||||||
debug(LOG_ERROR, "Invalid NET_COLOURREQUEST from player %d: Tried to change player %d to %d",
|
debug(LOG_ERROR, "Invalid NET_POSITIONREQUEST from player %d: Tried to change player %d to %d",
|
||||||
NETgetSource(), (int)player, (int)position);
|
NETgetSource(), (int)player, (int)position);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1954,8 +1957,13 @@ UDWORD addPlayerBox(BOOL players)
|
||||||
sFormInit.pDisplay = displayPlayer;
|
sFormInit.pDisplay = displayPlayer;
|
||||||
sFormInit.UserData = i;
|
sFormInit.UserData = i;
|
||||||
widgAddForm(psWScreen, &sFormInit);
|
widgAddForm(psWScreen, &sFormInit);
|
||||||
addFESlider(MULTIOP_SKSLIDE+i,sFormInit.id, 43,9, DIFF_SLIDER_STOPS,
|
#ifdef DEBUG
|
||||||
|
addFESlider(MULTIOP_SKSLIDE+i,sFormInit.id, 63,9, DIFF_SLIDER_STOPS,
|
||||||
(game.skDiff[i] <= DIFF_SLIDER_STOPS ? game.skDiff[i] : DIFF_SLIDER_STOPS / 2)); //set to 50% (value of UBYTE_MAX == human player)
|
(game.skDiff[i] <= DIFF_SLIDER_STOPS ? game.skDiff[i] : DIFF_SLIDER_STOPS / 2)); //set to 50% (value of UBYTE_MAX == human player)
|
||||||
|
#else
|
||||||
|
addFESlider(MULTIOP_SKSLIDE+i,sFormInit.id, 43,9, DIFF_SLIDER_STOPS,
|
||||||
|
(game.skDiff[i] <= DIFF_SLIDER_STOPS ? game.skDiff[i] : DIFF_SLIDER_STOPS / 2));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2720,6 +2728,10 @@ void frontendMultiMessages(void)
|
||||||
recvColourRequest();
|
recvColourRequest();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case NET_POSITIONREQUEST:
|
||||||
|
recvPositionRequest();
|
||||||
|
break;
|
||||||
|
|
||||||
case NET_TEAMREQUEST:
|
case NET_TEAMREQUEST:
|
||||||
recvTeamRequest();
|
recvTeamRequest();
|
||||||
break;
|
break;
|
||||||
|
@ -3021,7 +3033,8 @@ BOOL startMultiOptions(BOOL bReenter)
|
||||||
teamChooserUp = -1;
|
teamChooserUp = -1;
|
||||||
for(i=0;i<MAX_PLAYERS;i++)
|
for(i=0;i<MAX_PLAYERS;i++)
|
||||||
{
|
{
|
||||||
game.skDiff[i] = (DIFF_SLIDER_STOPS / 2);
|
game.skDiff[i] = (DIFF_SLIDER_STOPS / 2); // reset AI (turn it on again)
|
||||||
|
setPlayerColour(i,i); //reset all colors as well
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!NetPlay.bComms) // force skirmish if no comms.
|
if(!NetPlay.bComms) // force skirmish if no comms.
|
||||||
|
@ -3473,8 +3486,76 @@ void displayPlayer(WIDGET *psWidget, UDWORD xOffset, UDWORD yOffset, PIELIGHT *p
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#ifdef DEBUG
|
||||||
|
// This is used for debugging right now, don't touch!
|
||||||
|
// yes, I know it looks like crap, but the sliders are a fixed size.
|
||||||
|
|
||||||
|
x=x+33;
|
||||||
|
// player number
|
||||||
|
switch (NetPlay.players[j].position)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_0,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_1,x+5,y+29);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_2,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_3,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_4,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_5,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_6,x+4,y+29);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
iV_DrawImage(IntImages,IMAGE_GN_7,x+4,y+29);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(getPlayerColour(j)) //flag icon
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER0,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER1,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER2,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER3,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER4,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER5,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER6,x+7,y+9);
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
iV_DrawImage(FrontImages,IMAGE_PLAYER7,x+7,y+9);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
|
||||||
//bluboxes.
|
//bluboxes.
|
||||||
drawBlueBox(x,y,psWidget->width,psWidget->height); // right
|
drawBlueBox(x,y,psWidget->width,psWidget->height); // right
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -676,11 +676,16 @@ static BOOL campInit(void)
|
||||||
// Remove baba player for skirmish
|
// Remove baba player for skirmish
|
||||||
if (!game.scavengers)
|
if (!game.scavengers)
|
||||||
{
|
{
|
||||||
for (player = game.maxPlayers; player < MAX_PLAYERS; player++)
|
for (player = 1; player < MAX_PLAYERS; player++)
|
||||||
{
|
{
|
||||||
|
// we want to remove disabled AI & all the other players that don't belong
|
||||||
|
if (game.skDiff[player] == 0 || player >= game.maxPlayers)
|
||||||
|
{
|
||||||
clearPlayer(player, true, false);
|
clearPlayer(player, true, false);
|
||||||
|
debug(LOG_NET, "removing disabled AI (%d) from map.", player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (NetPlay.isHost) // add oil drums
|
if (NetPlay.isHost) // add oil drums
|
||||||
{
|
{
|
||||||
|
|
|
@ -731,6 +731,7 @@ BOOL recvMessage(void)
|
||||||
ingame.JoiningInProgress[player_id] = false;
|
ingame.JoiningInProgress[player_id] = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// FIXME: the next 4 cases might not belong here --check (we got two loops for this)
|
||||||
case NET_COLOURREQUEST:
|
case NET_COLOURREQUEST:
|
||||||
recvColourRequest();
|
recvColourRequest();
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue