- lots of code cleanup from the cppcheck

This commit is contained in:
Mark Vejvoda 2012-09-22 20:13:57 +00:00
parent b1cc8592fd
commit 1c211e4ce6
75 changed files with 365 additions and 151 deletions

View File

@ -288,7 +288,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
model(NULL), glCanvas(NULL), renderer(NULL), model(NULL), glCanvas(NULL), renderer(NULL),
initTextureManager(true), timer(NULL), initTextureManager(true), timer(NULL),
startupSettingsInited(false), startupSettingsInited(false),
fileDialog(NULL) fileDialog(NULL),colorPicker(NULL)
{ {
this->appPath = appPath; this->appPath = appPath;
Properties::setApplicationPath(executable_path(appPath)); Properties::setApplicationPath(executable_path(appPath));
@ -297,6 +297,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
string iniFilePath = extractDirectoryPathFromFile(config.getFileName(false)); string iniFilePath = extractDirectoryPathFromFile(config.getFileName(false));
//getGlPlatformExtensions(); //getGlPlatformExtensions();
isControlKeyPressed = false;
int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker
//int args[] = { WX_GL_RGBA, WX_GL_MIN_ALPHA, 0 }; // to prevent flicker //int args[] = { WX_GL_RGBA, WX_GL_MIN_ALPHA, 0 }; // to prevent flicker
glCanvas = new GlCanvas(this, args); glCanvas = new GlCanvas(this, args);
@ -2508,8 +2509,9 @@ int App::MainLoop(){
} }
catch(const exception &e){ catch(const exception &e){
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Exception"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Exception"), wxOK | wxICON_ERROR).ShowModal();
return 0; return 1;
} }
return 0;
} }
int App::OnExit(){ int App::OnExit(){

View File

@ -219,6 +219,7 @@ public:
App() : wxApp() { App() : wxApp() {
mainWindow = NULL; mainWindow = NULL;
} }
virtual ~App() {}
virtual bool OnInit(); virtual bool OnInit();
virtual int MainLoop(); virtual int MainLoop();
virtual int OnExit(); virtual int OnExit();

View File

@ -106,6 +106,16 @@ Renderer::Renderer() {
green = 0.3f; green = 0.3f;
blue = 0.3f; blue = 0.3f;
alpha = 1.0f; alpha = 1.0f;
customTextureRed=NULL;
customTextureBlue=NULL;
customTextureGreen=NULL;
customTextureYellow=NULL;
customTextureWhite=NULL;
customTextureCyan=NULL;
customTextureOrange=NULL;
customTextureMagenta=NULL;
particleManager=NULL;
} }
Renderer::~Renderer() { Renderer::~Renderer() {
@ -346,6 +356,7 @@ void Renderer::reset(int w, int h, PlayerColor playerColor) {
break; break;
default: default:
assert(false); assert(false);
break;
} }
meshCallbackTeamColor.setTeamTexture(customTexture); meshCallbackTeamColor.setTeamTexture(customTexture);
@ -479,6 +490,7 @@ Texture2D * Renderer::getPlayerColorTexture(PlayerColor playerColor) {
break; break;
default: default:
assert(false); assert(false);
break;
} }
return customTexture; return customTexture;

View File

@ -121,7 +121,7 @@ private:
void checkExtension(const string &extension, const string &msg); void checkExtension(const string &extension, const string &msg);
public: public:
~Renderer(); virtual ~Renderer();
static Renderer *getInstance(); static Renderer *getInstance();
void init(); void init();

View File

@ -127,6 +127,8 @@ public:
virtual unsigned int getEdgeCount(void *userData) const = 0; virtual unsigned int getEdgeCount(void *userData) const = 0;
virtual AI_Node * getEdge(int index,void *userData) const = 0; virtual AI_Node * getEdge(int index,void *userData) const = 0;
virtual int32 getHashCode() const = 0; virtual int32 getHashCode() const = 0;
virtual ~AI_Node() {}
}; };
enum SearchState { enum SearchState {

View File

@ -296,7 +296,7 @@ bool GraphicLabel::mouseMove(int x, int y) {
int useWidth = w; int useWidth = w;
if(text.length() > 0 && font3D != NULL) { if(text.length() > 0 && font3D != NULL) {
float lineWidth = (font3D->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue); float lineWidth = (font3D->getTextHandler()->Advance(text.c_str()) * Shared::Graphics::Font::scaleFontValue);
useWidth = (int)lineWidth; useWidth = (int)lineWidth;
} }
@ -833,7 +833,7 @@ void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
int maxButtonWidth = -1; int maxButtonWidth = -1;
for(unsigned int i = 0; i < menuItems.size(); ++i) { for(unsigned int i = 0; i < menuItems.size(); ++i) {
int currentButtonWidth = -1; int currentButtonWidth = -1;
if(font3D != NULL && Font::forceLegacyFonts == false) { if(font3D != NULL && Shared::Graphics::Font::forceLegacyFonts == false) {
FontMetrics *fontMetrics= font3D->getMetrics(); FontMetrics *fontMetrics= font3D->getMetrics();
if(fontMetrics) { if(fontMetrics) {
currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]); currentButtonWidth = fontMetrics->getTextWidth(menuItems[i]);

View File

@ -38,6 +38,7 @@ class Console;
class CustomInputCallbackInterface { class CustomInputCallbackInterface {
public: public:
virtual void processInputText(string text, bool cancelled) = 0; virtual void processInputText(string text, bool cancelled) = 0;
virtual ~CustomInputCallbackInterface() {}
}; };
// ===================================================== // =====================================================

View File

@ -968,6 +968,7 @@ void Commander::giveNetworkCommand(NetworkCommand* networkCommand) const {
default: default:
assert(false); assert(false);
break;
} }
} }
else { else {

View File

@ -52,6 +52,7 @@ class SwitchTeamVote;
class CommanderNetworkCallbackInterface { class CommanderNetworkCallbackInterface {
public: public:
virtual void commanderNetworkUpdateTask(int id) = 0; virtual void commanderNetworkUpdateTask(int id) = 0;
virtual ~CommanderNetworkCallbackInterface() {}
}; };
class CommanderNetworkThread : public BaseThread class CommanderNetworkThread : public BaseThread
@ -88,7 +89,7 @@ private:
public: public:
Commander(); Commander();
~Commander(); virtual ~Commander();
void signalNetworkUpdate(Game *game); void signalNetworkUpdate(Game *game);
void init(World *world); void init(World *world);

View File

@ -106,6 +106,13 @@ Game::Game() : ProgramState(NULL) {
program=NULL; program=NULL;
gameStarted=false; gameStarted=false;
highlightCellTexture=NULL;
lastMasterServerGameStatsDump=0;
lastMaxUnitCalcTime=0;
lastRenderLog2d=0;
playerIndexDisconnect=0;
tickCount=0;
popupMenu.setEnabled(false); popupMenu.setEnabled(false);
popupMenu.setVisible(false); popupMenu.setVisible(false);
@ -846,7 +853,7 @@ void Game::load(int loadTypes) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Game::findFactionLogoFile(&gameSettings, &logger); Game::findFactionLogoFile(&gameSettings, &logger);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -883,7 +890,7 @@ void Game::load(int loadTypes) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -921,7 +928,7 @@ void Game::load(int loadTypes) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -934,7 +941,7 @@ void Game::load(int loadTypes) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -997,7 +1004,7 @@ void Game::init(bool initForPreviewOnly) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
} }
@ -1042,7 +1049,7 @@ void Game::init(bool initForPreviewOnly) {
if(initForPreviewOnly == false) { if(initForPreviewOnly == false) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
gui.init(this); gui.init(this);
@ -1083,7 +1090,7 @@ void Game::init(bool initForPreviewOnly) {
if(initForPreviewOnly == false) { if(initForPreviewOnly == false) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
scriptManager.init(&world, &gameCamera,loadGameNode); scriptManager.init(&world, &gameCamera,loadGameNode);
@ -1122,7 +1129,7 @@ void Game::init(bool initForPreviewOnly) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
if(world.getFactionCount() == 1 && world.getFaction(0)->getPersonalityType() == fpt_Observer) { if(world.getFactionCount() == 1 && world.getFaction(0)->getPersonalityType() == fpt_Observer) {
@ -1174,7 +1181,7 @@ void Game::init(bool initForPreviewOnly) {
// give CPU time to update other things to avoid apperance of hanging // give CPU time to update other things to avoid apperance of hanging
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Waiting for network\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] Waiting for network\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__);
@ -1833,7 +1840,7 @@ void Game::addOrReplaceInHighlightedCells(MarkedCell mc){
void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role) { void Game::ReplaceDisconnectedNetworkPlayersWithAI(bool isNetworkGame, NetworkRole role) {
if(role == nrServer && isNetworkGame == true && if(role == nrServer && isNetworkGame == true &&
difftime(time(NULL),lastNetworkPlayerConnectionCheck) >= NETWORK_PLAYER_CONNECTION_CHECK_SECONDS) { difftime((long int)time(NULL),lastNetworkPlayerConnectionCheck) >= NETWORK_PLAYER_CONNECTION_CHECK_SECONDS) {
lastNetworkPlayerConnectionCheck = time(NULL); lastNetworkPlayerConnectionCheck = time(NULL);
Logger &logger= Logger::getInstance(); Logger &logger= Logger::getInstance();
ServerInterface *server = NetworkManager::getInstance().getServerInterface(); ServerInterface *server = NetworkManager::getInstance().getServerInterface();
@ -1945,7 +1952,7 @@ void Game::render() {
string str=""; string str="";
std::map<int,string> factionDebugInfo; std::map<int,string> factionDebugInfo;
if( difftime(time(NULL),lastMasterServerGameStatsDump) >= GAME_STATS_DUMP_INTERVAL) { if( difftime((long int)time(NULL),lastMasterServerGameStatsDump) >= GAME_STATS_DUMP_INTERVAL) {
lastMasterServerGameStatsDump = time(NULL); lastMasterServerGameStatsDump = time(NULL);
str = getDebugStats(factionDebugInfo); str = getDebugStats(factionDebugInfo);
@ -2884,7 +2891,7 @@ void Game::mouseMove(int x, int y, const MouseState *ms) {
gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult); gameCamera.transitionVH(-(y - lastMousePos.y) * ymult, (lastMousePos.x - x) * xmult);
mouseX=lastMousePos.x; mouseX=lastMousePos.x;
mouseY=lastMousePos.y; mouseY=lastMousePos.y;
Window::revertMousePos(); Shared::Platform::Window::revertMousePos();
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
return; return;
@ -3632,7 +3639,7 @@ void Game::render3d(){
void Game::updateWorldStats() { void Game::updateWorldStats() {
world.getStats()->setWorldTimeElapsed(world.getTimeFlow()->getTime()); world.getStats()->setWorldTimeElapsed(world.getTimeFlow()->getTime());
if(difftime(time(NULL),lastMaxUnitCalcTime) >= 1) { if(difftime((long int)time(NULL),lastMaxUnitCalcTime) >= 1) {
lastMaxUnitCalcTime = time(NULL); lastMaxUnitCalcTime = time(NULL);
int totalUnitcount = 0; int totalUnitcount = 0;
@ -3867,7 +3874,7 @@ void Game::render2d() {
std::map<int,string> factionDebugInfo; std::map<int,string> factionDebugInfo;
if( renderer.getShowDebugUI() == true || if( renderer.getShowDebugUI() == true ||
(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1)) { (perfLogging == true && difftime((long int)time(NULL),lastRenderLog2d) >= 1)) {
str = getDebugStats(factionDebugInfo); str = getDebugStats(factionDebugInfo);
} }
@ -3973,7 +3980,7 @@ void Game::render2d() {
//2d mouse //2d mouse
renderer.renderMouse2d(mouseX, mouseY, mouse2d, gui.isSelectingPos()? 1.f: 0.f); renderer.renderMouse2d(mouseX, mouseY, mouse2d, gui.isSelectingPos()? 1.f: 0.f);
if(perfLogging == true && difftime(time(NULL),lastRenderLog2d) >= 1) { if(perfLogging == true && difftime((long int)time(NULL),lastRenderLog2d) >= 1) {
lastRenderLog2d = time(NULL); lastRenderLog2d = time(NULL);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] Statistics: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,str.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] Statistics: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,str.c_str());

View File

@ -91,7 +91,7 @@ private:
int updateFps, lastUpdateFps, avgUpdateFps; int updateFps, lastUpdateFps, avgUpdateFps;
int totalRenderFps, renderFps, lastRenderFps, avgRenderFps,currentAvgRenderFpsTotal; int totalRenderFps, renderFps, lastRenderFps, avgRenderFps,currentAvgRenderFpsTotal;
Uint64 tickCount; uint64 tickCount;
bool paused; bool paused;
bool gameOver; bool gameOver;
bool renderNetworkStatus; bool renderNetworkStatus;

View File

@ -58,6 +58,7 @@ GameCamera::GameCamera() : pos(0.f, defaultHeight, 0.f),
//config //config
speed= 15.f / GameConstants::cameraFps; speed= 15.f / GameConstants::cameraFps;
clampBounds= !Config::getInstance().getBool("PhotoMode"); clampBounds= !Config::getInstance().getBool("PhotoMode");
clampDisable = false;
vAng= startingVAng; vAng= startingVAng;
hAng= startingHAng; hAng= startingHAng;
@ -122,6 +123,14 @@ void GameCamera::setPos(Vec2f pos){
destPos.z = pos.y; destPos.z = pos.y;
} }
void GameCamera::setPos(Vec3f pos){
this->pos= pos;
//clampPosXZ(0.0f, (float)limitX, 0.0f, (float)limitY);
destPos.x = pos.x;
destPos.y = pos.y;
destPos.z = pos.z;
}
void GameCamera::update(){ void GameCamera::update(){
//move XZ //move XZ
@ -143,13 +152,13 @@ void GameCamera::update(){
} }
if(move.y>0){ if(move.y>0){
moveUp(speed * move.y); moveUp(speed * move.y);
if(clampBounds && pos.y<maxHeight){ if(clampDisable == false && clampBounds && pos.y<maxHeight){
rotateHV(0.f, -speed * 1.7f * move.y); rotateHV(0.f, -speed * 1.7f * move.y);
} }
} }
if(move.y<0){ if(move.y<0){
moveUp(speed * move.y); moveUp(speed * move.y);
if(clampBounds && pos.y>minHeight){ if(clampDisable == false && clampBounds && pos.y>minHeight){
rotateHV(0.f, -speed * 1.7f * move.y); rotateHV(0.f, -speed * 1.7f * move.y);
} }
} }
@ -182,7 +191,7 @@ void GameCamera::update(){
clampAng(); clampAng();
if(clampBounds){ if(clampDisable == false && clampBounds){
clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY); clampPosXYZ(0.0f, (float)limitX, minHeight, maxHeight, 0.0f, (float)limitY);
} }
} }
@ -341,6 +350,10 @@ void GameCamera::save(XmlNode *node) const {
// ==================== PRIVATE ==================== // ==================== PRIVATE ====================
void GameCamera::clampPosXZ(float x1, float x2, float z1, float z2){ void GameCamera::clampPosXZ(float x1, float x2, float z1, float z2){
if(clampDisable == true) {
return;
}
if(pos.x < x1) pos.x = x1; if(pos.x < x1) pos.x = x1;
if(destPos.x < x1) destPos.x = x1; if(destPos.x < x1) destPos.x = x1;
if(pos.z < z1) pos.z = z1; if(pos.z < z1) pos.z = z1;
@ -352,6 +365,10 @@ void GameCamera::clampPosXZ(float x1, float x2, float z1, float z2){
} }
void GameCamera::clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2){ void GameCamera::clampPosXYZ(float x1, float x2, float y1, float y2, float z1, float z2){
if(clampDisable == true) {
return;
}
if(pos.x < x1) pos.x = x1; if(pos.x < x1) pos.x = x1;
if(destPos.x < x1) destPos.x = x1; if(destPos.x < x1) destPos.x = x1;
if(pos.y < y1) pos.y = y1; if(pos.y < y1) pos.y = y1;
@ -373,6 +390,10 @@ void GameCamera::rotateHV(float h, float v){
} }
void GameCamera::clampAng() { void GameCamera::clampAng() {
if(clampDisable == true) {
return;
}
if(vAng > maxVAng) vAng = maxVAng; if(vAng > maxVAng) vAng = maxVAng;
if(destAng.x > maxVAng) destAng.x = maxVAng; if(destAng.x > maxVAng) destAng.x = maxVAng;
if(vAng < minVAng) vAng = minVAng; if(vAng < minVAng) vAng = minVAng;

View File

@ -79,6 +79,7 @@ private:
//config //config
float speed; float speed;
bool clampBounds; bool clampBounds;
bool clampDisable;
//float maxRenderDistance; //float maxRenderDistance;
float maxHeight; float maxHeight;
float minHeight; float minHeight;
@ -108,6 +109,7 @@ public:
//set //set
void setRotate(float rotate){this->rotate= rotate;} void setRotate(float rotate){this->rotate= rotate;}
void setPos(Vec2f pos); void setPos(Vec2f pos);
void setPos(Vec3f pos);
void setMoveX(float f) {this->move.x= f;} void setMoveX(float f) {this->move.x= f;}
void setMoveY(float f) {this->move.y= f;} void setMoveY(float f) {this->move.y= f;}
@ -148,6 +150,7 @@ public:
void save(XmlNode *node) const; void save(XmlNode *node) const;
void setClampBounds(bool value) { clampBounds = value; } void setClampBounds(bool value) { clampBounds = value; }
void setClampDisabled(bool value) { clampDisable = value; };
void setMaxHeight(float value); void setMaxHeight(float value);
float getCalculatedDefault() const{ return calculatedDefault; } float getCalculatedDefault() const{ return calculatedDefault; }
void setCalculatedDefault(float calculatedDefault); void setCalculatedDefault(float calculatedDefault);
@ -157,6 +160,9 @@ public:
void setMinVAng(float value) { minVAng = value; } void setMinVAng(float value) { minVAng = value; }
void setMaxVAng(float value) { maxVAng = value; } void setMaxVAng(float value) { maxVAng = value; }
void setHAng(float value) { hAng=value;};
void setVAng(float value) { vAng=value;}
void saveGame(XmlNode *rootNode); void saveGame(XmlNode *rootNode);
void loadGame(const XmlNode *rootNode); void loadGame(const XmlNode *rootNode);

View File

@ -6,6 +6,7 @@
#include "vec.h" #include "vec.h"
#include <map> #include <map>
#include <string> #include <string>
#include "conversion.h"
#include <stdexcept> #include <stdexcept>
// ============================================================== // ==============================================================
@ -21,6 +22,7 @@
using namespace Shared::Graphics; using namespace Shared::Graphics;
using namespace std; using namespace std;
using namespace Shared::Util;
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{

View File

@ -79,11 +79,12 @@ string PlayerStats::getStats() const {
default: default:
printf("Error control = %d\n",control); printf("Error control = %d\n",control);
assert(false); assert(false);
break;
}; };
} }
if(control != ctHuman && control != ctNetwork || if((control != ctHuman && control != ctNetwork) ||
control == ctNetwork && playerLeftBeforeEnd==true) { (control == ctNetwork && playerLeftBeforeEnd == true)) {
controlString += " x " + floatToStr(resourceMultiplier,1); controlString += " x " + floatToStr(resourceMultiplier,1);
} }

View File

@ -87,6 +87,7 @@ public:
maxConcurrentUnitCount = 0; maxConcurrentUnitCount = 0;
totalEndGameConcurrentUnitCount = 0; totalEndGameConcurrentUnitCount = 0;
isMasterserverMode = false; isMasterserverMode = false;
timePlayed = 0;
} }
void init(int factionCount, int thisFactionIndex, const string &description); void init(int factionCount, int thisFactionIndex, const string &description);

View File

@ -416,6 +416,7 @@ string Lang::get(const string &s, string uselanguage, bool fallbackToDefault) {
return "???" + s + "???"; return "???" + s + "???";
} }
return "???" + s + "???";
} }
string Lang::getScenarioString(const string &s) { string Lang::getScenarioString(const string &s) {
@ -430,6 +431,7 @@ string Lang::getScenarioString(const string &s) {
} }
return "???" + s + "???"; return "???" + s + "???";
} }
return "???" + s + "???";
} }
string Lang::getTechTreeString(const string &s,const char *defaultValue) { string Lang::getTechTreeString(const string &s,const char *defaultValue) {
@ -459,6 +461,7 @@ string Lang::getTechTreeString(const string &s,const char *defaultValue) {
} }
return "???" + s + "???"; return "???" + s + "???";
} }
return "???" + s + "???";
} }
string Lang::getTilesetString(const string &s,const char *defaultValue) { string Lang::getTilesetString(const string &s,const char *defaultValue) {
@ -488,6 +491,7 @@ string Lang::getTilesetString(const string &s,const char *defaultValue) {
} }
return "???" + s + "???"; return "???" + s + "???";
} }
return "???" + s + "???";
} }
bool Lang::fileMatchesISO630Code(string uselanguage, string testLanguageFile) { bool Lang::fileMatchesISO630Code(string uselanguage, string testLanguageFile) {

View File

@ -161,6 +161,20 @@ Renderer::Renderer() : BaseRenderer() {
//assert(0==1); //assert(0==1);
Renderer::rendererEnded = false; Renderer::rendererEnded = false;
shadowAlpha = 0;
shadowFrameSkip = 0;
triangleCount = 0;
smoothedRenderFps = 0;
shadowTextureSize = 0;
shadows = sDisabled;
shadowMapFrame = 0;
textures3D = false;
photoMode = false;
focusArrows = false;
pointCount = 0;
maxLights = 0;
waterAnim = 0;
this->allowRenderUnitTitles = false; this->allowRenderUnitTitles = false;
this->menu = NULL; this->menu = NULL;
this->game = NULL; this->game = NULL;
@ -246,7 +260,7 @@ void Renderer::cleanupScreenshotThread() {
if(saveScreenShotThread) { if(saveScreenShotThread) {
saveScreenShotThread->signalQuit(); saveScreenShotThread->signalQuit();
for(time_t elapsed = time(NULL); for(time_t elapsed = time(NULL);
getSaveScreenQueueSize() > 0 && difftime(time(NULL),elapsed) <= 7;) { getSaveScreenQueueSize() > 0 && difftime((long int)time(NULL),elapsed) <= 7;) {
sleep(0); sleep(0);
} }
if(saveScreenShotThread->canShutdown(true) == true && if(saveScreenShotThread->canShutdown(true) == true &&
@ -870,7 +884,7 @@ Font3D *Renderer::newFont3D(ResourceScope rs){
return fontManager[rs]->newFont3D(); return fontManager[rs]->newFont3D();
} }
void Renderer::endFont(Font *font, ResourceScope rs, bool mustExistInList) { void Renderer::endFont(Shared::Graphics::Font *font, ResourceScope rs, bool mustExistInList) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
return; return;
} }
@ -1633,7 +1647,7 @@ void Renderer::computeVisibleQuad() {
visibleQuad.p[3].x,visibleQuad.p[3].y); visibleQuad.p[3].x,visibleQuad.p[3].y);
} }
} }
catch(PROJECTION_TO_INFINITY e) { catch(PROJECTION_TO_INFINITY &e) {
if(debug) printf("hmm staring at the horizon %d\n",(int)e); if(debug) printf("hmm staring at the horizon %d\n",(int)e);
// use historic code solution // use historic code solution
visibleQuad = this->gameCamera->computeVisibleQuad(); visibleQuad = this->gameCamera->computeVisibleQuad();
@ -2551,7 +2565,7 @@ void Renderer::renderTextBoundingBox3D(const string &text, Font3D *font,
for(int i = 0; i < useWidth; ++i) { for(int i = 0; i < useWidth; ++i) {
temp += DEFAULT_CHAR_FOR_WIDTH_CALC; temp += DEFAULT_CHAR_FOR_WIDTH_CALC;
} }
float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Font::scaleFontValue); float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Shared::Graphics::Font::scaleFontValue);
useWidth = (int)lineWidth; useWidth = (int)lineWidth;
maxEditWidth = useWidth; maxEditWidth = useWidth;
@ -2622,7 +2636,7 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
throw megaglest_runtime_error("font->getTextHandler() == NULL (5)"); throw megaglest_runtime_error("font->getTextHandler() == NULL (5)");
} }
float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * Font::scaleFontValue); float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * Shared::Graphics::Font::scaleFontValue);
if(lineWidth < w) { if(lineWidth < w) {
pos.x += ((w / 2.f) - (lineWidth / 2.f)); pos.x += ((w / 2.f) - (lineWidth / 2.f));
} }
@ -2638,7 +2652,7 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
//const Metrics &metrics= Metrics::getInstance(); //const Metrics &metrics= Metrics::getInstance();
//float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue); //float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue);
float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Font::scaleFontValue); float lineHeight = (font->getTextHandler()->LineHeight(text.c_str()) * Shared::Graphics::Font::scaleFontValue);
//lineHeight=metrics.toVirtualY(lineHeight); //lineHeight=metrics.toVirtualY(lineHeight);
//lineHeight= lineHeight / (2.f + 0.2f * FontMetrics::DEFAULT_Y_OFFSET_FACTOR); //lineHeight= lineHeight / (2.f + 0.2f * FontMetrics::DEFAULT_Y_OFFSET_FACTOR);
//pos.y += (h / 2.f) - (lineHeight / 2.f); //pos.y += (h / 2.f) - (lineHeight / 2.f);
@ -2651,7 +2665,7 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
//if(Font::forceFTGLFonts == true) { //if(Font::forceFTGLFonts == true) {
// First go to top of bounding box // First go to top of bounding box
pos.y += (h - lineHeight); pos.y += (h - lineHeight);
pos.y -= ((h - lineHeight) / Font::scaleFontValueCenterHFactor); pos.y -= ((h - lineHeight) / Shared::Graphics::Font::scaleFontValueCenterHFactor);
// } // }
// else { // else {
// pos.y += (float)(((float)h) / 2.0); // pos.y += (float)(((float)h) / 2.0);
@ -2702,7 +2716,7 @@ void Renderer::renderTextBoundingBox3D(const string &text, Font3D *font,
for(int i = 0; i < useWidth; ++i) { for(int i = 0; i < useWidth; ++i) {
temp += DEFAULT_CHAR_FOR_WIDTH_CALC; temp += DEFAULT_CHAR_FOR_WIDTH_CALC;
} }
float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Font::scaleFontValue); float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Shared::Graphics::Font::scaleFontValue);
useWidth = (int)lineWidth; useWidth = (int)lineWidth;
maxEditWidth = useWidth; maxEditWidth = useWidth;
@ -2784,7 +2798,7 @@ void Renderer::renderTextBoundingBox3D(const string &text, Font3D *font,
for(int i = 0; i < useWidth; ++i) { for(int i = 0; i < useWidth; ++i) {
temp += DEFAULT_CHAR_FOR_WIDTH_CALC; temp += DEFAULT_CHAR_FOR_WIDTH_CALC;
} }
float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Font::scaleFontValue); float lineWidth = (font->getTextHandler()->Advance(temp.c_str()) * Shared::Graphics::Font::scaleFontValue);
useWidth = (int)lineWidth; useWidth = (int)lineWidth;
maxEditWidth = useWidth; maxEditWidth = useWidth;
@ -5261,6 +5275,7 @@ void Renderer::renderSelectionEffects() {
break; break;
default: default:
arrowColor= Vec3f(1.f, 1.f, 0.f); arrowColor= Vec3f(1.f, 1.f, 0.f);
break;
} }
//arrow target //arrow target

View File

@ -366,7 +366,7 @@ private:
vbo_vertices(0), vbo_normals(0), vbo_vertices(0), vbo_normals(0),
vbo_fowTexCoords(0), vbo_surfTexCoords(0), vbo_fowTexCoords(0), vbo_surfTexCoords(0),
vbo_indices(0), indexCount(0), vbo_indices(0), indexCount(0),
textureHandle(th) {} textureHandle(th),textureCRC(0) {}
~Layer(); ~Layer();
void load_vbos(bool vboEnabled); void load_vbos(bool vboEnabled);
void render(VisibleQuadContainerCache &qCache); void render(VisibleQuadContainerCache &qCache);
@ -444,7 +444,7 @@ public:
Texture3D *newTexture3D(ResourceScope rs); Texture3D *newTexture3D(ResourceScope rs);
Font2D *newFont(ResourceScope rs); Font2D *newFont(ResourceScope rs);
Font3D *newFont3D(ResourceScope rs); Font3D *newFont3D(ResourceScope rs);
void endFont(Font *font, ResourceScope rs, bool mustExistInList=false); void endFont(Shared::Graphics::Font *font, ResourceScope rs, bool mustExistInList=false);
void resetFontManager(ResourceScope rs); void resetFontManager(ResourceScope rs);
inline TextRenderer2D *getTextRenderer() const {return textRenderer;} inline TextRenderer2D *getTextRenderer() const {return textRenderer;}

View File

@ -314,6 +314,7 @@ void BattleEnd::render() {
default: default:
printf("Error control = %d for i = %d\n",stats.getControl(i),i); printf("Error control = %d for i = %d\n",stats.getControl(i),i);
assert(false); assert(false);
break;
}; };
} }

View File

@ -103,7 +103,7 @@ static bool gameInitialized = false;
static Program *mainProgram = NULL; static Program *mainProgram = NULL;
static FileCRCPreCacheThread *preCacheThread = NULL; static FileCRCPreCacheThread *preCacheThread = NULL;
static string runtimeErrorMsg = ""; //static string runtimeErrorMsg = "";
void cleanupCRCThread() { void cleanupCRCThread() {
if(preCacheThread != NULL) { if(preCacheThread != NULL) {
@ -114,14 +114,14 @@ void cleanupCRCThread() {
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
preCacheThread->signalQuit(); preCacheThread->signalQuit();
for(;preCacheThread->canShutdown(false) == false && for(;preCacheThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= MAX_THREAD_WAIT;) { difftime((long int)time(NULL),elapsed) <= MAX_THREAD_WAIT;) {
//sleep(150); //sleep(150);
} }
if(difftime(time(NULL),elapsed) <= MAX_THREAD_WAIT) { if(difftime((long int)time(NULL),elapsed) <= MAX_THREAD_WAIT) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("B - shutting down crc threads\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("B - shutting down crc threads\n");
for(;preCacheThread->shutdownAndWait() == false && for(;preCacheThread->shutdownAndWait() == false &&
difftime(time(NULL),elapsed) <= MAX_THREAD_WAIT;) { difftime((long int)time(NULL),elapsed) <= MAX_THREAD_WAIT;) {
} }
if(preCacheThread->getRunningStatus() == false) { if(preCacheThread->getRunningStatus() == false) {
delete preCacheThread; delete preCacheThread;
@ -173,7 +173,7 @@ static void cleanupProcessObjects() {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("start running threads = %lu\n",Thread::getThreadList().size()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("start running threads = %lu\n",Thread::getThreadList().size());
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
for(;Thread::getThreadList().size() > 0 && for(;Thread::getThreadList().size() > 0 &&
difftime(time(NULL),elapsed) <= 10;) { difftime((long int)time(NULL),elapsed) <= 10;) {
//sleep(0); //sleep(0);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = %lu\n",Thread::getThreadList().size()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("end running threads = %lu\n",Thread::getThreadList().size());
@ -405,7 +405,7 @@ public:
if(glActiveTexture != NULL) { if(glActiveTexture != NULL) {
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
//program->getState()->render(); //program->getState()->render();
Window::handleEvent(); Shared::Platform::Window::handleEvent();
mainProgram->loop(); mainProgram->loop();
//printf("\nhandle error #1\n"); //printf("\nhandle error #1\n");
@ -420,7 +420,7 @@ public:
if(glActiveTexture != NULL) { if(glActiveTexture != NULL) {
for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) { for(;GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false && mainProgram->isMessageShowing();) {
//program->renderProgramMsgBox(); //program->renderProgramMsgBox();
Window::handleEvent(); Shared::Platform::Window::handleEvent();
mainProgram->loop(); mainProgram->loop();
//printf("\nhandle error #2\n"); //printf("\nhandle error #2\n");
@ -891,9 +891,9 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) {
renderer.setShowDebugUI(!showDebugUI); renderer.setShowDebugUI(!showDebugUI);
} }
} }
else if(keystate.mod & (KMOD_LCTRL | KMOD_RCTRL) && else if((keystate.mod & (KMOD_LCTRL | KMOD_RCTRL)) &&
isKeyPressed(configKeys.getSDLKey("SwitchLanguage"),key) == true) { isKeyPressed(configKeys.getSDLKey("SwitchLanguage"),key) == true) {
if(keystate.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { if((keystate.mod & (KMOD_LSHIFT | KMOD_RSHIFT))) {
//toggleLanguage(""); //toggleLanguage("");
this->triggerLanguageToggle = true; this->triggerLanguageToggle = true;
this->triggerLanguage = ""; this->triggerLanguage = "";
@ -3333,7 +3333,7 @@ int glestMain(int argc, char** argv) {
} }
if(config.getBool("ForceFTGLFonts","false") == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_FORCE_FTGLFONTS]) == true) { if(config.getBool("ForceFTGLFonts","false") == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_FORCE_FTGLFONTS]) == true) {
Font::forceFTGLFonts = true; Shared::Graphics::Font::forceFTGLFonts = true;
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n"); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n");
printf("**WARNING** Forcing use of FTGL Fonts\n"); printf("**WARNING** Forcing use of FTGL Fonts\n");
} }
@ -3342,7 +3342,7 @@ int glestMain(int argc, char** argv) {
} }
if(config.getBool("EnableLegacyFonts","false") == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_ENABLE_LEGACYFONTS]) == true) { if(config.getBool("EnableLegacyFonts","false") == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_ENABLE_LEGACYFONTS]) == true) {
Font::forceLegacyFonts = true; Shared::Graphics::Font::forceLegacyFonts = true;
Renderer::renderText3DEnabled = false; Renderer::renderText3DEnabled = false;
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n"); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**WARNING** Forcing Legacy Fonts Enabled\n");
printf("**WARNING** Forcing Legacy Fonts Enabled\n"); printf("**WARNING** Forcing Legacy Fonts Enabled\n");
@ -3494,14 +3494,14 @@ int glestMain(int argc, char** argv) {
// 256 for English // 256 for English
// 30000 for Chinese // 30000 for Chinese
Font::charCount = config.getInt("FONT_CHARCOUNT",intToStr(Font::charCount).c_str()); Shared::Graphics::Font::charCount = config.getInt("FONT_CHARCOUNT",intToStr(Shared::Graphics::Font::charCount).c_str());
Font::fontTypeName = config.getString("FONT_TYPENAME",Font::fontTypeName.c_str()); Shared::Graphics::Font::fontTypeName = config.getString("FONT_TYPENAME",Shared::Graphics::Font::fontTypeName.c_str());
Font::fontIsMultibyte = config.getBool("FONT_MULTIBYTE",intToStr(Font::fontIsMultibyte).c_str()); Shared::Graphics::Font::fontIsMultibyte = config.getBool("FONT_MULTIBYTE",intToStr(Shared::Graphics::Font::fontIsMultibyte).c_str());
Font::fontIsRightToLeft = config.getBool("FONT_RIGHTTOLEFT",intToStr(Font::fontIsRightToLeft).c_str()); Shared::Graphics::Font::fontIsRightToLeft = config.getBool("FONT_RIGHTTOLEFT",intToStr(Shared::Graphics::Font::fontIsRightToLeft).c_str());
Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Font::baseSize).c_str()); Shared::Graphics::Font::baseSize = config.getInt("FONT_BASE_SIZE",intToStr(Shared::Graphics::Font::baseSize).c_str());
Font::scaleFontValue = config.getFloat("FONT_SCALE_SIZE",floatToStr(Font::scaleFontValue).c_str()); Shared::Graphics::Font::scaleFontValue = config.getFloat("FONT_SCALE_SIZE",floatToStr(Shared::Graphics::Font::scaleFontValue).c_str());
Font::scaleFontValueCenterHFactor = config.getFloat("FONT_SCALE_CENTERH_FACTOR",floatToStr(Font::scaleFontValueCenterHFactor).c_str()); Shared::Graphics::Font::scaleFontValueCenterHFactor = config.getFloat("FONT_SCALE_CENTERH_FACTOR",floatToStr(Shared::Graphics::Font::scaleFontValueCenterHFactor).c_str());
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str()); Shared::Graphics::Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Shared::Graphics::Font::langHeightText.c_str());
// Example values: // Example values:
// DEFAULT_CHARSET (English) = 1 // DEFAULT_CHARSET (English) = 1
@ -3514,8 +3514,8 @@ int glestMain(int argc, char** argv) {
SystemFlags::DEFAULT_HTTP_TIMEOUT = config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str()); SystemFlags::DEFAULT_HTTP_TIMEOUT = config.getInt("DEFAULT_HTTP_TIMEOUT",intToStr(SystemFlags::DEFAULT_HTTP_TIMEOUT).c_str());
} }
bool allowAltEnterFullscreenToggle = config.getBool("AllowAltEnterFullscreenToggle",boolToStr(Window::getAllowAltEnterFullscreenToggle()).c_str()); bool allowAltEnterFullscreenToggle = config.getBool("AllowAltEnterFullscreenToggle",boolToStr(Shared::Platform::Window::getAllowAltEnterFullscreenToggle()).c_str());
Window::setAllowAltEnterFullscreenToggle(allowAltEnterFullscreenToggle); Shared::Platform::Window::setAllowAltEnterFullscreenToggle(allowAltEnterFullscreenToggle);
if(config.getBool("noTeamColors","false") == true) { if(config.getBool("noTeamColors","false") == true) {
MeshCallbackTeamColor::noTeamColors = true; MeshCallbackTeamColor::noTeamColors = true;
@ -3524,7 +3524,7 @@ int glestMain(int argc, char** argv) {
// Setup debug logging etc // Setup debug logging etc
setupLogging(config, haveSpecialOutputCommandLineOption); setupLogging(config, haveSpecialOutputCommandLineOption);
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Font::charCount,Font::fontTypeName.c_str(),Shared::Platform::charSet,Font::fontIsMultibyte, Font::fontIsRightToLeft); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte, Shared::Graphics::Font::fontIsRightToLeft);
NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage); NetworkInterface::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
MenuStateMasterserver::setDisplayMessageFunction(ExceptionHandler::DisplayMessage); MenuStateMasterserver::setDisplayMessageFunction(ExceptionHandler::DisplayMessage);
@ -3560,7 +3560,7 @@ int glestMain(int argc, char** argv) {
} }
if(config.getBool("EnableVSynch","false") == true) { if(config.getBool("EnableVSynch","false") == true) {
Window::setTryVSynch(true); Shared::Platform::Window::setTryVSynch(true);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**ENABLED OPENGL VSYNCH**\n"); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("**ENABLED OPENGL VSYNCH**\n");
} }
@ -3671,7 +3671,7 @@ int glestMain(int argc, char** argv) {
lang.loadStrings(language,false, true); lang.loadStrings(language,false, true);
if( lang.hasString("FONT_HEIGHT_TEXT")) { if( lang.hasString("FONT_HEIGHT_TEXT")) {
Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Font::langHeightText.c_str()); Shared::Graphics::Font::langHeightText = config.getString("FONT_HEIGHT_TEXT",Shared::Graphics::Font::langHeightText.c_str());
} }
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_FONT_BASESIZE]) == true) { if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_FONT_BASESIZE]) == true) {
@ -3688,7 +3688,7 @@ int glestMain(int argc, char** argv) {
//printf("#1 Forcing font [%s] paramPartTokens.size() = %d, paramValue [%s]\n",newfont.c_str(),paramPartTokens.size(),paramValue.c_str()); //printf("#1 Forcing font [%s] paramPartTokens.size() = %d, paramValue [%s]\n",newfont.c_str(),paramPartTokens.size(),paramValue.c_str());
printf("Forcing font base size[%s]\n",newfontBaseSize.c_str()); printf("Forcing font base size[%s]\n",newfontBaseSize.c_str());
Font::baseSize = strToInt(newfontBaseSize); Shared::Graphics::Font::baseSize = strToInt(newfontBaseSize);
} }
else { else {
printf("\nInvalid missing font base size specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); printf("\nInvalid missing font base size specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL));
@ -3698,8 +3698,8 @@ int glestMain(int argc, char** argv) {
} }
} }
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Font::charCount,Font::fontTypeName.c_str(),Shared::Platform::charSet,Font::fontIsMultibyte,Font::fontIsRightToLeft); SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",Font::charCount,Font::fontTypeName.c_str(),Shared::Platform::charSet,Font::fontIsMultibyte,Font::fontIsRightToLeft); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",Shared::Graphics::Font::charCount,Shared::Graphics::Font::fontTypeName.c_str(),Shared::Platform::charSet,Shared::Graphics::Font::fontIsMultibyte,Shared::Graphics::Font::fontIsRightToLeft);
if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_FONT]) == true) { if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_FONT]) == true) {
int foundParamIndIndex = -1; int foundParamIndIndex = -1;
@ -4466,7 +4466,7 @@ int glestMain(int argc, char** argv) {
} }
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
int result = 0; int result = 0;
@ -4497,7 +4497,7 @@ int glestMain(int argc, char** argv) {
renderer.swapBuffers(); renderer.swapBuffers();
sleep(0); sleep(0);
Window::handleEvent(); Shared::Platform::Window::handleEvent();
SDL_PumpEvents(); SDL_PumpEvents();
Model *model = renderer.newModel(rsGlobal); Model *model = renderer.newModel(rsGlobal);
@ -4618,7 +4618,7 @@ int glestMain(int argc, char** argv) {
//throw megaglest_runtime_error("Test!"); //throw megaglest_runtime_error("Test!");
//main loop //main loop
while(program->isShutdownApplicationEnabled() == false && Window::handleEvent()) { while(program->isShutdownApplicationEnabled() == false && Shared::Platform::Window::handleEvent()) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
if(disableheadless_console == false) { if(disableheadless_console == false) {

View File

@ -161,7 +161,7 @@ private:
public: public:
Program(); Program();
~Program(); virtual ~Program();
static Program *getInstance() {return singleton;} static Program *getInstance() {return singleton;}

View File

@ -1070,7 +1070,7 @@ void MenuStateConnectedGame::broadCastGameSettingsToHeadlessServer(bool forceNow
} }
if(forceNow == true || if(forceNow == true ||
((needToBroadcastServerSettings == true ) && ( difftime(time(NULL),broadcastServerSettingsDelayTimer) >= HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS))) { ((needToBroadcastServerSettings == true ) && ( difftime((long int)time(NULL),broadcastServerSettingsDelayTimer) >= HEADLESSSERVER_BROADCAST_SETTINGS_SECONDS))) {
//printf("In [%s:%s] Line: %d forceNow = %d broadcastServerSettingsDelayTimer = %lu, now =%lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,forceNow,broadcastServerSettingsDelayTimer,time(NULL)); //printf("In [%s:%s] Line: %d forceNow = %d broadcastServerSettingsDelayTimer = %lu, now =%lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,forceNow,broadcastServerSettingsDelayTimer,time(NULL));
needToBroadcastServerSettings = false; needToBroadcastServerSettings = false;
@ -1800,7 +1800,7 @@ void MenuStateConnectedGame::render() {
clientInterface->getGameSettings()->getMasterserver_admin() > 0 && clientInterface->getGameSettings()->getMasterserver_admin() > 0 &&
clientInterface->getGameSettings()->getMasterserver_admin_faction_index() == i) { clientInterface->getGameSettings()->getMasterserver_admin_faction_index() == i) {
if(difftime(time(NULL),timerLabelFlash) < 1) { if(difftime((long int)time(NULL),timerLabelFlash) < 1) {
renderer.renderLabel(&labelPlayers[i],&playerColor); renderer.renderLabel(&labelPlayers[i],&playerColor);
} }
else { else {
@ -1858,7 +1858,7 @@ void MenuStateConnectedGame::render() {
renderer.renderLabel(&labelStatus); renderer.renderLabel(&labelStatus);
renderer.renderLabel(&labelInfo); renderer.renderLabel(&labelInfo);
if(difftime(time(NULL),timerLabelFlash) < 1) { if(difftime((long int)time(NULL),timerLabelFlash) < 1) {
renderer.renderLabel(&labelDataSynchInfo,&RED); renderer.renderLabel(&labelDataSynchInfo,&RED);
} }
else { else {
@ -1962,7 +1962,7 @@ void MenuStateConnectedGame::render() {
renderer.renderChatManager(&chatManager); renderer.renderChatManager(&chatManager);
renderer.renderConsole(&console,showFullConsole,true); renderer.renderConsole(&console,showFullConsole,true);
if(difftime(time(NULL),timerLabelFlash) > 2) { if(difftime((long int)time(NULL),timerLabelFlash) > 2) {
timerLabelFlash = time(NULL); timerLabelFlash = time(NULL);
} }
} }
@ -2012,11 +2012,11 @@ void MenuStateConnectedGame::update() {
} }
} }
if(difftime(time(NULL),lastNetworkSendPing) >= GameConstants::networkPingInterval) { if(difftime((long int)time(NULL),lastNetworkSendPing) >= GameConstants::networkPingInterval) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to sendPingMessage...\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to sendPingMessage...\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
lastNetworkSendPing = time(NULL); lastNetworkSendPing = time(NULL);
clientInterface->sendPingMessage(GameConstants::networkPingInterval, time(NULL)); clientInterface->sendPingMessage(GameConstants::networkPingInterval, (int64)time(NULL));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pingCount = %d, clientInterface->getLastPingLag() = %f, GameConstants::networkPingInterval = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,pingCount, clientInterface->getLastPingLag(),GameConstants::networkPingInterval); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pingCount = %d, clientInterface->getLastPingLag() = %f, GameConstants::networkPingInterval = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,pingCount, clientInterface->getLastPingLag(),GameConstants::networkPingInterval);
@ -2101,7 +2101,7 @@ void MenuStateConnectedGame::update() {
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 1; const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 1;
if( lastUpdateDate <= 0 || if( lastUpdateDate <= 0 ||
difftime(time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS) { difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS) {
techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL, true); techCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), string("/") + gameSettings->getTech() + string("/*"), ".xml", NULL, true);
//clientInterface->sendTextMessage("#3 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(gameSettings->getTechCRC()),-1, true, ""); //clientInterface->sendTextMessage("#3 TechCRC = " + intToStr(techCRC) + " remoteCRC = " + intToStr(gameSettings->getTechCRC()),-1, true, "");
} }
@ -2126,7 +2126,7 @@ void MenuStateConnectedGame::update() {
const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 24; const time_t REFRESH_CRC_DAY_SECONDS = 60 * 60 * 24;
if( lastUpdateDate <= 0 || if( lastUpdateDate <= 0 ||
difftime(time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS || difftime((long int)time(NULL),lastUpdateDate) >= REFRESH_CRC_DAY_SECONDS ||
(techCRC != 0 && techCRC != gameSettings->getTechCRC())) { (techCRC != 0 && techCRC != gameSettings->getTechCRC())) {
factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true); factionCRC = getFolderTreeContentsCheckSumRecursively(config.getPathListForType(ptTechs,""), "/" + gameSettings->getTech() + "/factions/" + factionName + "/*", ".xml", NULL, true);
} }

View File

@ -31,6 +31,7 @@
#include <iterator> #include <iterator>
#include "map_preview.h" #include "map_preview.h"
#include "string_utils.h" #include "string_utils.h"
#include "network_message.h"
#include "leak_dumper.h" #include "leak_dumper.h"
namespace Glest{ namespace Game{ namespace Glest{ namespace Game{
@ -252,7 +253,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu,
listBoxTileset.init(xoffset+460, mapPos, 150); listBoxTileset.init(xoffset+460, mapPos, 150);
//listBoxTileset.setItems(results); //listBoxTileset.setItems(results);
setupTilesetList(""); setupTilesetList("");
srand(time(NULL)); srand((unsigned int)time(NULL));
listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount()); listBoxTileset.setSelectedItemIndex(rand() % listBoxTileset.getItemCount());
//tech Tree listBox //tech Tree listBox
@ -903,7 +904,7 @@ void MenuStateCustomGame::cleanup() {
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
publishToMasterserverThread->signalQuit(); publishToMasterserverThread->signalQuit();
for(;publishToMasterserverThread->canShutdown(false) == false && for(;publishToMasterserverThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) { difftime((long int)time(NULL),elapsed) <= 15;) {
//sleep(150); //sleep(150);
} }
if(publishToMasterserverThread->canShutdown(true)) { if(publishToMasterserverThread->canShutdown(true)) {
@ -1273,7 +1274,7 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton) {
int slotsToChangeStart = i; int slotsToChangeStart = i;
int slotsToChangeEnd = i; int slotsToChangeEnd = i;
// If control is pressed while changing player types then change all other slots to same type // If control is pressed while changing player types then change all other slots to same type
if(Window::isKeyStateModPressed(KMOD_CTRL) == true) { if(Shared::Platform::Window::isKeyStateModPressed(KMOD_CTRL) == true) {
slotsToChangeStart = 0; slotsToChangeStart = 0;
slotsToChangeEnd = mapInfo.players-1; slotsToChangeEnd = mapInfo.players-1;
} }
@ -1561,7 +1562,7 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
// Max 1000 tries to get a random, unused faction // Max 1000 tries to get a random, unused faction
for(int findRandomFaction = 1; findRandomFaction < 1000; ++findRandomFaction) { for(int findRandomFaction = 1; findRandomFaction < 1000; ++findRandomFaction) {
srand(time(NULL) + findRandomFaction); srand((unsigned int)time(NULL) + findRandomFaction);
int selectedFactionIndex = rand() % listBoxFactions[i].getItemCount(); int selectedFactionIndex = rand() % listBoxFactions[i].getItemCount();
string selectedFactionName = listBoxFactions[i].getItem(selectedFactionIndex); string selectedFactionName = listBoxFactions[i].getItem(selectedFactionIndex);
@ -2196,7 +2197,7 @@ void MenuStateCustomGame::update() {
if(needToLoadTextures) { if(needToLoadTextures) {
// this delay is done to make it possible to switch faster // this delay is done to make it possible to switch faster
if(difftime(time(NULL), previewLoadDelayTimer) >= 2){ if(difftime((long int)time(NULL), previewLoadDelayTimer) >= 2){
//loadScenarioPreviewTexture(); //loadScenarioPreviewTexture();
needToLoadTextures= false; needToLoadTextures= false;
} }
@ -2501,7 +2502,7 @@ void MenuStateCustomGame::update() {
bool checkDataSynch = (serverInterface->getAllowGameDataSynchCheck() == true && bool checkDataSynch = (serverInterface->getAllowGameDataSynchCheck() == true &&
needToSetChangedGameSettings == true && needToSetChangedGameSettings == true &&
(( difftime(time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS)|| (( difftime((long int)time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS)||
(this->headlessServerMode == true))); (this->headlessServerMode == true)));
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took msecs: %lld\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,chrono.getMillis());
@ -2558,7 +2559,7 @@ void MenuStateCustomGame::update() {
//listBoxEnableServerControlledAI.setEditable(false); //listBoxEnableServerControlledAI.setEditable(false);
} }
bool republishToMaster = (difftime(time(NULL),lastMasterserverPublishing) >= MASTERSERVER_BROADCAST_PUBLISH_SECONDS); bool republishToMaster = (difftime((long int)time(NULL),lastMasterserverPublishing) >= MASTERSERVER_BROADCAST_PUBLISH_SECONDS);
if(republishToMaster == true) { if(republishToMaster == true) {
if(listBoxPublishServer.getSelectedItemIndex() == 0) { if(listBoxPublishServer.getSelectedItemIndex() == 0) {
@ -2580,7 +2581,7 @@ void MenuStateCustomGame::update() {
} }
if(needToPublishDelayed) { if(needToPublishDelayed) {
// this delay is done to make it possible to switch over maps which are not meant to be distributed // this delay is done to make it possible to switch over maps which are not meant to be distributed
if((difftime(time(NULL), mapPublishingDelayTimer) >= BROADCAST_MAP_DELAY_SECONDS) || if((difftime((long int)time(NULL), mapPublishingDelayTimer) >= BROADCAST_MAP_DELAY_SECONDS) ||
(this->headlessServerMode == true) ){ (this->headlessServerMode == true) ){
// after 5 seconds we are allowed to publish again! // after 5 seconds we are allowed to publish again!
needToSetChangedGameSettings = true; needToSetChangedGameSettings = true;
@ -2590,7 +2591,7 @@ void MenuStateCustomGame::update() {
} }
} }
if(needToPublishDelayed == false || headlessServerMode == true) { if(needToPublishDelayed == false || headlessServerMode == true) {
bool broadCastSettings = (difftime(time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS); bool broadCastSettings = (difftime((long int)time(NULL),lastSetChangedGameSettings) >= BROADCAST_SETTINGS_SECONDS);
//printf("broadCastSettings = %d\n",broadCastSettings); //printf("broadCastSettings = %d\n",broadCastSettings);
@ -2885,7 +2886,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
hasClientConnection = serverInterface->hasClientConnection(); hasClientConnection = serverInterface->hasClientConnection();
} }
} }
bool needPing = (difftime(time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval); bool needPing = (difftime((long int)time(NULL),lastNetworkPing) >= GameConstants::networkPingInterval);
if(callingThread->getQuitStatus() == true) { if(callingThread->getQuitStatus() == true) {
return; return;
@ -2940,7 +2941,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
// Give things another chance to see if we can get a connection from the master server // Give things another chance to see if we can get a connection from the master server
if(tMasterserverErrorElapsed > 0 && if(tMasterserverErrorElapsed > 0 &&
difftime(time(NULL),tMasterserverErrorElapsed) > MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS) { difftime((long int)time(NULL),tMasterserverErrorElapsed) > MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS) {
showMasterserverError=true; showMasterserverError=true;
masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply"); masterServererErrorToShow = (serverInfo != "" ? serverInfo : "No Reply");
} }
@ -2950,7 +2951,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) {
} }
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error checking response from masterserver elapsed seconds = %.2f / %d\nResponse:\n%s\n", SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line %d] error checking response from masterserver elapsed seconds = %.2f / %d\nResponse:\n%s\n",
extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,difftime(time(NULL),tMasterserverErrorElapsed),MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS,serverInfo.c_str()); extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,difftime((long int)time(NULL),tMasterserverErrorElapsed),MASTERSERVER_BROADCAST_MAX_WAIT_RESPONSE_SECONDS,serverInfo.c_str());
needToRepublishToMasterserver = true; needToRepublishToMasterserver = true;
} }

View File

@ -77,7 +77,7 @@ void ClientInterface::shutdownNetworkCommandListThread() {
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
networkCommandListThread->signalQuit(); networkCommandListThread->signalQuit();
for(;networkCommandListThread->canShutdown(false) == false && for(;networkCommandListThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) { difftime((long int)time(NULL),elapsed) <= 15;) {
//sleep(150); //sleep(150);
} }
if(networkCommandListThread->canShutdown(true)) { if(networkCommandListThread->canShutdown(true)) {
@ -168,7 +168,7 @@ void ClientInterface::update() {
} }
} }
double lastSendElapsed = difftime(time(NULL),lastNetworkCommandListSendTime); double lastSendElapsed = difftime((long int)time(NULL),lastNetworkCommandListSendTime);
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -583,8 +583,8 @@ void ClientInterface::updateLobby() {
} }
if( clientSocket != NULL && clientSocket->isConnected() == true && if( clientSocket != NULL && clientSocket->isConnected() == true &&
gotIntro == false && difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) { gotIntro == false && difftime((long int)time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] difftime(time(NULL),connectedTime) = %f\n",__FILE__,__FUNCTION__,__LINE__,difftime(time(NULL),connectedTime)); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] difftime(time(NULL),connectedTime) = %f\n",__FILE__,__FUNCTION__,__LINE__,difftime((long int)time(NULL),connectedTime));
close(); close();
} }
} }
@ -605,7 +605,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
if(clientSimulationLagStartTime == 0) { if(clientSimulationLagStartTime == 0) {
clientSimulationLagStartTime = time(NULL); clientSimulationLagStartTime = time(NULL);
} }
if(difftime(time(NULL),clientSimulationLagStartTime) <= Config::getInstance().getInt("SimulateClientLagDurationSeconds","0")) { if(difftime((long int)time(NULL),clientSimulationLagStartTime) <= Config::getInstance().getInt("SimulateClientLagDurationSeconds","0")) {
sleep(Config::getInstance().getInt("SimulateClientLag","0")); sleep(Config::getInstance().getInt("SimulateClientLag","0"));
} }
} }
@ -820,6 +820,7 @@ void ClientInterface::updateFrame(int *checkFrame) {
close(); close();
done= true; done= true;
} }
break;
} }
if(isConnected() == false && quit == true) { if(isConnected() == false && quit == true) {
@ -1138,7 +1139,7 @@ void ClientInterface::waitUntilReady(Checksum* checksum) {
return; return;
} }
Window::handleEvent(); Shared::Platform::Window::handleEvent();
// sleep a bit // sleep a bit
sleep(waitSleepTime); sleep(waitSleepTime);
} }

View File

@ -243,6 +243,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d\n",__FILE__,__FUNCTION__,__LINE__);
this->mutexSocket = new Mutex(); this->mutexSocket = new Mutex();
this->socket = NULL;
this->mutexCloseConnection = new Mutex(); this->mutexCloseConnection = new Mutex();
this->mutexPendingNetworkCommandList = new Mutex(); this->mutexPendingNetworkCommandList = new Mutex();
this->socketSynchAccessor = new Mutex(); this->socketSynchAccessor = new Mutex();
@ -452,7 +453,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(this->isConnected() == true) { if(this->isConnected() == true) {
//RandomGen random; //RandomGen random;
//sessionKey = random.randRange(-100000, 100000); //sessionKey = random.randRange(-100000, 100000);
srand(time(NULL) / (this->playerIndex + 1)); srand((unsigned int)time(NULL) / (this->playerIndex + 1));
sessionKey = rand() % 1000000; sessionKey = rand() % 1000000;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] accepted new client connection, serverInterface->getOpenSlotCount() = %d, sessionKey = %d\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getOpenSlotCount(),sessionKey); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] accepted new client connection, serverInterface->getOpenSlotCount() = %d, sessionKey = %d\n",__FILE__,__FUNCTION__,__LINE__,serverInterface->getOpenSlotCount(),sessionKey);
@ -1143,11 +1144,11 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
double maxClientLagTimeAllowed = 8; double maxClientLagTimeAllowed = 8;
if(this->serverInterface->getGameStartTime() > 0 && if(this->serverInterface->getGameStartTime() > 0 &&
difftime(time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),this->serverInterface->getGameStartTime()) >= LAG_CHECK_GRACE_PERIOD) {
if(this->isConnected() == true) { if(this->isConnected() == true) {
double clientLag = this->serverInterface->getCurrentFrameCount() - this->getCurrentFrameCount(); double clientLag = this->serverInterface->getCurrentFrameCount() - this->getCurrentFrameCount();
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0); double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
double clientLagTime = difftime(time(NULL),this->getLastReceiveCommandListTime()); double clientLagTime = difftime((long int)time(NULL),this->getLastReceiveCommandListTime());
// New lag check // New lag check
if((maxFrameCountLagAllowed > 0 && clientLagCount > maxFrameCountLagAllowed) || if((maxFrameCountLagAllowed > 0 && clientLagCount > maxFrameCountLagAllowed) ||
@ -1200,7 +1201,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
void ConnectionSlot::validateConnection() { void ConnectionSlot::validateConnection() {
if(this->isConnected() == true && if(this->isConnected() == true &&
gotIntro == false && connectedTime > 0 && gotIntro == false && connectedTime > 0 &&
difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) { difftime((long int)time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
close(); close();
} }
} }

View File

@ -67,6 +67,7 @@ public:
class ConnectionSlotCallbackInterface { class ConnectionSlotCallbackInterface {
public: public:
virtual void slotUpdateTask(ConnectionSlotEvent *event) = 0; virtual void slotUpdateTask(ConnectionSlotEvent *event) = 0;
virtual ~ConnectionSlotCallbackInterface() {}
}; };
class ConnectionSlotThread : public BaseThread class ConnectionSlotThread : public BaseThread

View File

@ -244,7 +244,7 @@ public:
NetworkMessagePing getLastPingInfo() const { return lastPingInfo; } NetworkMessagePing getLastPingInfo() const { return lastPingInfo; }
double getLastPingLag() const { double getLastPingLag() const {
return difftime(time(NULL),lastPingInfo.getPingReceivedLocalTime()); return difftime((long int)time(NULL),lastPingInfo.getPingReceivedLocalTime());
} }
std::string getIpAddress(); std::string getIpAddress();

View File

@ -136,6 +136,7 @@ NetworkMessagePing::NetworkMessagePing(int32 pingFrequency, int64 pingTime){
data.messageType= nmtPing; data.messageType= nmtPing;
data.pingFrequency= pingFrequency; data.pingFrequency= pingFrequency;
data.pingTime= pingTime; data.pingTime= pingTime;
pingReceivedLocalTime=0;
} }
bool NetworkMessagePing::receive(Socket* socket){ bool NetworkMessagePing::receive(Socket* socket){

View File

@ -103,7 +103,23 @@ private:
int32 unitCommandGroupId; int32 unitCommandGroupId;
public: public:
NetworkCommand(){}; NetworkCommand() {
networkCommandType=0;
unitId=0;
unitTypeId=0;
commandTypeId=0;
positionX=0;
positionY=0;
targetId=0;
wantQueue=0;
fromFactionIndex=0;
unitFactionUnitCount=0;
unitFactionIndex=0;
commandStateType=0;
commandStateValue=0;
unitCommandGroupId=0;
}
NetworkCommand( NetworkCommand(
World *world, World *world,
int networkCommandType, int networkCommandType,

View File

@ -219,7 +219,7 @@ void ServerInterface::shutdownMasterserverPublishThread() {
time_t elapsed = time(NULL); time_t elapsed = time(NULL);
publishToMasterserverThread->signalQuit(); publishToMasterserverThread->signalQuit();
for(;publishToMasterserverThread->canShutdown(false) == false && for(;publishToMasterserverThread->canShutdown(false) == false &&
difftime(time(NULL),elapsed) <= 15;) { difftime((long int)time(NULL),elapsed) <= 15;) {
//sleep(150); //sleep(150);
} }
if(publishToMasterserverThread->canShutdown(true)) { if(publishToMasterserverThread->canShutdown(true)) {
@ -658,13 +658,13 @@ std::pair<bool,bool> ServerInterface::clientLagCheck(ConnectionSlot *connectionS
alreadyInLagCheck = true; alreadyInLagCheck = true;
if(gameStartTime > 0 && if(gameStartTime > 0 &&
difftime(time(NULL),gameStartTime) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),gameStartTime) >= LAG_CHECK_GRACE_PERIOD) {
if(connectionSlot != NULL && connectionSlot->isConnected() == true) { if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
double clientLag = this->getCurrentFrameCount() - connectionSlot->getCurrentFrameCount(); double clientLag = this->getCurrentFrameCount() - connectionSlot->getCurrentFrameCount();
double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0); double clientLagCount = (gameSettings.getNetworkFramePeriod() > 0 ? (clientLag / gameSettings.getNetworkFramePeriod()) : 0);
connectionSlot->setCurrentLagCount(clientLagCount); connectionSlot->setCurrentLagCount(clientLagCount);
double clientLagTime = difftime(time(NULL),connectionSlot->getLastReceiveCommandListTime()); double clientLagTime = difftime((long int)time(NULL),connectionSlot->getLastReceiveCommandListTime());
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -869,7 +869,7 @@ void ServerInterface::checkForCompletedClients(std::map<int,bool> & mapSlotSigna
std::map<int,bool> slotsCompleted; std::map<int,bool> slotsCompleted;
for(bool threadsDone = false; for(bool threadsDone = false;
exitServer == false && threadsDone == false && exitServer == false && threadsDone == false &&
difftime(time(NULL),waitForThreadElapsed) < MAX_SLOT_THREAD_WAIT_TIME;) { difftime((long int)time(NULL),waitForThreadElapsed) < MAX_SLOT_THREAD_WAIT_TIME;) {
threadsDone = true; threadsDone = true;
// Examine all threads for completion of delegation // Examine all threads for completion of delegation
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
@ -932,7 +932,7 @@ void ServerInterface::checkForLaggingClients(std::map<int,bool> &mapSlotSignalle
std::map<int,bool> slotsWarnedList; std::map<int,bool> slotsWarnedList;
for(bool threadsDone = false; for(bool threadsDone = false;
exitServer == false && threadsDone == false && exitServer == false && threadsDone == false &&
difftime(time(NULL),waitForThreadElapsed) < MAX_SLOT_THREAD_WAIT_TIME;) { difftime((long int)time(NULL),waitForThreadElapsed) < MAX_SLOT_THREAD_WAIT_TIME;) {
threadsDone = true; threadsDone = true;
// Examine all threads for completion of delegation // Examine all threads for completion of delegation
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
@ -978,9 +978,9 @@ void ServerInterface::checkForLaggingClients(std::map<int,bool> &mapSlotSignalle
if((clientLagExceededOrWarned.first == true && gameSettings.getNetworkPauseGameForLaggedClients() == true)) { // || if((clientLagExceededOrWarned.first == true && gameSettings.getNetworkPauseGameForLaggedClients() == true)) { // ||
//(clientLagExceededOrWarned.second == true && slotsWarnedAndRetried[i] == false)) { //(clientLagExceededOrWarned.second == true && slotsWarnedAndRetried[i] == false)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, clientLagExceededOrWarned.first = %d, clientLagExceededOrWarned.second = %d, difftime(time(NULL),waitForClientsElapsed) = %.2f, MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE = %.2f\n",__FILE__,__FUNCTION__,__LINE__,clientLagExceededOrWarned.first,clientLagExceededOrWarned.second,difftime(time(NULL),waitForClientsElapsed),MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, clientLagExceededOrWarned.first = %d, clientLagExceededOrWarned.second = %d, difftime(time(NULL),waitForClientsElapsed) = %.2f, MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE = %.2f\n",__FILE__,__FUNCTION__,__LINE__,clientLagExceededOrWarned.first,clientLagExceededOrWarned.second,difftime((long int)time(NULL),waitForClientsElapsed),MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE);
if(difftime(time(NULL),waitForClientsElapsed) < MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE) { if(difftime((long int)time(NULL),waitForClientsElapsed) < MAX_CLIENT_WAIT_SECONDS_FOR_PAUSE) {
if(connectionSlot != NULL) { if(connectionSlot != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, clientLagExceededOrWarned.first = %d, clientLagExceededOrWarned.second = %d\n",__FILE__,__FUNCTION__,__LINE__,clientLagExceededOrWarned.first,clientLagExceededOrWarned.second); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, clientLagExceededOrWarned.first = %d, clientLagExceededOrWarned.second = %d\n",__FILE__,__FUNCTION__,__LINE__,clientLagExceededOrWarned.first,clientLagExceededOrWarned.second);
@ -1011,7 +1011,7 @@ void ServerInterface::checkForLaggingClients(std::map<int,bool> &mapSlotSignalle
if(connectionSlot != NULL && connectionSlot->isConnected() == true) { if(connectionSlot != NULL && connectionSlot->isConnected() == true) {
try { try {
if(gameHasBeenInitiated == true && if(gameHasBeenInitiated == true &&
difftime(time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) {
//printf("\n\n\n^^^^^^^^^^^^^^ PART A\n\n\n"); //printf("\n\n\n^^^^^^^^^^^^^^ PART A\n\n\n");
@ -1306,7 +1306,7 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
} }
else if(gameHasBeenInitiated == true && else if(gameHasBeenInitiated == true &&
difftime(time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) {
//printf("\nServerInterface::update -- E1\n"); //printf("\nServerInterface::update -- E1\n");
//std::map<int,ConnectionSlotEvent> eventList; //std::map<int,ConnectionSlotEvent> eventList;
@ -1318,7 +1318,7 @@ void ServerInterface::update() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s Line: %d] took %lld msecs\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
} }
else if(gameHasBeenInitiated == true && else if(gameHasBeenInitiated == true &&
difftime(time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) { difftime((long int)time(NULL),lastGlobalLagCheckTime) >= LAG_CHECK_GRACE_PERIOD) {
//printf("\nServerInterface::update -- F\n"); //printf("\nServerInterface::update -- F\n");
std::map<int,ConnectionSlotEvent> eventList; std::map<int,ConnectionSlotEvent> eventList;
@ -1764,7 +1764,7 @@ void ServerInterface::waitUntilReady(Checksum *checksum) {
} }
} }
Window::handleEvent(); Shared::Platform::Window::handleEvent();
} }
if(logger.getCancelLoading() == true) { if(logger.getCancelLoading() == true) {
@ -1941,7 +1941,7 @@ string ServerInterface::getNetworkStatus() {
if(connectionSlot!= NULL) { if(connectionSlot!= NULL) {
if(connectionSlot->isConnected()) { if(connectionSlot->isConnected()) {
int clientLagCount = connectionSlot->getCurrentLagCount(); int clientLagCount = connectionSlot->getCurrentLagCount();
double lastClientCommandListTimeLag = difftime(time(NULL),connectionSlot->getLastReceiveCommandListTime()); double lastClientCommandListTimeLag = difftime((long int)time(NULL),connectionSlot->getLastReceiveCommandListTime());
//float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str()); //float pingTime = connectionSlot->getThreadedPingMS(connectionSlot->getIpAddress().c_str());
char szBuf[1024]=""; char szBuf[1024]="";
//sprintf(szBuf,", lag = %d [%.2f], ping = %.2fms",clientLagCount,lastClientCommandListTimeLag,pingTime); //sprintf(szBuf,", lag = %d [%.2f], ping = %.2fms",clientLagCount,lastClientCommandListTimeLag,pingTime);
@ -2305,7 +2305,7 @@ void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool wai
time_t tStart = time(NULL); time_t tStart = time(NULL);
bool gotAckFromAllClients = false; bool gotAckFromAllClients = false;
while(gotAckFromAllClients == false && difftime(time(NULL),tStart) <= 5) { while(gotAckFromAllClients == false && difftime((long int)time(NULL),tStart) <= 5) {
gotAckFromAllClients = true; gotAckFromAllClients = true;
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
//printf("===> START slot %d - About to setGameSettings #1\n",i); //printf("===> START slot %d - About to setGameSettings #1\n",i);
@ -2341,7 +2341,7 @@ void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool wai
time_t tStart = time(NULL); time_t tStart = time(NULL);
bool gotAckFromAllClients = false; bool gotAckFromAllClients = false;
while(gotAckFromAllClients == false && difftime(time(NULL),tStart) <= 5) { while(gotAckFromAllClients == false && difftime((long int)time(NULL),tStart) <= 5) {
gotAckFromAllClients = true; gotAckFromAllClients = true;
for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) { for(int i= 0; exitServer == false && i < GameConstants::maxPlayers; ++i) {
//printf("===> START slot %d - About to setGameSettings 2\n",i); //printf("===> START slot %d - About to setGameSettings 2\n",i);
@ -2440,7 +2440,7 @@ std::map<string,string> ServerInterface::publishToMasterserver() {
void ServerInterface::simpleTask(BaseThread *callingThread) { void ServerInterface::simpleTask(BaseThread *callingThread) {
MutexSafeWrapper safeMutex(masterServerThreadAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutex(masterServerThreadAccessor,CODE_AT_LINE);
if(difftime(time(NULL),lastMasterserverHeartbeatTime) >= MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS) { if(difftime((long int)time(NULL),lastMasterserverHeartbeatTime) >= MASTERSERVER_HEARTBEAT_GAME_STATUS_SECONDS) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
lastMasterserverHeartbeatTime = time(NULL); lastMasterserverHeartbeatTime = time(NULL);
@ -2532,7 +2532,7 @@ std::string ServerInterface::DumpStatsToLog(bool dumpToStringOnly) const {
const int HOURS_IN_DAY = 24; const int HOURS_IN_DAY = 24;
const int MINUTES_IN_HOUR = 60; const int MINUTES_IN_HOUR = 60;
const int SECONDS_IN_MINUTE = 60; const int SECONDS_IN_MINUTE = 60;
int InSeconds = difftime(time(NULL),slot->getConnectedTime()); int InSeconds = difftime((long int)time(NULL),slot->getConnectedTime());
// compute seconds // compute seconds
int seconds = InSeconds % SECONDS_IN_MINUTE ; int seconds = InSeconds % SECONDS_IN_MINUTE ;
// throw away seconds used in previous statement and convert to minutes // throw away seconds used in previous statement and convert to minutes
@ -2588,7 +2588,7 @@ void ServerInterface::notifyBadClientConnectAttempt(string ipAddress) {
//printf("In [%s::%s Line: %d] ipAddress [%s]\n",__FILE__,__FUNCTION__,__LINE__,ipAddress.c_str()); //printf("In [%s::%s Line: %d] ipAddress [%s]\n",__FILE__,__FUNCTION__,__LINE__,ipAddress.c_str());
if(badClientConnectIPList.find(ipAddress) == badClientConnectIPList.end()) { if(badClientConnectIPList.find(ipAddress) == badClientConnectIPList.end()) {
badClientConnectIPList[ipAddress] = make_pair(0,time(NULL)); badClientConnectIPList[ipAddress] = make_pair(0,(long int)time(NULL));
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
} }
@ -2598,7 +2598,7 @@ void ServerInterface::notifyBadClientConnectAttempt(string ipAddress) {
const uint64 BLOCK_BAD_CLIENT_CONNECT_MAX_ATTEMPTS = Config::getInstance().getInt("BlockBadClientConnectMaxAttempts", "6"); const uint64 BLOCK_BAD_CLIENT_CONNECT_MAX_ATTEMPTS = Config::getInstance().getInt("BlockBadClientConnectMaxAttempts", "6");
bool addToBlockedClientsList = false; bool addToBlockedClientsList = false;
if(difftime(time(NULL),lastBadConnectionAttempt.second) <= BLOCK_BAD_CLIENT_CONNECT_MAX_SECONDS) { if(difftime((long int)time(NULL),lastBadConnectionAttempt.second) <= BLOCK_BAD_CLIENT_CONNECT_MAX_SECONDS) {
//printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
if(lastBadConnectionAttempt.first+1 > BLOCK_BAD_CLIENT_CONNECT_MAX_ATTEMPTS) { if(lastBadConnectionAttempt.first+1 > BLOCK_BAD_CLIENT_CONNECT_MAX_ATTEMPTS) {

View File

@ -61,7 +61,7 @@ private:
public: public:
//misc //misc
~SoundRenderer(); virtual ~SoundRenderer();
static SoundRenderer &getInstance(); static SoundRenderer &getInstance();
bool init(Window *window); bool init(Window *window);
void update(); void update();

View File

@ -61,6 +61,7 @@ public:
Command(const CommandType *ct, Unit *unit); Command(const CommandType *ct, Unit *unit);
Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing); Command(const CommandType *ct, const Vec2i &pos, const UnitType *unitType, CardinalDir facing);
virtual ~Command() {}
//get //get
inline const CommandType *getCommandType() const {return commandType;} inline const CommandType *getCommandType() const {return commandType;}
inline Vec2i getPos() const {return pos;} inline Vec2i getPos() const {return pos;}

View File

@ -46,6 +46,7 @@ class Object;
class ObjectStateInterface { class ObjectStateInterface {
public: public:
virtual void removingObjectEvent(Object *object) = 0; virtual void removingObjectEvent(Object *object) = 0;
virtual ~ObjectStateInterface() {}
}; };
class Object : public BaseColorPickEntity { class Object : public BaseColorPickEntity {
@ -69,7 +70,7 @@ private:
public: public:
Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos); Object(ObjectType *objectType, const Vec3f &pos, const Vec2i &mapPos);
~Object(); virtual ~Object();
void end(); //to kill particles void end(); //to kill particles
void initParticles(); void initParticles();

View File

@ -1050,8 +1050,42 @@ void Unit::setPos(const Vec2i &pos, bool clearPathFinder) {
if(clearPathFinder == true && this->unitPath != NULL) { if(clearPathFinder == true && this->unitPath != NULL) {
this->unitPath->clear(); this->unitPath->clear();
} }
Vec2i oldLastPos = this->lastPos;
this->lastPos= this->pos; this->lastPos= this->pos;
this->pos= pos; this->pos= pos;
/*
// This code is initial code to make the camera 'follow' a unit
if(this->getId() == 5) {
printf("A fov [%f] [H [%f] [V [%f]\n",game->getGameCameraPtr()->getFov(),game->getGameCameraPtr()->getHAng(),game->getGameCameraPtr()->getVAng());
game->getGameCameraPtr()->setClampDisabled(true);
game->getGameCameraPtr()->setFov(45);
if(oldLastPos.x > pos.x) {
game->getGameCameraPtr()->setHAng(270);
game->getGameCameraPtr()->setVAng(-7.6);
}
else if(oldLastPos.x < pos.x) {
game->getGameCameraPtr()->setHAng(90);
game->getGameCameraPtr()->setVAng(1.4);
}
else if(oldLastPos.y > pos.y) {
game->getGameCameraPtr()->setHAng(180);
game->getGameCameraPtr()->setVAng(4.2);
}
else {
game->getGameCameraPtr()->setHAng(-2.4);
game->getGameCameraPtr()->setVAng(-1.4);
}
game->getGameCameraPtr()->setPos(getCurrVector());
game->getGameCameraPtr()->stop();
printf("B fov [%f] [H [%f] [V [%f]\n",game->getGameCameraPtr()->getFov(),game->getGameCameraPtr()->getHAng(),game->getGameCameraPtr()->getVAng());
}
*/
map->clampPos(this->pos); map->clampPos(this->pos);
this->meetingPos= pos - Vec2i(1); this->meetingPos= pos - Vec2i(1);
map->clampPos(this->meetingPos); map->clampPos(this->meetingPos);

View File

@ -289,7 +289,7 @@ class UnitAttackBoostEffect {
public: public:
UnitAttackBoostEffect(); UnitAttackBoostEffect();
~UnitAttackBoostEffect(); virtual ~UnitAttackBoostEffect();
const AttackBoost *boost; const AttackBoost *boost;
const Unit *source; const Unit *source;
@ -303,7 +303,7 @@ class UnitAttackBoostEffectOriginator {
public: public:
UnitAttackBoostEffectOriginator(); UnitAttackBoostEffectOriginator();
~UnitAttackBoostEffectOriginator(); virtual ~UnitAttackBoostEffectOriginator();
const SkillType *skillType; const SkillType *skillType;
std::vector<int> currentAttackBoostUnits; std::vector<int> currentAttackBoostUnits;
@ -458,7 +458,7 @@ private:
public: public:
Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing); Unit(int id, UnitPathInterface *path, const Vec2i &pos, const UnitType *type, Faction *faction, Map *map, CardinalDir placeFacing);
~Unit(); virtual ~Unit();
//static bool isUnitDeleted(void *unit); //static bool isUnitDeleted(void *unit);

View File

@ -575,8 +575,9 @@ string SkillType::skillClassToStr(SkillClass skillClass) {
case scUpgrade: return "Upgrade"; case scUpgrade: return "Upgrade";
default: default:
assert(false); assert(false);
return ""; break;
}; }
return "";
} }
string SkillType::fieldToStr(Field field) { string SkillType::fieldToStr(Field field) {
@ -605,8 +606,9 @@ string SkillType::fieldToStr(Field field) {
return lang.getTilesetString("FieldAirName",fieldName.c_str()); return lang.getTilesetString("FieldAirName",fieldName.c_str());
default: default:
assert(false); assert(false);
return ""; break;
}; }
return "";
} }
void SkillType::saveGame(XmlNode *rootNode) { void SkillType::saveGame(XmlNode *rootNode) {

View File

@ -90,7 +90,7 @@ enum AttackBoostTargetType {
class AttackBoost { class AttackBoost {
public: public:
AttackBoost(); AttackBoost();
~AttackBoost(); virtual ~AttackBoost();
bool enabled; bool enabled;
bool allowMultipleBoosts; bool allowMultipleBoosts;
int radius; int radius;

View File

@ -84,6 +84,17 @@ UnitType::UnitType() : ProducibleType() {
armorType= NULL; armorType= NULL;
rotatedBuildPos=0; rotatedBuildPos=0;
field = fLand;
id = 0;
meetingPoint = false;
rotationAllowed = false;
countUnitDeathInStats=false;
countUnitProductionInStats=false;
countUnitKillInStats=false;
countKillForUnitUpgrade=false;
for(int i=0; i<ccCount; ++i){ for(int i=0; i<ccCount; ++i){
firstCommandTypeOfClass[i]= NULL; firstCommandTypeOfClass[i]= NULL;
} }
@ -919,6 +930,7 @@ bool UnitType::isOfClass(UnitClass uc) const{
return hasSkillClass(scBeBuilt); return hasSkillClass(scBeBuilt);
default: default:
assert(false); assert(false);
break;
} }
return false; return false;
} }

View File

@ -81,6 +81,7 @@ protected:
std::map<string,int> prodSpeedMorphIsMultiplierValueList; std::map<string,int> prodSpeedMorphIsMultiplierValueList;
public: public:
virtual ~UpgradeTypeBase() {}
int getMaxHp() const {return maxHp;} int getMaxHp() const {return maxHp;}
bool getMaxHpIsMultiplier() const {return maxHpIsMultiplier;} bool getMaxHpIsMultiplier() const {return maxHpIsMultiplier;}
@ -180,6 +181,7 @@ public:
class TotalUpgrade: public UpgradeTypeBase { class TotalUpgrade: public UpgradeTypeBase {
public: public:
TotalUpgrade(); TotalUpgrade();
virtual ~TotalUpgrade() {}
void reset(); void reset();
void sum(const UpgradeTypeBase *ut, const Unit *unit); void sum(const UpgradeTypeBase *ut, const Unit *unit);

View File

@ -217,6 +217,7 @@ public:
FastAINode() { FastAINode() {
this->map = NULL; this->map = NULL;
hashCode=0;
} }
FastAINode(Vec2i &pos,const Map *map) { FastAINode(Vec2i &pos,const Map *map) {
this->pos = pos; this->pos = pos;
@ -226,6 +227,7 @@ public:
result.addInt(pos.y); result.addInt(pos.y);
hashCode = result.getSum(); hashCode = result.getSum();
} }
virtual ~FastAINode() {}
void setData(Vec2i pos, const Map *map) { void setData(Vec2i pos, const Map *map) {
this->pos = pos; this->pos = pos;
this->map = map; this->map = map;

View File

@ -398,6 +398,7 @@ string Scenario::controllerTypeToStr(const ControlType &ct) {
default: default:
printf("Error control = %d\n",ct); printf("Error control = %d\n",ct);
//assert(false); //assert(false);
break;
} }
return controlString; return controlString;

View File

@ -464,6 +464,7 @@ void UnitUpdater::updateMove(Unit *unit, int frameIndex) {
default: default:
unit->finishCommand(); unit->finishCommand();
break;
} }
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld --------------------------- [END OF METHOD] ---------------------------\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis());
@ -557,6 +558,7 @@ void UnitUpdater::updateAttack(Unit *unit, int frameIndex) {
break; break;
default: default:
unit->finishCommand(); unit->finishCommand();
break;
} }
/* /*
case tsMoving: case tsMoving:

View File

@ -341,6 +341,7 @@ public:
App() : wxApp() { App() : wxApp() {
mainWindow = NULL; mainWindow = NULL;
} }
virtual ~App() {}
virtual bool OnInit(); virtual bool OnInit();
virtual int MainLoop(); virtual int MainLoop();
virtual int OnExit(); virtual int OnExit();

View File

@ -24,7 +24,7 @@ namespace Shared { namespace Graphics {
class BaseRenderer : public RendererMapInterface { class BaseRenderer : public RendererMapInterface {
public: public:
BaseRenderer() { } BaseRenderer() { }
~BaseRenderer() { } virtual ~BaseRenderer() { }
virtual void initMapSurface(int clientW, int clientH); virtual void initMapSurface(int clientW, int clientH);
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false); virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid=false);

View File

@ -36,12 +36,16 @@ class RendererInterface {
public: public:
virtual Texture2D *newTexture2D(ResourceScope rs) = 0; virtual Texture2D *newTexture2D(ResourceScope rs) = 0;
virtual Model *newModel(ResourceScope rs) = 0; virtual Model *newModel(ResourceScope rs) = 0;
virtual ~RendererInterface() {}
}; };
class RendererMapInterface { class RendererMapInterface {
public: public:
virtual void initMapSurface(int clientW, int clientH) = 0; virtual void initMapSurface(int clientW, int clientH) = 0;
virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) = 0; virtual void renderMap(MapPreview *map, int x, int y, int clientW, int clientH, int cellSize, bool grid) = 0;
virtual ~RendererMapInterface() {}
}; };
// ===================================================== // =====================================================

View File

@ -241,6 +241,7 @@ class BaseColorPickEntity {
public: public:
BaseColorPickEntity(); BaseColorPickEntity();
virtual ~BaseColorPickEntity() {}
static const int COLOR_COMPONENTS = 4; static const int COLOR_COMPONENTS = 4;
static void init(int bufferSize); static void init(int bufferSize);
@ -254,8 +255,6 @@ public:
string getColorDescription() const; string getColorDescription() const;
virtual string getUniquePickName() const = 0; virtual string getUniquePickName() const = 0;
~BaseColorPickEntity() {};
private: private:
unsigned char uniqueColorID[COLOR_COMPONENTS]; unsigned char uniqueColorID[COLOR_COMPONENTS];

View File

@ -29,6 +29,8 @@ class TextRenderer {
public: public:
virtual void render(const string &text, float x, float y, bool centered=false, Vec3f *color=NULL) = 0; virtual void render(const string &text, float x, float y, bool centered=false, Vec3f *color=NULL) = 0;
virtual void end()= 0; virtual void end()= 0;
virtual ~TextRenderer() {}
}; };
class TextRenderer2D : public TextRenderer { class TextRenderer2D : public TextRenderer {

View File

@ -22,6 +22,7 @@ namespace Shared{ namespace Graphics{
class VideoLoadingCallbackInterface { class VideoLoadingCallbackInterface {
public: public:
virtual ~VideoLoadingCallbackInterface() {}
/** a value from 1 to 100 representing % done */ /** a value from 1 to 100 representing % done */
virtual void renderVideoLoading(int progressPercent) = 0; virtual void renderVideoLoading(int progressPercent) = 0;
}; };

View File

@ -30,6 +30,7 @@ namespace Shared { namespace PlatformCommon {
class FileCRCPreCacheThreadCallbackInterface { class FileCRCPreCacheThreadCallbackInterface {
public: public:
virtual vector<Texture2D *> processTech(string techName) = 0; virtual vector<Texture2D *> processTech(string techName) = 0;
virtual ~FileCRCPreCacheThreadCallbackInterface() {}
}; };
// ===================================================== // =====================================================
@ -74,6 +75,8 @@ public:
virtual void setupTask(BaseThread *callingThread) { } virtual void setupTask(BaseThread *callingThread) { }
virtual void shutdownTask(BaseThread *callingThread) { } virtual void shutdownTask(BaseThread *callingThread) { }
virtual ~SimpleTaskCallbackInterface() {}
}; };
class SimpleTaskThread : public BaseThread class SimpleTaskThread : public BaseThread

View File

@ -46,6 +46,8 @@ void normalizeNick(char *nick);
class IRCCallbackInterface { class IRCCallbackInterface {
public: public:
virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) = 0; virtual void IRC_CallbackEvent(IRCEventType evt, const char* origin, const char **params, unsigned int count) = 0;
virtual ~IRCCallbackInterface() {}
}; };
class IRCThread : public BaseThread class IRCThread : public BaseThread

View File

@ -44,7 +44,7 @@ enum FTP_Client_CallbackType {
class FTPClientCallbackInterface { class FTPClientCallbackInterface {
public: public:
virtual ~FTPClientCallbackInterface() {}
struct FtpProgressStats { struct FtpProgressStats {
double download_total; double download_total;
double download_now; double download_now;

View File

@ -55,6 +55,8 @@ class FTPClientValidationInterface {
public: public:
virtual int isValidClientType(uint32 clientIp) = 0; virtual int isValidClientType(uint32 clientIp) = 0;
virtual int isClientAllowedToGetFile(uint32 clientIp, const char *username, const char *filename) = 0; virtual int isClientAllowedToGetFile(uint32 clientIp, const char *username, const char *filename) = 0;
virtual ~FTPClientValidationInterface() {}
}; };
@ -62,6 +64,8 @@ public:
class UPNPInitInterface { class UPNPInitInterface {
public: public:
virtual void UPNPInitStatus(bool result) = 0; virtual void UPNPInitStatus(bool result) = 0;
virtual ~UPNPInitInterface() {}
}; };
// //
@ -71,6 +75,7 @@ public:
class DiscoveredServersInterface { class DiscoveredServersInterface {
public: public:
virtual void DiscoveredServers(std::vector<string> serverList) = 0; virtual void DiscoveredServers(std::vector<string> serverList) = 0;
virtual ~DiscoveredServersInterface() {}
}; };
// ===================================================== // =====================================================

View File

@ -233,7 +233,7 @@ LOCAL int ftpCmdPort(int sessionId, const char* args, int len)
} }
} }
// TODO Derzeit wird die übergebene IP nicht beachtet, sondern nur die IP des Control-Sockets verwendet // TODO Derzeit wird die übergebene IP nicht beachtet, sondern nur die IP des Control-Sockets verwendet
clientIp[0] = clientIp[0]; //clientIp[0] = clientIp[0];
if(ftpGetSession(sessionId)->passiveDataSocket >= 0) if(ftpGetSession(sessionId)->passiveDataSocket >= 0)
{ {
if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPort about to Close socket = %d for sessionId = %d\n",ftpGetSession(sessionId)->passiveDataSocket,sessionId); if(VERBOSE_MODE_ENABLED) printf("In ftpCmdPort about to Close socket = %d for sessionId = %d\n",ftpGetSession(sessionId)->passiveDataSocket,sessionId);
@ -701,6 +701,7 @@ LOCAL int ftpCmdType(int sessionId, const char* args, int len)
break; break;
default: default:
ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg028); ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg028);
break;
} }
return 0; return 0;
@ -799,6 +800,7 @@ LOCAL int ftpCmdStru(int sessionId, const char* args, int len)
break; break;
default: default:
ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg031); ftpSendMsg(MSG_NORMAL, sessionId, 504, ftpMsg031);
break;
} }
return 0; return 0;
} }

View File

@ -195,6 +195,7 @@ Pixmap2D* JPGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
for (int i = 0; i < picComponents; ++i) { for (int i = 0; i < picComponents; ++i) {
pixels[location+xPic+i] = l; pixels[location+xPic+i] = l;
} }
break;
//TODO: Error //TODO: Error
} }
} }

View File

@ -38,10 +38,9 @@ static void user_read_data(png_structp read_ptr, png_bytep data, png_size_t leng
} }
} }
static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t length) { //static void user_write_data(png_structp png_ptr, png_bytep data, png_size_t length) {}
}
static void user_flush_data(png_structp png_ptr) {} //static void user_flush_data(png_structp png_ptr) {}
/**Get Extension array, initialised*/ /**Get Extension array, initialised*/
//static inline const string* getExtensionsPng() { //static inline const string* getExtensionsPng() {
@ -178,6 +177,7 @@ Pixmap2D* PNGReader::read(ifstream& is, const string& path, Pixmap2D* ret) const
for (unsigned int i = 0; i < picComponents; ++i) { for (unsigned int i = 0; i < picComponents; ++i) {
pixels[location+xPic+i] = l; pixels[location+xPic+i] = l;
} }
break;
//TODO: Error //TODO: Error
} }
} }
@ -327,6 +327,7 @@ Pixmap3D* PNGReader3D::read(ifstream& is, const string& path, Pixmap3D* ret) con
for (unsigned int i = 0; i < picComponents; ++i) { for (unsigned int i = 0; i < picComponents; ++i) {
pixels[location+xPic+i] = l; pixels[location+xPic+i] = l;
} }
break;
//TODO: Error //TODO: Error
} }
} }

View File

@ -80,6 +80,7 @@ void fillPixels(uint8 *texturePixels, const Pixmap2D *pixmap){
break; break;
default: default:
assert(false); assert(false);
break;
} }
} }
} }

View File

@ -31,6 +31,7 @@ ModelRendererGl::ModelRendererGl() {
rendering= false; rendering= false;
duplicateTexCoords= false; duplicateTexCoords= false;
secondaryTexCoordUnit= 1; secondaryTexCoordUnit= 1;
lastTexture=0;
} }
void ModelRendererGl::begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback) { void ModelRendererGl::begin(bool renderNormals, bool renderTextures, bool renderColors, MeshCallback *meshCallback) {

View File

@ -307,6 +307,7 @@ void ParticleRendererGl::setBlendMode(ParticleSystem::BlendMode blendMode){
break; break;
default: default:
assert(false); assert(false);
break;
} }
} }

View File

@ -205,6 +205,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
parts[parts.size()-1] += szBuf; parts[parts.size()-1] += szBuf;
} }
lastCharacterWasSpecial = false; lastCharacterWasSpecial = false;
break;
} }
} }
@ -221,6 +222,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
break; break;
default: default:
font->getTextHandler()->Render(parts[i].c_str()); font->getTextHandler()->Render(parts[i].c_str());
break;
} }
} }
} }
@ -299,6 +301,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
parts[parts.size()-1] += szBuf; parts[parts.size()-1] += szBuf;
} }
lastCharacterWasSpecial = false; lastCharacterWasSpecial = false;
break;
} }
} }
@ -315,6 +318,7 @@ void TextRenderer2DGl::render(const string &text, float x, float y, bool centere
break; break;
default: default:
font->getTextHandler()->Render(parts[i].c_str()); font->getTextHandler()->Render(parts[i].c_str());
break;
} }
} }
} }
@ -590,6 +594,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
parts[parts.size()-1] += szBuf; parts[parts.size()-1] += szBuf;
} }
lastCharacterWasSpecial = false; lastCharacterWasSpecial = false;
break;
} }
} }
@ -635,6 +640,7 @@ void TextRenderer3DGl::internalRender(const string &text, float x, float y, boo
font->getTextHandler()->Render(parts[i].c_str()); font->getTextHandler()->Render(parts[i].c_str());
specialFTGLErrorCheckWorkaround(parts[i]); specialFTGLErrorCheckWorkaround(parts[i]);
} }
break;
} }
} }
} }

View File

@ -772,6 +772,7 @@ void GameParticleSystem::render(ParticleRenderer *pr, ModelRenderer *mr){
break; break;
default: default:
assert(false); assert(false);
break;
} }
} }
} }
@ -900,6 +901,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount) :
radius= 0.5f; radius= 0.5f;
speed= 0.01f; speed= 0.01f;
windSpeed= Vec3f(0.0f); windSpeed= Vec3f(0.0f);
minRadius = 0.0;
setParticleSize(0.6f); setParticleSize(0.6f);
setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f)); setColorNoEnergy(Vec4f(1.0f, 0.5f, 0.0f, 1.0f));
@ -1403,6 +1405,7 @@ AttackParticleSystem::AttackParticleSystem(int particleCount) :
GameParticleSystem(particleCount){ GameParticleSystem(particleCount){
primitive= pQuad; primitive= pQuad;
gravity= 0.0f; gravity= 0.0f;
sizeNoEnergy = 0.0;
} }
void AttackParticleSystem::saveGame(XmlNode *rootNode) { void AttackParticleSystem::saveGame(XmlNode *rootNode) {
@ -1520,6 +1523,7 @@ void ProjectileParticleSystem::update(){
default: default:
assert(false); assert(false);
break;
} }
direction= pos - lastPos; direction= pos - lastPos;
@ -1729,6 +1733,7 @@ SplashParticleSystem::SplashParticleSystem(int particleCount) :
verticalSpreadB= 0.0f; verticalSpreadB= 0.0f;
horizontalSpreadA= 1.0f; horizontalSpreadA= 1.0f;
horizontalSpreadB= 0.0f; horizontalSpreadB= 0.0f;
startEmissionRate= 0.0f;
} }
SplashParticleSystem::~SplashParticleSystem(){ SplashParticleSystem::~SplashParticleSystem(){

View File

@ -26,7 +26,8 @@ const int Texture::defaultSize = 256;
const int Texture::defaultComponents = 4; const int Texture::defaultComponents = 4;
bool Texture::useTextureCompression = false; bool Texture::useTextureCompression = false;
/* Quick utility function for texture creation */ // Quick utility function for texture creation
/*
static int powerOfTwo(int input) { static int powerOfTwo(int input) {
int value = 1; int value = 1;
@ -35,6 +36,7 @@ static int powerOfTwo(int input) {
} }
return value; return value;
} }
*/
Texture::Texture() { Texture::Texture() {
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false); assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);

View File

@ -184,7 +184,7 @@ static void unlock(void *data, void *id, void *const *p_pixels) {
} }
static void display(void *data, void *id) { static void display(void *data, void *id) {
/* VLC wants to display the video */ // VLC wants to display the video
class ctx *ctx = (class ctx *)data; class ctx *ctx = (class ctx *)data;
if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__); if(ctx->verboseEnabled) printf("In [%s] Line: %d\n",__FUNCTION__,__LINE__);
} }

View File

@ -201,6 +201,8 @@ static void libirc_dcc_add_descriptors (irc_session_t * ircsession, fd_set *in_s
if ( dcc->dccmode == LIBIRC_DCC_SENDFILE && dcc->incoming_offset < 4 ) if ( dcc->dccmode == LIBIRC_DCC_SENDFILE && dcc->incoming_offset < 4 )
libirc_add_to_set (dcc->sock, in_set, maxfd); libirc_add_to_set (dcc->sock, in_set, maxfd);
break;
} }
} }

View File

@ -101,6 +101,7 @@ static int socket_connect (socket_t * sock, const struct sockaddr *saddr, sockle
return 0; return 0;
} }
return 0;
} }

View File

@ -202,6 +202,8 @@ static void libirc_dcc_add_descriptors (irc_session_t * ircsession, fd_set *in_s
if ( dcc->dccmode == LIBIRC_DCC_SENDFILE && dcc->incoming_offset < 4 ) if ( dcc->dccmode == LIBIRC_DCC_SENDFILE && dcc->incoming_offset < 4 )
libirc_add_to_set (dcc->sock, in_set, maxfd); libirc_add_to_set (dcc->sock, in_set, maxfd);
break;
} }
} }

View File

@ -101,6 +101,7 @@ static int socket_connect (socket_t * sock, const struct sockaddr *saddr, sockle
return 0; return 0;
} }
return 0;
} }

View File

@ -552,6 +552,7 @@ string LuaScript::errorToString(int errorCode) {
break; break;
default: default:
error+= "Unknown error"; error+= "Unknown error";
break;
} }
error += string(": ")+luaL_checkstring(luaState, -1); error += string(": ")+luaL_checkstring(luaState, -1);

View File

@ -1370,7 +1370,7 @@ string extractLastDirectoryFromPath(string Path) {
} }
else { else {
for(int i = lastDirectory-1; i >= 0; --i) { for(int i = lastDirectory-1; i >= 0; --i) {
if(Path[i] == '/' || Path[i] == '\\' && i > 0) { if((Path[i] == '/' || Path[i] == '\\') && i > 0) {
result = Path.erase( 0, i); result = Path.erase( 0, i);
break; break;
} }

View File

@ -573,6 +573,7 @@ int main(int argc, char ** argv)
default: default:
printf("Found device (igd ?) : %s\n", urls.controlURL); printf("Found device (igd ?) : %s\n", urls.controlURL);
printf("Trying to continue anyway\n"); printf("Trying to continue anyway\n");
break;
} }
printf("Local LAN ip address : %s\n", lanaddr); printf("Local LAN ip address : %s\n", lanaddr);
#if 0 #if 0
@ -662,6 +663,7 @@ int main(int argc, char ** argv)
default: default:
fprintf(stderr, "Unknown switch -%c\n", command); fprintf(stderr, "Unknown switch -%c\n", command);
retcode = 1; retcode = 1;
break;
} }
FreeUPNPUrls(&urls); FreeUPNPUrls(&urls);

View File

@ -98,6 +98,7 @@ const char * strupnperror(int err)
break; break;
default: default:
s = NULL; s = NULL;
break;
} }
return s; return s;
} }

View File

@ -349,6 +349,7 @@ void Ip::Inet_NtoA(uint32 addr, char * ipbuf)
} }
// convert a string represenation of an IP address into its numeric equivalent // convert a string represenation of an IP address into its numeric equivalent
/*
static uint32 Inet_AtoN(const char * buf) static uint32 Inet_AtoN(const char * buf)
{ {
// net_server inexplicably doesn't have this function; so I'll just fake it // net_server inexplicably doesn't have this function; so I'll just fake it
@ -368,7 +369,7 @@ static uint32 Inet_AtoN(const char * buf)
} }
return ret; return ret;
} }
*/
/* /*
static void PrintNetworkInterfaceInfos() static void PrintNetworkInterfaceInfos()
{ {
@ -793,6 +794,8 @@ Socket::Socket(PLATFORM_SOCKET sock) {
MutexSafeWrapper safeMutexSocketDestructorFlag(inSocketDestructorSynchAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutexSocketDestructorFlag(inSocketDestructorSynchAccessor,CODE_AT_LINE);
inSocketDestructorSynchAccessor->setOwnerId(CODE_AT_LINE); inSocketDestructorSynchAccessor->setOwnerId(CODE_AT_LINE);
this->inSocketDestructor = false; this->inSocketDestructor = false;
lastThreadedPing = 0;
lastDebugEvent = 0;
//safeMutexSocketDestructorFlag.ReleaseLock(); //safeMutexSocketDestructorFlag.ReleaseLock();
//this->pingThread = NULL; //this->pingThread = NULL;
@ -933,7 +936,7 @@ Socket::~Socket() {
for(time_t elapsed = time(NULL); for(time_t elapsed = time(NULL);
(dataSynchAccessorRead->getRefCount() > 0 || (dataSynchAccessorRead->getRefCount() > 0 ||
dataSynchAccessorWrite->getRefCount() > 0) && dataSynchAccessorWrite->getRefCount() > 0) &&
difftime(time(NULL),elapsed) <= 2;) { difftime((long int)time(NULL),elapsed) <= 2;) {
printf("Waiting in socket destructor\n"); printf("Waiting in socket destructor\n");
//sleep(0); //sleep(0);
} }
@ -1149,7 +1152,7 @@ int Socket::getDataToRead(bool wantImmediateReply) {
if(isSocketValid() == true) if(isSocketValid() == true)
{ {
//int loopCount = 1; //int loopCount = 1;
for(time_t elapsed = time(NULL); difftime(time(NULL),elapsed) < 1;) { for(time_t elapsed = time(NULL); difftime((long int)time(NULL),elapsed) < 1;) {
/* ioctl isn't posix, but the following seems to work on all modern /* ioctl isn't posix, but the following seems to work on all modern
* unixes */ * unixes */
#ifndef WIN32 #ifndef WIN32
@ -1236,7 +1239,7 @@ int Socket::send(const void *data, int dataSize) {
int attemptCount = 0; int attemptCount = 0;
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { (difftime((long int)time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) {
attemptCount++; attemptCount++;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount);
@ -1297,7 +1300,7 @@ int Socket::send(const void *data, int dataSize) {
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while(((bytesSent > 0 && totalBytesSent < dataSize) || while(((bytesSent > 0 && totalBytesSent < dataSize) ||
(bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN)) && (bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN)) &&
(difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { (difftime((long int)time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) {
attemptCount++; attemptCount++;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] attemptCount = %d, totalBytesSent = %d\n",__FILE__,__FUNCTION__,__LINE__,attemptCount,totalBytesSent);
@ -1399,7 +1402,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) { (difftime((long int)time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) {
if(isConnected() == false) { if(isConnected() == false) {
int iErr = getLastSocketError(); int iErr = getLastSocketError();
disconnectSocket(); disconnectSocket();
@ -1512,7 +1515,7 @@ int Socket::peek(void *data, int dataSize,bool mustGetData,int *pLastSocketError
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) && while((err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) { (difftime((long int)time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) {
/* /*
if(isConnected() == false) { if(isConnected() == false) {
int iErr = getLastSocketError(); int iErr = getLastSocketError();
@ -1978,7 +1981,7 @@ void BroadCastClientSocketThread::execute() {
try { try {
// Keep getting packets forever. // Keep getting packets forever.
for( time_t elapsed = time(NULL); difftime(time(NULL),elapsed) <= 5; ) { for( time_t elapsed = time(NULL); difftime((long int)time(NULL),elapsed) <= 5; ) {
alen = sizeof(struct sockaddr); alen = sizeof(struct sockaddr);
int nb=0;// The number of bytes read. int nb=0;// The number of bytes read.
bool gotData = (nb = recvfrom(bcfd, buff, 10024, 0, (struct sockaddr *) &bcSender, &alen)) > 0; bool gotData = (nb = recvfrom(bcfd, buff, 10024, 0, (struct sockaddr *) &bcSender, &alen)) > 0;
@ -2061,6 +2064,7 @@ ServerSocket::ServerSocket(bool basicMode) : Socket() {
//ServerSocket::upnpdiscoverThread = NULL; //ServerSocket::upnpdiscoverThread = NULL;
//safeMutexUPNP.ReleaseLock(); //safeMutexUPNP.ReleaseLock();
boundPort = 0;
portBound = false; portBound = false;
broadCastThread = NULL; broadCastThread = NULL;
if(this->basicMode == false) { if(this->basicMode == false) {
@ -2791,7 +2795,7 @@ void BroadCastSocketThread::execute() {
strcat(buff,ipList[idx1].c_str()); strcat(buff,ipList[idx1].c_str());
} }
if(difftime(time(NULL),elapsed) >= 1 && getQuitStatus() == false) { if(difftime((long int)time(NULL),elapsed) >= 1 && getQuitStatus() == false) {
elapsed = time(NULL); elapsed = time(NULL);
bool pauseBroadCast = getPauseBroadcast(); bool pauseBroadCast = getPauseBroadcast();

View File

@ -877,8 +877,8 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
if(result == true && modifiersAllowed == false) { if(result == true && modifiersAllowed == false) {
//printf("input.keysym.mod = %d\n",input.keysym.mod); //printf("input.keysym.mod = %d\n",input.keysym.mod);
if( input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL) || if( (input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) ||
input.keysym.mod & (KMOD_LALT | KMOD_RALT)) { (input.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
//input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { //input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] result *WOULD HAVE BEEN TRUE* but is false due to: modifiersAllowed = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,modifiersAllowed,input.keysym.mod); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] result *WOULD HAVE BEEN TRUE* but is false due to: modifiersAllowed = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,modifiersAllowed,input.keysym.mod);
result = false; result = false;

View File

@ -359,6 +359,7 @@ bool Properties::getBool(const string &key, const char *defaultValueIfNotFound)
//throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + key + " in: " + path+"\n[" + e.what() + "]");
} }
return false;
} }
int Properties::getInt(const string &key,const char *defaultValueIfNotFound) const{ int Properties::getInt(const string &key,const char *defaultValueIfNotFound) const{
@ -370,6 +371,7 @@ int Properties::getInt(const string &key,const char *defaultValueIfNotFound) con
//throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
} }
return 0;
} }
int Properties::getInt(const string &key, int min, int max,const char *defaultValueIfNotFound) const{ int Properties::getInt(const string &key, int min, int max,const char *defaultValueIfNotFound) const{
@ -389,6 +391,7 @@ float Properties::getFloat(const string &key, const char *defaultValueIfNotFound
//throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + key + " in: " + path + "\n[" + e.what() + "]");
} }
return 0.0;
} }
float Properties::getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound) const{ float Properties::getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound) const{
@ -476,6 +479,7 @@ bool Properties::getBool(const char *key, const char *defaultValueIfNotFound) co
//throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + string(key) + " in: " + path+"\n[" + e.what() + "]");
} }
return false;
} }
int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const{ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const{
@ -487,6 +491,7 @@ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const
//throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
} }
return 0;
} }
float Properties::getFloat(const char *key, const char *defaultValueIfNotFound) const{ float Properties::getFloat(const char *key, const char *defaultValueIfNotFound) const{
@ -498,6 +503,7 @@ float Properties::getFloat(const char *key, const char *defaultValueIfNotFound)
//throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); //throw megaglest_runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]"); throw runtime_error("Error accessing value: " + string(key) + " in: " + path + "\n[" + e.what() + "]");
} }
return 0.0;
} }
const string Properties::getString(const char *key, const char *defaultValueIfNotFound) const{ const string Properties::getString(const char *key, const char *defaultValueIfNotFound) const{

View File

@ -173,6 +173,7 @@ XmlNode *XmlIo::load(const string &path, std::map<string,string> mapTagReplaceme
throw megaglest_runtime_error(szBuf); throw megaglest_runtime_error(szBuf);
} }
return NULL;
} }
void XmlIo::save(const string &path, const XmlNode *node){ void XmlIo::save(const string &path, const XmlNode *node){