Distribute players based on team instead of PrefPosition

ipv6
Lukas Werling 2017-01-01 22:51:56 +01:00
parent e015cdef8d
commit 088fc450d9
3 changed files with 8 additions and 3 deletions

View File

@ -60,7 +60,6 @@ void C4PlayerInfoCore::Default(C4RankSystem *pRanks)
PrefColorDw=0xff;
PrefColor2Dw=0;
OldPrefControl=0;
PrefPosition=0;
PrefMouse=1;
OldPrefControlStyle = 0;
OldPrefAutoContextMenu = 0;
@ -162,7 +161,6 @@ void C4PlayerInfoCore::CompileFunc(StdCompiler *pComp)
pComp->Value(mkNamingAdapt(PrefColor, "Color", 0));
pComp->Value(mkNamingAdapt(PrefColorDw, "ColorDw", 0xffu));
pComp->Value(mkNamingAdapt(PrefColor2Dw, "AlternateColorDw", 0u));
pComp->Value(mkNamingAdapt(PrefPosition, "Position", 0));
pComp->Value(mkNamingAdapt(PrefMouse, "Mouse", 1));
pComp->Value(mkNamingAdapt(OldPrefControl, "Control", 1));
pComp->Value(mkNamingAdapt(OldPrefControlStyle, "AutoStopControl", 0));

View File

@ -98,7 +98,6 @@ public:
int32_t PrefMouse;
int32_t PrefColor;
uint32_t PrefColorDw, PrefColor2Dw;
int32_t PrefPosition;
int32_t PrefClonkSkin;
// Old control method - loaded for backwards compatilibity if PrefControl is unassigned
// and stored back so you can use the same player file for CR and OC

View File

@ -641,6 +641,14 @@ bool C4Player::ScenarioInit()
if (Game.StartupPlayerCount>=2)
{
int32_t iMaxPos=Game.StartupPlayerCount;
// Try to initialize PrefPosition using teams. This should put players of a team next to each other.
int PrefPosition = 0;
C4PlayerInfo *plr;
for (int i = 0; (plr = Game.PlayerInfos.GetPlayerInfoByIndex(i)) != nullptr; i++)
{
if (plr->GetTeam() < Team)
PrefPosition++;
}
// Map preferred position to available positions
int32_t iStartPos=Clamp(PrefPosition*iMaxPos/C4P_MaxPosition,0,iMaxPos-1);
int32_t iPosition=iStartPos;