News:

Check out the MegaGlest Wiki! Anyone can be an editor, and we want you!

Main Menu

BUG - Scenario not end on death

Started by Omega, 28 June 2011, 20:03:05

Omega

Testing some stuff for scenarios, with the default winning conditions on, even if you are completely wiped out, the game will not give the "you lose" message. Normally if the default winning conditions are on, you win and lose based on the buildings destroyed.

As well, the loading screen images for scenarios don't seem to be working. I just got the generic missing image screen. Is the loading screen the path relative from the scenario XML?
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

silnarm

using,

  <default-units value="false"/>
  <default-victory-conditions value="true"/>


I immediately get the 'you lose' message, as expected. Could you cull away other code leaving the bare minimum to reproduce this then post it up?

Quote from: Omega on 28 June 2011, 20:03:05
As well, the loading screen images for scenarios don't seem to be working. I just got the generic missing image screen. Is the loading screen the path relative from the scenario XML?

I assume it looks in the scenario directory, what does the error log say? While it would previously try to load any valid image file, this is no longer true, all textures must have power-of-two dimensions now.

Glest Advanced Engine - Code Monkey

Timeline | Downloads

Omega

Quote from: silnarm on 30 June 2011, 12:31:53all textures must have power-of-two dimensions now.
Oh, that would be the problem. Can the width and height be different as long as they are each a power of two, eg: 1024x512?

I'll have to retry the scenario again, I just started one with the default units, resources, and victory conditions, then just played it out in a suicide mission.
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert

hailstone

Quote from: Omega on 28 June 2011, 20:03:05
Testing some stuff for scenarios, with the default winning conditions on, even if you are completely wiped out, the game will not give the "you lose" message. Normally if the default winning conditions are on, you win and lose based on the buildings destroyed.
I changed this a while back so that it wouldn't count as losing if your team still had buildings left and the game wouldn't end until there was a winner (ie teams with buildings = 1) instead of "if this faction has no buildings then lose and exit". It might be good to have the previous early out behaviour for scenarios (see comment in current code).

Previous code:
[spoiler]
GameStatus SimulationInterface::checkWinnerStandard() {
//lose
bool lose = false;
if (!hasBuilding(world->getThisFaction())) {
lose = true;
for (int i=0; i < world->getFactionCount(); ++i) {
if (!world->getFaction(i)->isAlly(world->getThisFaction())) {
stats->setVictorious(i);
}
}
gameOver = true;
return GameStatus::LOST;
}

//win
if (!lose) {
bool win = true;
for (int i=0; i < world->getFactionCount(); ++i) {
if (i != world->getThisFactionIndex()) {
if (hasBuilding(world->getFaction(i))
&& !world->getFaction(i)->isAlly(world->getThisFaction())) {
win = false;
}
}
}

//if win
if (win) {
for (int i=0; i < world->getFactionCount(); ++i) {
if (world->getFaction(i)->isAlly(world->getThisFaction())) {
stats->setVictorious(i);
}
}
gameOver = true;
return GameStatus::WON;
}
}
return GameStatus::NO_CHANGE;
}
[/spoiler]

Current code:
[spoiler]
GameStatus SimulationInterface::checkWinnerStandard() {
bool teams[GameConstants::maxPlayers] = {false};
int activeTeams = 0;

// if any faction in the team has a building set to active
for (int i = 0; i < world->getFactionCount(); ++i) {
// only bother setting once for each active team
if (!teams[world->getFaction(i)->getTeam()] && hasBuilding(world->getFaction(i))) {
activeTeams++;
teams[world->getFaction(i)->getTeam()] = true;
}
}

bool thisTeamWin = teams[world->getThisFaction()->getTeam()];

// has game ended?
if (activeTeams <= 1 /*|| !thisTeamWin*/) { // uncomment to get previous early out behaviour
gameOver = true;

// set victory
for (int i = 0; i < world->getFactionCount(); ++i) {
if (teams[world->getFaction(i)->getTeam()]) {
stats->setVictorious(i);
}
}

if (thisTeamWin) {
return GameStatus::WON;
} else {
return GameStatus::LOST;
}
}

return GameStatus::NO_CHANGE;
}
[/spoiler]
Glest Advanced Engine - Admin/Programmer
https://sourceforge.net/projects/glestae/

Omega

Oh, I see. As a note, rather than changing it for all scenarios in general, what about a piece of Lua code that could be called to change this, so it could only be "disabled" where necessary?
Edit the MegaGlest wiki: http://docs.megaglest.org/

My personal projects: http://github.com/KatrinaHoffert