- bugfix for headless server's reporting of winning players and team.
- masterserver returns proper JSON header now
This commit is contained in:
parent
f6806bd1ea
commit
8414077d7a
|
@ -3489,11 +3489,13 @@ void Game::tryPauseToggle(bool pauseValue) {
|
|||
|
||||
void Game::startMarkCell() {
|
||||
int totalMarkedCellsForPlayer = 0;
|
||||
for(std::map<Vec2i, MarkedCell>::iterator iterMap = mapMarkedCellList.begin();
|
||||
iterMap != mapMarkedCellList.end(); ++iterMap) {
|
||||
MarkedCell &bm = iterMap->second;
|
||||
if(bm.getPlayerIndex() == world.getThisFaction()->getStartLocationIndex()) {
|
||||
totalMarkedCellsForPlayer++;
|
||||
if(world.getThisFaction() != NULL) {
|
||||
for(std::map<Vec2i, MarkedCell>::iterator iterMap = mapMarkedCellList.begin();
|
||||
iterMap != mapMarkedCellList.end(); ++iterMap) {
|
||||
MarkedCell &bm = iterMap->second;
|
||||
if(bm.getPlayerIndex() == world.getThisFaction()->getStartLocationIndex()) {
|
||||
totalMarkedCellsForPlayer++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5677,9 +5679,17 @@ void Game::checkWinnerStandard() {
|
|||
|
||||
// did some team win
|
||||
if(teamsAlive.size() <= 1) {
|
||||
if(this->masterserverMode == true) {
|
||||
printf("Game finished...\n");
|
||||
}
|
||||
for(int i=0; i< world.getFactionCount(); ++i) {
|
||||
if(i != world.getThisFactionIndex() && teamsAlive.find(world.getFaction(i)->getTeam()) != teamsAlive.end()) {
|
||||
Faction *faction = world.getFaction(i);
|
||||
|
||||
if(i != world.getThisFactionIndex() && teamsAlive.find(faction->getTeam()) != teamsAlive.end()) {
|
||||
world.getStats()->setVictorious(i);
|
||||
if(this->masterserverMode == true) {
|
||||
printf("Player: %s is on the winning team #: %d\n",this->gameSettings.getNetworkPlayerName(i).c_str(),faction->getTeam());
|
||||
}
|
||||
}
|
||||
}
|
||||
gameOver= true;
|
||||
|
@ -5811,13 +5821,18 @@ void Game::checkWinnerScripted() {
|
|||
// END
|
||||
}
|
||||
|
||||
scriptManager.onGameOver(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner());
|
||||
|
||||
if(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()){
|
||||
if(this->masterserverMode == true || world.getThisFaction()->getPersonalityType() == fpt_Observer) {
|
||||
showWinMessageBox();
|
||||
}
|
||||
else{
|
||||
showLoseMessageBox();
|
||||
else {
|
||||
scriptManager.onGameOver(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner());
|
||||
|
||||
if(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()){
|
||||
showWinMessageBox();
|
||||
}
|
||||
else{
|
||||
showLoseMessageBox();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5827,24 +5842,28 @@ bool Game::factionLostGame(int factionIndex) {
|
|||
}
|
||||
|
||||
bool Game::factionLostGame(const Faction *faction) {
|
||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
const UnitType *ut = faction->getUnit(i)->getType();
|
||||
if(ut->getCountInVictoryConditions() == ucvcNotSet) {
|
||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
if(faction != NULL) {
|
||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
const UnitType *ut = faction->getUnit(i)->getType();
|
||||
if(ut->getCountInVictoryConditions() == ucvcNotSet) {
|
||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(ut->getCountInVictoryConditions() == ucvcTrue) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if(ut->getCountInVictoryConditions() == ucvcTrue) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Game::hasBuilding(const Faction *faction) {
|
||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
return true;
|
||||
if(faction != NULL) {
|
||||
for(int i=0; i<faction->getUnitCount(); ++i) {
|
||||
if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -196,6 +196,10 @@ public:
|
|||
const string &getScenario() const {return scenario;}
|
||||
const string &getScenarioDir() const {return scenarioDir;}
|
||||
const string &getFactionTypeName(int factionIndex) const {
|
||||
if(factionIndex == -1) {
|
||||
static string HEADLESS_FACTION = "headless-server";
|
||||
return HEADLESS_FACTION;
|
||||
}
|
||||
if(factionIndex < 0 || factionIndex >= GameConstants::maxPlayers) {
|
||||
char szBuf[8096]="";
|
||||
snprintf(szBuf,8096,"In [%s] Invalid factionIndex = %d\n",__FUNCTION__,factionIndex);
|
||||
|
|
|
@ -264,7 +264,7 @@ string BattleEnd::getBattleEndMusic(bool won) {
|
|||
void BattleEnd::initBackgroundMusic() {
|
||||
string music = "";
|
||||
|
||||
if(stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getVictory(stats.getThisFactionIndex())){
|
||||
//header += lang.getString("Victory");
|
||||
music = getBattleEndMusic(true);
|
||||
|
@ -299,7 +299,7 @@ void BattleEnd::initBackgroundVideo() {
|
|||
string videoFile = "";
|
||||
string videoFileFallback = "";
|
||||
|
||||
if(stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getVictory(stats.getThisFactionIndex())){
|
||||
//header += lang.getString("Victory");
|
||||
|
||||
|
@ -703,7 +703,7 @@ void BattleEnd::render() {
|
|||
|
||||
string header = stats.getDescription() + " - ";
|
||||
|
||||
if(stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getThisFactionIndex() > 0 && stats.getTeam(stats.getThisFactionIndex()) != GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
if(stats.getVictory(stats.getThisFactionIndex())){
|
||||
header += lang.getString("Victory");
|
||||
}
|
||||
|
|
|
@ -1978,12 +1978,20 @@ void World::initFactionTypes(GameSettings *gs) {
|
|||
//create stats
|
||||
//printf("World gs->getThisFactionIndex() = %d\n",gs->getThisFactionIndex());
|
||||
|
||||
stats.init(gs->getFactionCount(), gs->getThisFactionIndex(), gs->getDescription(),gs->getTech());
|
||||
if(this->game->isMasterserverMode() == true) {
|
||||
this->thisFactionIndex = -1;
|
||||
}
|
||||
else {
|
||||
this->thisFactionIndex= gs->getThisFactionIndex();
|
||||
}
|
||||
|
||||
stats.init(gs->getFactionCount(), this->thisFactionIndex, gs->getDescription(),gs->getTech());
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
//create factions
|
||||
this->thisFactionIndex= gs->getThisFactionIndex();
|
||||
//printf("this->thisFactionIndex = %d\n",this->thisFactionIndex);
|
||||
|
||||
//factions.resize(gs->getFactionCount());
|
||||
for(int i= 0; i < gs->getFactionCount(); ++i){
|
||||
Faction *newFaction = new Faction();
|
||||
|
@ -2086,7 +2094,12 @@ void World::initFactionTypes(GameSettings *gs) {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(factions.empty() == false) {
|
||||
thisTeamIndex= getFaction(thisFactionIndex)->getTeam();
|
||||
if(this->game->isMasterserverMode() == true) {
|
||||
thisTeamIndex = -1;
|
||||
}
|
||||
else {
|
||||
thisTeamIndex = getFaction(thisFactionIndex)->getTeam();
|
||||
}
|
||||
}
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -2384,49 +2397,49 @@ ExploredCellsLookupItem World::exploreCells(const Vec2i &newPos, int sightRange,
|
|||
|
||||
bool World::showWorldForPlayer(int factionIndex, bool excludeFogOfWarCheck) const {
|
||||
bool ret = false;
|
||||
if(factionIndex >= 0) {
|
||||
if(excludeFogOfWarCheck == false &&
|
||||
fogOfWarSkillTypeValue == 0 && fogOfWarOverride == true) {
|
||||
ret = true;
|
||||
}
|
||||
else if(factionIndex == thisFactionIndex && game != NULL) {
|
||||
// Player is an Observer
|
||||
if(thisTeamIndex == GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
ret = true;
|
||||
}
|
||||
// Game over and not a network game
|
||||
else if(game->getGameOver() == true &&
|
||||
game->getGameSettings()->isNetworkGame() == false) {
|
||||
ret = true;
|
||||
}
|
||||
// Game is over but playing a Network game so check if we can
|
||||
// turn off fog of war?
|
||||
else if(game->getGameOver() == true &&
|
||||
game->getGameSettings()->isNetworkGame() == true &&
|
||||
game->getGameSettings()->getEnableObserverModeAtEndGame() == true) {
|
||||
ret = true;
|
||||
|
||||
if(excludeFogOfWarCheck == false &&
|
||||
fogOfWarSkillTypeValue == 0 && fogOfWarOverride == true) {
|
||||
ret = true;
|
||||
}
|
||||
else if(factionIndex == thisFactionIndex && game != NULL) {
|
||||
// Player is an Observer
|
||||
if(thisTeamIndex == GameConstants::maxPlayers -1 + fpt_Observer) {
|
||||
ret = true;
|
||||
}
|
||||
// Game over and not a network game
|
||||
else if(game->getGameOver() == true &&
|
||||
game->getGameSettings()->isNetworkGame() == false) {
|
||||
ret = true;
|
||||
}
|
||||
// Game is over but playing a Network game so check if we can
|
||||
// turn off fog of war?
|
||||
else if(game->getGameOver() == true &&
|
||||
game->getGameSettings()->isNetworkGame() == true &&
|
||||
game->getGameSettings()->getEnableObserverModeAtEndGame() == true) {
|
||||
ret = true;
|
||||
// If the faction is NOT on the winning team, don't let them see the map
|
||||
// until all mobile units are dead
|
||||
if(getStats()->getVictory(factionIndex) == false) {
|
||||
// If the player has at least 1 Unit alive that is mobile (can move)
|
||||
// then we cannot turn off fog of war
|
||||
|
||||
// If the faction is NOT on the winning team, don't let them see the map
|
||||
// until all mobile units are dead
|
||||
if(getStats()->getVictory(factionIndex) == false) {
|
||||
// If the player has at least 1 Unit alive that is mobile (can move)
|
||||
// then we cannot turn off fog of war
|
||||
|
||||
const Faction *faction = getFaction(factionIndex);
|
||||
// for(int i = 0; i < faction->getUnitCount(); ++i) {
|
||||
// Unit *unit = getFaction(factionIndex)->getUnit(i);
|
||||
// if(unit != NULL && unit->isAlive() && unit->getType()->isMobile() == true) {
|
||||
// ret = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
if(faction->hasAliveUnits(true,false) == true) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
const Faction *faction = getFaction(factionIndex);
|
||||
// for(int i = 0; i < faction->getUnitCount(); ++i) {
|
||||
// Unit *unit = getFaction(factionIndex)->getUnit(i);
|
||||
// if(unit != NULL && unit->isAlive() && unit->getType()->isMobile() == true) {
|
||||
// ret = false;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
if(faction->hasAliveUnits(true,false) == true) {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,8 +160,8 @@ public:
|
|||
inline int getThisTeamIndex() const {return thisTeamIndex;}
|
||||
inline void setThisTeamIndex(int team) { thisTeamIndex=team;}
|
||||
|
||||
inline const Faction *getThisFaction() const {return factions[thisFactionIndex];}
|
||||
inline Faction *getThisFactionPtr() {return factions[thisFactionIndex];}
|
||||
inline const Faction *getThisFaction() const {return (thisFactionIndex >= 0 ? factions[thisFactionIndex] : NULL);}
|
||||
inline Faction *getThisFactionPtr() {return (thisFactionIndex >= 0 ? factions[thisFactionIndex] : NULL);}
|
||||
|
||||
inline int getFactionCount() const {return (int)factions.size();}
|
||||
inline const Map *getMap() const {return ↦}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
db_disconnect( DB_LINK );
|
||||
unset( $linkid );
|
||||
|
||||
header('Content-type: application/json');
|
||||
echo json_encode($all_servers);
|
||||
unset( $all_servers );
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue