- Some initial changes in prep for support server controlled AI
This commit is contained in:
parent
288bd3a287
commit
1c9b85418a
|
@ -30,10 +30,15 @@ using namespace Shared::Graphics;
|
||||||
|
|
||||||
namespace Glest{ namespace Game{
|
namespace Glest{ namespace Game{
|
||||||
|
|
||||||
|
bool AiInterface::enableServerControlledAI = false;
|
||||||
|
|
||||||
AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex){
|
AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
this->world= game.getWorld();
|
this->world= game.getWorld();
|
||||||
this->commander= game.getCommander();
|
this->commander= game.getCommander();
|
||||||
this->console= game.getConsole();
|
this->console= game.getConsole();
|
||||||
|
this->gameSettings = game.getGameSettings();
|
||||||
|
|
||||||
this->factionIndex= factionIndex;
|
this->factionIndex= factionIndex;
|
||||||
this->teamIndex= teamIndex;
|
this->teamIndex= teamIndex;
|
||||||
|
@ -55,6 +60,7 @@ AiInterface::AiInterface(Game &game, int factionIndex, int teamIndex){
|
||||||
fprintf(f, "%s", "Glest AI log file\n\n");
|
fprintf(f, "%s", "Glest AI log file\n\n");
|
||||||
fclose(f);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ==================== main ====================
|
// ==================== main ====================
|
||||||
|
@ -88,6 +94,18 @@ void AiInterface::printLog(int logLevel, const string &s){
|
||||||
// ==================== interaction ====================
|
// ==================== interaction ====================
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos){
|
CommandResult AiInterface::giveCommand(int unitIndex, CommandClass commandClass, const Vec2i &pos){
|
||||||
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
if(enableServerControlledAI == true && this->gameSettings->isNetworkGame() == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
CommandResult result = commander->tryGiveCommand(world->getFaction(factionIndex)->getUnit(unitIndex), world->getFaction(factionIndex)->getUnit(unitIndex)->getType()->getFirstCtOfClass(commandClass), pos, world->getFaction(factionIndex)->getUnit(unitIndex)->getType(),CardinalDir::NORTH);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
Command *c= new Command (world->getFaction(factionIndex)->getUnit(unitIndex)->getType()->getFirstCtOfClass(commandClass), pos);
|
Command *c= new Command (world->getFaction(factionIndex)->getUnit(unitIndex)->getType()->getFirstCtOfClass(commandClass), pos);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
@ -96,30 +114,81 @@ CommandResult AiInterface::giveCommand(int unitIndex, CommandClass commandClass,
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos){
|
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos){
|
||||||
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
if(enableServerControlledAI == true && this->gameSettings->isNetworkGame() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos));
|
|
||||||
|
CommandResult result = commander->tryGiveCommand(world->getFaction(factionIndex)->getUnit(unitIndex), commandType, pos, world->getFaction(factionIndex)->getUnit(unitIndex)->getType(),CardinalDir::NORTH);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos));
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut){
|
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, const Vec2i &pos, const UnitType *ut){
|
||||||
|
assert(this->gameSettings != NULL);
|
||||||
|
|
||||||
|
if(enableServerControlledAI == true && this->gameSettings->isNetworkGame() == true) {
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir::NORTH));
|
|
||||||
|
CommandResult result = commander->tryGiveCommand(world->getFaction(factionIndex)->getUnit(unitIndex), commandType, pos, ut,CardinalDir::NORTH);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, Unit *u){
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, u));
|
|
||||||
|
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, pos, ut, CardinalDir::NORTH));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CommandResult AiInterface::giveCommand(int unitIndex, const CommandType *commandType, Unit *u){
|
||||||
|
assert(this->gameSettings != NULL);
|
||||||
|
assert(this->commander != NULL);
|
||||||
|
|
||||||
|
if(enableServerControlledAI == true && this->gameSettings->isNetworkGame() == true) {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
assert(u != NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
CommandResult result = commander->tryGiveCommand(u, commandType, Vec2i(0), u->getType(),CardinalDir::NORTH);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
CommandResult result = world->getFaction(factionIndex)->getUnit(unitIndex)->giveCommand(new Command(commandType, u));
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ==================== get data ====================
|
// ==================== get data ====================
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Martiño Figueroa
|
// Copyright (C) 2001-2008 Martio Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -17,6 +17,7 @@
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "conversion.h"
|
#include "conversion.h"
|
||||||
#include "ai.h"
|
#include "ai.h"
|
||||||
|
#include "game_settings.h"
|
||||||
|
|
||||||
using Shared::Util::intToStr;
|
using Shared::Util::intToStr;
|
||||||
|
|
||||||
|
@ -33,6 +34,8 @@ private:
|
||||||
World *world;
|
World *world;
|
||||||
Commander *commander;
|
Commander *commander;
|
||||||
Console *console;
|
Console *console;
|
||||||
|
GameSettings *gameSettings;
|
||||||
|
|
||||||
Ai ai;
|
Ai ai;
|
||||||
|
|
||||||
int timer;
|
int timer;
|
||||||
|
@ -43,6 +46,8 @@ private:
|
||||||
bool redir;
|
bool redir;
|
||||||
int logLevel;
|
int logLevel;
|
||||||
|
|
||||||
|
static bool enableServerControlledAI;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
AiInterface(Game &game, int factionIndex, int teamIndex);
|
AiInterface(Game &game, int factionIndex, int teamIndex);
|
||||||
|
|
||||||
|
@ -84,6 +89,8 @@ public:
|
||||||
bool checkCosts(const ProducibleType *pt);
|
bool checkCosts(const ProducibleType *pt);
|
||||||
bool isFreeCells(const Vec2i &pos, int size, Field field);
|
bool isFreeCells(const Vec2i &pos, int size, Field field);
|
||||||
|
|
||||||
|
static bool getEnableServerControlledAI() { return enableServerControlledAI; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string getLogFilename() const {return "ai"+intToStr(factionIndex)+".log";}
|
string getLogFilename() const {return "ai"+intToStr(factionIndex)+".log";}
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,12 +41,19 @@ void Commander::init(World *world){
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue) const {
|
CommandResult Commander::tryGiveCommand(const Unit* unit, const CommandType *commandType, const Vec2i &pos, const UnitType* unitType, CardinalDir facing, bool tryQueue) const {
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
assert(this->world != NULL);
|
assert(this->world != NULL);
|
||||||
assert(unit != NULL);
|
assert(unit != NULL);
|
||||||
assert(commandType != NULL);
|
assert(commandType != NULL);
|
||||||
assert(unitType != NULL);
|
assert(unitType != NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(), commandType->getId(), pos, unitType->getId(), -1, facing, tryQueue);
|
NetworkCommand networkCommand(this->world,nctGiveCommand, unit->getId(), commandType->getId(), pos, unitType->getId(), -1, facing, tryQueue);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
return pushNetworkCommand(&networkCommand);
|
return pushNetworkCommand(&networkCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,12 +43,16 @@ Game *thisGamePtr = NULL;
|
||||||
Game::Game(Program *program, const GameSettings *gameSettings):
|
Game::Game(Program *program, const GameSettings *gameSettings):
|
||||||
ProgramState(program), lastMousePos(0)
|
ProgramState(program), lastMousePos(0)
|
||||||
{
|
{
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
originalDisplayMsgCallback = NULL;
|
originalDisplayMsgCallback = NULL;
|
||||||
thisGamePtr = this;
|
thisGamePtr = this;
|
||||||
|
|
||||||
this->gameSettings= *gameSettings;
|
this->gameSettings= *gameSettings;
|
||||||
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
scrollSpeed = Config::getInstance().getFloat("UiScrollSpeed","1.5");
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
mouseX=0;
|
mouseX=0;
|
||||||
mouseY=0;
|
mouseY=0;
|
||||||
mouse2d= 0;
|
mouse2d= 0;
|
||||||
|
@ -63,10 +67,13 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
||||||
renderNetworkStatus= false;
|
renderNetworkStatus= false;
|
||||||
speed= sNormal;
|
speed= sNormal;
|
||||||
showFullConsole= false;
|
showFullConsole= false;
|
||||||
render3DThreadManager = NULL;
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
Game::~Game(){
|
Game::~Game(){
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
Logger &logger= Logger::getInstance();
|
Logger &logger= Logger::getInstance();
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
|
@ -74,25 +81,26 @@ Game::~Game(){
|
||||||
logger.setState(Lang::getInstance().get("Deleting"));
|
logger.setState(Lang::getInstance().get("Deleting"));
|
||||||
logger.add("Game", true);
|
logger.add("Game", true);
|
||||||
|
|
||||||
BaseThread::shutdownAndWait(render3DThreadManager);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
delete render3DThreadManager;
|
|
||||||
render3DThreadManager = NULL;
|
|
||||||
|
|
||||||
renderer.endGame();
|
renderer.endGame();
|
||||||
SoundRenderer::getInstance().stopAllSounds();
|
SoundRenderer::getInstance().stopAllSounds();
|
||||||
|
|
||||||
deleteValues(aiInterfaces.begin(), aiInterfaces.end());
|
deleteValues(aiInterfaces.begin(), aiInterfaces.end());
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
gui.end(); //selection must be cleared before deleting units
|
gui.end(); //selection must be cleared before deleting units
|
||||||
world.end(); //must die before selection because of referencers
|
world.end(); //must die before selection because of referencers
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
thisGamePtr = NULL;
|
thisGamePtr = NULL;
|
||||||
if(originalDisplayMsgCallback != NULL) {
|
if(originalDisplayMsgCallback != NULL) {
|
||||||
NetworkInterface::setDisplayMessageFunction(originalDisplayMsgCallback);
|
NetworkInterface::setDisplayMessageFunction(originalDisplayMsgCallback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ==================== init and load ====================
|
// ==================== init and load ====================
|
||||||
|
|
||||||
int Game::ErrorDisplayMessage(const char *msg, bool exitApp) {
|
int Game::ErrorDisplayMessage(const char *msg, bool exitApp) {
|
||||||
|
@ -346,7 +354,7 @@ void Game::init()
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Waiting for network\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Waiting for network\n",__FILE__,__FUNCTION__);
|
||||||
logger.add("Waiting for network", true);
|
logger.add("Waiting for network players", true);
|
||||||
networkManager.getGameNetworkInterface()->waitUntilReady(&checksum);
|
networkManager.getGameNetworkInterface()->waitUntilReady(&checksum);
|
||||||
|
|
||||||
std::string worldLog = world.DumpWorldToLog(true);
|
std::string worldLog = world.DumpWorldToLog(true);
|
||||||
|
@ -358,18 +366,9 @@ void Game::init()
|
||||||
|
|
||||||
logger.add("Launching game");
|
logger.add("Launching game");
|
||||||
|
|
||||||
BaseThread::shutdownAndWait(render3DThreadManager);
|
|
||||||
delete render3DThreadManager;
|
|
||||||
//render3DThreadManager = new SimpleTaskThread(this,0,5,true);
|
|
||||||
//render3DThreadManager->start();
|
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::simpleTask() {
|
|
||||||
renderWorker();
|
|
||||||
}
|
|
||||||
|
|
||||||
// ==================== update ====================
|
// ==================== update ====================
|
||||||
|
|
||||||
//update
|
//update
|
||||||
|
@ -394,17 +393,22 @@ void Game::update(){
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
NetworkManager &networkManager= NetworkManager::getInstance();
|
||||||
//update
|
//update
|
||||||
for(int i=0; i<updateLoops; ++i){
|
for(int i=0; i<updateLoops; ++i){
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
if( AiInterface::getEnableServerControlledAI() == false ||
|
||||||
|
this->gameSettings.isNetworkGame() == false ||
|
||||||
|
(this->gameSettings.isNetworkGame() == true && networkManager.getNetworkRole() == nrServer)) {
|
||||||
//AiInterface
|
//AiInterface
|
||||||
for(int i=0; i<world.getFactionCount(); ++i){
|
for(int i=0; i<world.getFactionCount(); ++i){
|
||||||
if(world.getFaction(i)->getCpuControl() && scriptManager.getPlayerModifiers(i)->getAiEnabled()){
|
if(world.getFaction(i)->getCpuControl() && scriptManager.getPlayerModifiers(i)->getAiEnabled()){
|
||||||
aiInterfaces[i]->update();
|
aiInterfaces[i]->update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
//World
|
//World
|
||||||
|
@ -469,12 +473,7 @@ void Game::render() {
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps);
|
//SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps);
|
||||||
|
|
||||||
renderFps++;
|
renderFps++;
|
||||||
if(render3DThreadManager == NULL) {
|
|
||||||
renderWorker();
|
renderWorker();
|
||||||
}
|
|
||||||
else {
|
|
||||||
render3DThreadManager->setTaskSignalled(true);
|
|
||||||
}
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps);
|
//SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "chat_manager.h"
|
#include "chat_manager.h"
|
||||||
#include "script_manager.h"
|
#include "script_manager.h"
|
||||||
#include "game_settings.h"
|
#include "game_settings.h"
|
||||||
#include "simple_threads.h"
|
//#include "simple_threads.h"
|
||||||
#include "network_interface.h"
|
#include "network_interface.h"
|
||||||
|
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
@ -38,7 +38,8 @@ class GraphicMessageBox;
|
||||||
// Main game class
|
// Main game class
|
||||||
// =====================================================
|
// =====================================================
|
||||||
|
|
||||||
class Game: public ProgramState, public SimpleTaskCallbackInterface {
|
//class Game: public ProgramState, public SimpleTaskCallbackInterface {
|
||||||
|
class Game: public ProgramState {
|
||||||
public:
|
public:
|
||||||
enum Speed{
|
enum Speed{
|
||||||
sFast,
|
sFast,
|
||||||
|
@ -60,7 +61,6 @@ private:
|
||||||
Console console;
|
Console console;
|
||||||
ChatManager chatManager;
|
ChatManager chatManager;
|
||||||
ScriptManager scriptManager;
|
ScriptManager scriptManager;
|
||||||
SimpleTaskThread *render3DThreadManager;
|
|
||||||
|
|
||||||
//misc
|
//misc
|
||||||
Checksum checksum;
|
Checksum checksum;
|
||||||
|
@ -123,8 +123,6 @@ public:
|
||||||
|
|
||||||
void quitGame();
|
void quitGame();
|
||||||
|
|
||||||
virtual void simpleTask();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//render
|
//render
|
||||||
void render3d();
|
void render3d();
|
||||||
|
|
|
@ -67,6 +67,16 @@ public:
|
||||||
const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];}
|
const string &getNetworkPlayerName(int factionIndex) const {return networkPlayerNames[factionIndex];}
|
||||||
ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];}
|
ControlType getFactionControl(int factionIndex) const {return factionControls[factionIndex];}
|
||||||
|
|
||||||
|
bool isNetworkGame() const {
|
||||||
|
bool result = false;
|
||||||
|
for(int idx = 0; idx < GameConstants::maxPlayers; ++idx) {
|
||||||
|
if(factionControls[idx] == ctNetwork) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
int getThisFactionIndex() const {return thisFactionIndex;}
|
int getThisFactionIndex() const {return thisFactionIndex;}
|
||||||
int getFactionCount() const {return factionCount;}
|
int getFactionCount() const {return factionCount;}
|
||||||
int getTeam(int factionIndex) const {return teams[factionIndex];}
|
int getTeam(int factionIndex) const {return teams[factionIndex];}
|
||||||
|
|
|
@ -584,15 +584,19 @@ void MenuStateConnectedGame::update()
|
||||||
//launch
|
//launch
|
||||||
if(clientInterface->getLaunchGame())
|
if(clientInterface->getLaunchGame())
|
||||||
{
|
{
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - A\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
//servers.save(serversSavedFile);
|
//servers.save(serversSavedFile);
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - B\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
assert(clientInterface != NULL);
|
||||||
|
|
||||||
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
program->setState(new Game(program, clientInterface->getGameSettings()));
|
program->setState(new Game(program, clientInterface->getGameSettings()));
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] clientInterface->getLaunchGame() - C\n",__FILE__,__FUNCTION__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
Loading…
Reference in New Issue