- updated scenario lua function to allow carry over of factions or not
This commit is contained in:
parent
2d42f59fe1
commit
b126768d9c
|
@ -48,6 +48,7 @@ const int CANCEL_SWITCH_TEAM = -1;
|
|||
|
||||
Game::Game() : ProgramState(NULL) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
originalDisplayMsgCallback = NULL;
|
||||
aiInterfaces.clear();
|
||||
|
||||
|
@ -103,19 +104,7 @@ Game::Game() : ProgramState(NULL) {
|
|||
currentUIState=NULL;
|
||||
}
|
||||
|
||||
Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverMode):
|
||||
ProgramState(program), lastMousePos(0), isFirstRender(true)
|
||||
{
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->masterserverMode = masterserverMode;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
printf("Starting a new game...\n");
|
||||
}
|
||||
|
||||
this->program = program;
|
||||
void Game::resetMembers() {
|
||||
Unit::setGame(this);
|
||||
gameStarted = false;
|
||||
|
||||
|
@ -147,7 +136,7 @@ Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverM
|
|||
keyboardSetupPopupMenuIndex = -1;
|
||||
currentUIState = NULL;
|
||||
|
||||
this->gameSettings= *gameSettings;
|
||||
//this->gameSettings= NULL;
|
||||
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
||||
photoModeEnabled = Config::getInstance().getBool("PhotoMode","false");
|
||||
visibleHUD = Config::getInstance().getBool("VisibleHud","true");
|
||||
|
@ -182,6 +171,23 @@ Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverM
|
|||
|
||||
Logger &logger= Logger::getInstance();
|
||||
logger.showProgress();
|
||||
}
|
||||
|
||||
Game::Game(Program *program, const GameSettings *gameSettings,bool masterserverMode):
|
||||
ProgramState(program), lastMousePos(0), isFirstRender(true)
|
||||
{
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->masterserverMode = masterserverMode;
|
||||
|
||||
if(this->masterserverMode == true) {
|
||||
printf("Starting a new game...\n");
|
||||
}
|
||||
|
||||
this->program = program;
|
||||
resetMembers();
|
||||
this->gameSettings= *gameSettings;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
@ -1127,7 +1133,8 @@ void Game::update() {
|
|||
|
||||
if(world.getQueuedScenario() != "") {
|
||||
string name = world.getQueuedScenario();
|
||||
world.setQueuedScenario("");
|
||||
bool keepFactions = world.getQueuedScenarioKeepFactions();
|
||||
world.setQueuedScenario("",false);
|
||||
|
||||
vector<string> results;
|
||||
const vector<string> &dirList = Config::getInstance().getPathListForType(ptScenarios);
|
||||
|
@ -1146,16 +1153,43 @@ void Game::update() {
|
|||
//program->setState(new Game(program, &gameSettings, false));
|
||||
|
||||
//world->end();
|
||||
this->setGameSettings(&gameSettings);
|
||||
|
||||
//world->getMapPtr()->end();
|
||||
//world.end();
|
||||
|
||||
if(keepFactions == false) {
|
||||
world.end();
|
||||
world.cleanup();
|
||||
world.clearTileset();
|
||||
|
||||
SoundRenderer::getInstance().stopAllSounds();
|
||||
deleteValues(aiInterfaces.begin(), aiInterfaces.end());
|
||||
aiInterfaces.clear();
|
||||
gui.end(); //selection must be cleared before deleting units
|
||||
world.end(); //must die before selection because of referencers
|
||||
// MUST DO THIS LAST!!!! Because objects above have pointers to things like
|
||||
// unit particles and fade them out etc and this end method deletes the original
|
||||
// object pointers.
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.endGame();
|
||||
|
||||
GameConstants::updateFps = original_updateFps;
|
||||
GameConstants::cameraFps = original_cameraFps;
|
||||
|
||||
this->setGameSettings(&gameSettings);
|
||||
this->resetMembers();
|
||||
this->load();
|
||||
this->init();
|
||||
}
|
||||
else {
|
||||
world.endScenario();
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
renderer.endScenario();
|
||||
world.clearTileset();
|
||||
//this->load(lgt_FactionPreview | lgt_TileSet | lgt_TechTree | lgt_Map | lgt_Scenario);
|
||||
this->setGameSettings(&gameSettings);
|
||||
|
||||
this->load(lgt_FactionPreview | lgt_TileSet | lgt_Map | lgt_Scenario);
|
||||
//this->init();
|
||||
|
||||
world.init(this, gameSettings.getDefaultUnits(),false);
|
||||
Map *map= world.getMap();
|
||||
gameCamera.init(map->getW(), map->getH());
|
||||
|
@ -1194,6 +1228,8 @@ void Game::update() {
|
|||
StrSound *gameMusic= world.getThisFaction()->getType()->getMusic();
|
||||
soundRenderer.playMusic(gameMusic);
|
||||
}
|
||||
}
|
||||
//this->init();
|
||||
|
||||
//printf("[%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//Checksum checksum;
|
||||
|
|
|
@ -169,6 +169,7 @@ public:
|
|||
|
||||
void toggleTeamColorMarker();
|
||||
//init
|
||||
void resetMembers();
|
||||
virtual void load(int loadTypes);
|
||||
virtual void load();
|
||||
virtual void init();
|
||||
|
|
|
@ -261,7 +261,7 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
|
||||
inCellTriggerEvent = true;
|
||||
if(movingUnit != NULL) {
|
||||
ScenarioInfo scenarioInfoStart = world->getScenario()->getInfo();
|
||||
//ScenarioInfo scenarioInfoStart = world->getScenario()->getInfo();
|
||||
|
||||
for(std::map<int,CellTriggerEvent>::iterator iterMap = CellTriggerEventList.begin();
|
||||
iterMap != CellTriggerEventList.end(); ++iterMap) {
|
||||
|
@ -358,10 +358,10 @@ void ScriptManager::onCellTriggerEvent(Unit *movingUnit) {
|
|||
luaScript.endCall();
|
||||
}
|
||||
|
||||
ScenarioInfo scenarioInfoEnd = world->getScenario()->getInfo();
|
||||
if(scenarioInfoStart.file != scenarioInfoEnd.file) {
|
||||
break;
|
||||
}
|
||||
// ScenarioInfo scenarioInfoEnd = world->getScenario()->getInfo();
|
||||
// if(scenarioInfoStart.file != scenarioInfoEnd.file) {
|
||||
// break;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -858,13 +858,13 @@ int ScriptManager::getUnitCountOfType(int factionIndex, const string &typeName)
|
|||
return world->getUnitCountOfType(factionIndex, typeName);
|
||||
}
|
||||
|
||||
void ScriptManager::loadScenario(const string &name) {
|
||||
void ScriptManager::loadScenario(const string &name, bool keepFactions) {
|
||||
//printf("[%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
ScriptManager_STREFLOP_Wrapper streflopWrapper;
|
||||
|
||||
world->setQueuedScenario(name);
|
||||
world->setQueuedScenario(name,keepFactions);
|
||||
/*
|
||||
vector<string> results;
|
||||
const vector<string> &dirList = Config::getInstance().getPathListForType(ptScenarios);
|
||||
|
@ -1385,7 +1385,7 @@ int ScriptManager::loadScenario(LuaHandle* luaHandle) {
|
|||
//printf("[%s:%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
LuaArguments luaArguments(luaHandle);
|
||||
thisScriptManager->loadScenario(luaArguments.getString(-1));
|
||||
thisScriptManager->loadScenario(luaArguments.getString(-2),luaArguments.getInt(-1));
|
||||
return luaArguments.getReturnCount();
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ private:
|
|||
|
||||
bool getGameWon();
|
||||
|
||||
void loadScenario(const string &name);
|
||||
void loadScenario(const string &name, bool keepFactions);
|
||||
|
||||
//callbacks, commands
|
||||
static int showMessage(LuaHandle* luaHandle);
|
||||
|
|
|
@ -80,11 +80,12 @@ World::World(){
|
|||
fogOfWar=false;
|
||||
perfTimerEnabled=false;
|
||||
queuedScenarioName="";
|
||||
queuedScenarioKeepFactions=false;
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
World::~World() {
|
||||
void World::cleanup() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
ExploredCellsLookupItemCache.clear();
|
||||
|
@ -138,6 +139,14 @@ World::~World() {
|
|||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
World::~World() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
cleanup();
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
void World::endScenario() {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
Logger::getInstance().add("World", true);
|
||||
|
@ -326,8 +335,9 @@ Checksum World::loadScenario(const string &path, Checksum *checksum, bool resetC
|
|||
|
||||
// ==================== misc ====================
|
||||
|
||||
void World::setQueuedScenario(string scenarioName) {
|
||||
void World::setQueuedScenario(string scenarioName,bool keepFactions) {
|
||||
queuedScenarioName = scenarioName;
|
||||
queuedScenarioKeepFactions = keepFactions;
|
||||
}
|
||||
|
||||
void World::updateAllFactionUnits() {
|
||||
|
|
|
@ -144,10 +144,12 @@ private:
|
|||
uint32 nextCommandGroupId;
|
||||
|
||||
string queuedScenarioName;
|
||||
bool queuedScenarioKeepFactions;
|
||||
|
||||
public:
|
||||
World();
|
||||
~World();
|
||||
void cleanup();
|
||||
void end(); //to die before selection does
|
||||
void endScenario(); //to die before selection does
|
||||
|
||||
|
@ -196,8 +198,9 @@ public:
|
|||
set<string> &factions, Checksum* checksum,std::map<string,vector<pair<string, string> > > &loadedFileList);
|
||||
Checksum loadMap(const string &path, Checksum* checksum);
|
||||
Checksum loadScenario(const string &path, Checksum* checksum,bool resetCurrentScenario=false);
|
||||
void setQueuedScenario(string scenarioName);
|
||||
void setQueuedScenario(string scenarioName,bool keepFactions);
|
||||
string getQueuedScenario() const { return queuedScenarioName; }
|
||||
bool getQueuedScenarioKeepFactions() const { return queuedScenarioKeepFactions; }
|
||||
|
||||
//misc
|
||||
void update();
|
||||
|
|
Loading…
Reference in New Issue
Block a user