Fixed potential networking bugs

This commit is contained in:
mathusummut
2018-12-13 14:45:58 +01:00
parent 07930d85ab
commit b4feeecd4a
7 changed files with 10 additions and 26 deletions

View File

@@ -1163,10 +1163,10 @@ namespace Game {
ultraResourceAttack = (aiInterface->getControlType() == ctCpuUltra)
&& random.randRange(0, 2) == 1;
bool
megaResourceAttack = (aiInterface->getControlType() == ctCpuZeta)
zetaResourceAttack = (aiInterface->getControlType() == ctCpuZeta)
&& random.randRange(0, 1) == 1;
if (megaResourceAttack || ultraResourceAttack) {
if (zetaResourceAttack || ultraResourceAttack) {
Map *
map = aiInterface->getMap();

View File

@@ -1347,7 +1347,7 @@ namespace Game {
// world->getFaction(factionIndex)->getPersonalityType(),world->getFaction(factionIndex)->getIndex(),world->getFaction(factionIndex)->getControlType(),settings->getNetworkPlayerStatuses(factionIndex));
//printf("#2 nctPlayerStatusChange factionIndex = %d playerStatus = %d\n",factionIndex,playerStatus);
settings->setFactionControl(factionIndex, ctCpuUltra);
settings->setFactionControl(factionIndex, ctCpuZeta);
settings->setResourceMultiplierIndex(factionIndex,
settings->
getFallbackCpuMultiplier
@@ -1356,7 +1356,7 @@ namespace Game {
//game->get
Faction *
faction = this->world->getFaction(factionIndex);
faction->setControlType(ctCpuUltra);
faction->setControlType(ctCpuZeta);
if (!world->getGame()->getGameOver()
&& !this->world->getGame()->

View File

@@ -698,7 +698,7 @@ namespace Game {
"\nx " + floatToStr(stats.getResourceMultiplier(i), 1);
} else if (stats.getPlayerLeftBeforeEnd(i) == true) {
controlString +=
"\n" + lang.getString("CpuZeta") + "\nx " +
"\nx " +
floatToStr(stats.getResourceMultiplier(i), 1);
}

View File

@@ -1038,22 +1038,8 @@ namespace Game {
return 0;
}
bool Faction::getCpuControl(bool enableServerControlledAI,
bool isNetworkGame, NetworkRole role) const {
bool result = false;
if (enableServerControlledAI == false || isNetworkGame == false) {
result = (control == ctCpuEasy || control == ctCpu
|| control == ctCpuUltra || control == ctCpuZeta);
} else {
if (isNetworkGame == true) {
if (role == nrServer) {
result = (control == ctCpuEasy || control == ctCpu
|| control == ctCpuUltra || control == ctCpuZeta);
}
}
}
return result;
bool Faction::getCpuControl(bool enableServerControlledAI, bool isNetworkGame, NetworkRole role) const {
return getCpuControl();
}
bool Faction::getCpuControl() const {

View File

@@ -545,7 +545,7 @@ Please contact the ZetaGlest team for more info.";
char szBuf[8096] = "";
snprintf(szBuf, 8096,
"Invalid controller value specified in scenario: [%s] must be one of the following: closed, cpu-easy, cpu, cpu-ultra, cpu-zeta, human",
"Invalid controller value specified in scenario: [%s] must be one of the following: closed, cpu-easy, cpu, cpu-ultra, cpu-mega, human",
str.c_str());
throw std::runtime_error(szBuf);
}

View File

@@ -74,8 +74,6 @@ namespace Game {
private:
static const int maxResSearchRadius = 10;
static const int harvestDistance = 5;
static const int ultraResourceFactor = 3;
static const int megaResourceFactor = 4;
private:
const GameCamera *gameCamera;

View File

@@ -2118,7 +2118,7 @@ namespace Shared {
memset((char*) &bcaddr, 0, sizeof(bcaddr));
bcaddr.sin_family = AF_INET;
bcaddr.sin_addr.s_addr = htonl(INADDR_ANY);
bcaddr.sin_port = port;
bcaddr.sin_port = htons(port);
int val = 1;
#ifndef WIN32
@@ -2985,7 +2985,7 @@ namespace Shared {
if (SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork, "UDP Socket broadcast using IP [%s]\n", ipSubnetMaskList[idx].c_str());
bcLocal[idx].sin_addr.s_addr = inet_addr(ipSubnetMaskList[idx].c_str()); //htonl( INADDR_BROADCAST );
}
bcLocal[idx].sin_port = port; // We are letting the OS fill in the port number for the local machine.
bcLocal[idx].sin_port = htons(port); // We are letting the OS fill in the port number for the local machine.
#ifdef WIN32
bcfd[idx] = INVALID_SOCKET;
#else