- ported bugfixes for 3.6.0.3 release:

- CMake build system fixes applied during debian testing (like checking for compiler SSE support etc)
 - Windows client fix for headless server operation
 - Crash for some systems when trying to use VBO's
 - Fixed AZERTY keyboard support
 - Enhanced support for screenshots in g3d viewer
 - Updated particle code from titi
 - Bugfix for custom data path override causing compiler error
 - Bugfix for fontconfig to properly find fonts on systems that support and have fontconfig installed (fixes numerous non debian based systems that reported null font errors)
 - Minor UI fix on battle end screen when playing 8 players (last player was sometimes chopped off)
This commit is contained in:
Mark Vejvoda
2012-01-23 07:22:43 +00:00
parent 2224d75d10
commit f40c37f5e8
63 changed files with 948 additions and 470 deletions

View File

@@ -55,6 +55,7 @@ if (NOT ${XVFB_RUN} MATCHES "XVFB_RUN-NOTFOUND")
message(STATUS "Using xvfb-run to run man2help.") message(STATUS "Using xvfb-run to run man2help.")
endif() endif()
include(${CMAKE_SOURCE_DIR}/mk/cmake/Modules/SpecialMacros.cmake)
## Compiler flags ## Compiler flags
IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
@@ -74,12 +75,43 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
# For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html # For gcc warning options see: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
IF(NOT MINGW) IF(NOT MINGW)
# For tons of verbose warnings add: -Wall # For tons of verbose warnings add: -Wall
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic") # ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -rdynamic")
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -rdynamic")
ELSE() ELSE()
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE") # ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -mfpmath=sse -msse -DUNICODE")
ADD_DEFINITIONS("-Wreturn-type -fno-strict-aliasing -frounding-math -fsignaling-nans -DUNICODE")
ENDIF() ENDIF()
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
IF(NOT MAX_SSE_LEVEL_DESIRED)
SET(MAX_SSE_LEVEL_DESIRED "1" CACHE STRING "Set the max SSE level to use if supported (0-3)" FORCE)
ENDIF()
MESSAGE(STATUS "*NOTE: Checking for max SSE LEVEL [${MAX_SSE_LEVEL_DESIRED}]")
special_check_for_sse( ${MAX_SSE_LEVEL_DESIRED} )
OPTION(WANT_STREFLOP "use the library streflop" ON)
IF(WANT_STREFLOP)
ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32")
IF(HAS_SSE_EXTENSIONS)
ADD_DEFINITIONS("-DSTREFLOP_SSE")
MESSAGE(STATUS "*NOTE: using SSE for STREFLOP.")
ELSE()
special_check_for_x87()
IF(HAS_X87_SUPPORT)
ADD_DEFINITIONS("-DSTREFLOP_X87")
MESSAGE(STATUS "*NOTE: using X87 for STREFLOP.")
ELSE()
ADD_DEFINITIONS("-DSTREFLOP_SOFT")
MESSAGE(STATUS "*NOTE: using SOFT emulation for STREFLOP.")
ENDIF()
ENDIF()
ELSE()
MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur")
ENDIF()
# Debug compiler flags # Debug compiler flags
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3") SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g3")
@@ -169,21 +201,12 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW)
ENDIF() ENDIF()
OPTION(WANT_STREFLOP "use the library streflop" ON)
# Win32 specific Compiler Flags # Win32 specific Compiler Flags
IF(WIN32) IF(WIN32)
ADD_DEFINITIONS("-D_WINDOWS -D_WIN32 -D_STDCALL_SUPPORTED -D_M_IX86 -DXML_LIBRARY -D_LIB -DCURL_STATICLIB") ADD_DEFINITIONS("-D_WINDOWS -D_WIN32 -D_STDCALL_SUPPORTED -D_M_IX86 -DXML_LIBRARY -D_LIB -DCURL_STATICLIB")
ELSE() ELSE()
ADD_DEFINITIONS("-DCURL_STATICLIB") ADD_DEFINITIONS("-DCURL_STATICLIB")
ENDIF() ENDIF()
IF(WANT_STREFLOP)
ADD_DEFINITIONS("-DUSE_STREFLOP -DSTREFLOP_SSE -DSTREFLOP_RANDOM_GEN_SIZE=32 -DLIBM_COMPILING_FLT32")
ELSE()
MESSAGE(STATUS "*WARNING: Disabled use of STREFLOP! Out of synchs may occur")
ENDIF()
ENDIF() ENDIF()
IF(WIN32) IF(WIN32)
@@ -240,6 +263,13 @@ IF(EXISTS "${PROJECT_SOURCE_DIR}/data/glest_game/")
ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/data/glest_game ) ADD_SUBDIRECTORY( ${PROJECT_SOURCE_DIR}/data/glest_game )
ENDIF() ENDIF()
get_directory_property( DirDefs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS )
foreach( d ${DirDefs} )
message( STATUS "=====> Found Define: " ${d} )
endforeach()
message( STATUS "=====> DirDefs: " ${DirDefs} )
#MESSAGE(STATUS "*** Compiler definitions are [${COMPILE_DEFINITIONS}]")
MARK_AS_ADVANCED(SDLMAIN_LIBRARY) MARK_AS_ADVANCED(SDLMAIN_LIBRARY)
MARK_AS_ADVANCED(SDL_INCLUDE_DIR) MARK_AS_ADVANCED(SDL_INCLUDE_DIR)
MARK_AS_ADVANCED(SDL_LIBRARY) MARK_AS_ADVANCED(SDL_LIBRARY)

View File

@@ -6,6 +6,7 @@
# FTGL_FOUND - system has ftgl # FTGL_FOUND - system has ftgl
# FTGL_INCLUDE_DIR - path to FTGL/FTGL.h # FTGL_INCLUDE_DIR - path to FTGL/FTGL.h
# FTGL_LIBRARY - the library that must be included # FTGL_LIBRARY - the library that must be included
# FTGL_LIBRARY_PATH - the library path
# #
# #
@@ -14,16 +15,33 @@ IF(WANT_STATIC_LIBS)
OPTION(FTGL_STATIC "Set to ON to link your project with static library (instead of DLL)." ON) OPTION(FTGL_STATIC "Set to ON to link your project with static library (instead of DLL)." ON)
ENDIF() ENDIF()
#message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! #1 Searching for FTGL lib in custom path: [${FTGL_LIBRARY_PATH}]")
IF (FTGL_LIBRARY AND FTGL_INCLUDE_DIR) IF (FTGL_LIBRARY AND FTGL_INCLUDE_DIR)
SET(FTGL_FOUND "YES") SET(FTGL_FOUND "YES")
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! FTGL lib ALREADY FOUND in: [${FTGL_LIBRARY}]")
ELSE (FTGL_LIBRARY AND FTGL_INCLUDE_DIR) ELSE (FTGL_LIBRARY AND FTGL_INCLUDE_DIR)
FIND_PATH(FTGL_INCLUDE_DIR FTGL/ftgl.h PATHS /usr/local/include /usr/include) IF(FTGL_LIBRARY_PATH)
message(STATUS "!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Searching for FTGL lib in custom path: [${FTGL_LIBRARY_PATH}]")
ENDIF()
FIND_PATH(FTGL_INCLUDE_DIR FTGL/ftgl.h
PATHS /usr/local/include
/usr/include)
IF (FTGL_STATIC AND NOT FTGL_LIBRARY) IF (FTGL_STATIC AND NOT FTGL_LIBRARY)
FIND_LIBRARY(FTGL_LIBRARY NAMES libftgl.a ftgl PATHS /usr/local/lib /usr/lib) FIND_LIBRARY(FTGL_LIBRARY
NAMES libftgl.a ftgl libftgl libftgl.dll
PATHS /usr/local/lib
/usr/lib
${FTGL_LIBRARY_PATH})
ELSE() ELSE()
FIND_LIBRARY(FTGL_LIBRARY NAMES ftgl PATHS /usr/local/lib /usr/lib) FIND_LIBRARY(FTGL_LIBRARY
NAMES ftgl libftgl libftgl.dll libftgl.a
PATHS /usr/local/lib
/usr/lib
${FTGL_LIBRARY_PATH})
ENDIF() ENDIF()
IF (FTGL_INCLUDE_DIR AND FTGL_LIBRARY) IF (FTGL_INCLUDE_DIR AND FTGL_LIBRARY)

View File

@@ -2,12 +2,23 @@
SET(CMAKE_SYSTEM_NAME Windows) SET(CMAKE_SYSTEM_NAME Windows)
# which compilers to use for C and C++ # which compilers to use for C and C++
SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc) #SET(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++) #SET(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres) #SET(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
# here is the target environment located # here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc ${PROJECT_SOURCE_DIR}/source/win32_deps/lib) #SET(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc ${PROJECT_SOURCE_DIR}/source/win32_deps/lib)
SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 ${PROJECT_SOURCE_DIR}/source/win32_deps/lib)
include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/freetype-2.4.8/include)
include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/glew-1.7.0/include)
include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/ftgl-2.1.3~rc5/src)
#add_definitions(-std=c++0x)
add_definitions( -std=gnu++0x )
add_definitions( -DTA3D_PLATFORM_MSVC=1 )
add_definitions( -DTA3D_PLATFORM_WINDOWS=1 )
# adjust the default behaviour of the FIND_XXX() commands: # adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search # search headers and libraries in the target environment, search

View File

@@ -3,7 +3,7 @@ set -e
# Use this script to copy shared (libs) files to specified location # Use this script to copy shared (libs) files to specified location
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Written by Vivek Gite <http://www.cyberciti.biz/> # Written by Vivek Gite <http://www.cyberciti.biz/>
# (c) 2006 nixCraft under GNU GPL v2.0+ # Copyright (c) 2006 nixCraft under GNU GPL v2.0+
# Last updated on: Apr/06/2010 by Vivek Gite # Last updated on: Apr/06/2010 by Vivek Gite
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# + Modified for megaglest deployment - Softcoder # + Modified for megaglest deployment - Softcoder

View File

@@ -19,4 +19,4 @@ cd $GAMEDIR
# export game library directory # export game library directory
test -n "${LIBDIR}" && export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GAMEDIR}/${LIBDIR}" test -n "${LIBDIR}" && export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GAMEDIR}/${LIBDIR}"
./megaglest_configurator ./megaglest_configurator $@

View File

@@ -120,4 +120,4 @@ findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME}" "$DIRECTF
findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2"
findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2"
"$GAMEDIR/megaglest_g3dviewer" "$1" "$GAMEDIR/megaglest_g3dviewer" $@

View File

@@ -120,4 +120,4 @@ findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECTFB_LINKEDLIBNAME}" "$DIRECTF
findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${FUSION_LINKEDLIBNAME}" "$FUSION_LIBLOOKUP1" "$FUSION_LIBLOOKUP2"
findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2" findMissingSO "$LDCONFIG" "$GAMEDIR/$LIBDIR/${DIRECT_LINKEDLIBNAME}" "$DIRECT_LIBLOOKUP1" "$DIRECT_LIBLOOKUP2"
"$GAMEDIR/megaglest_editor" "$1" "$GAMEDIR/megaglest_editor" $@

Binary file not shown.

View File

@@ -16,6 +16,7 @@
#include "xml_parser.h" #include "xml_parser.h"
#include "util.h" #include "util.h"
#include "conversion.h" #include "conversion.h"
#include <memory>
#include"platform_util.h" #include"platform_util.h"
using namespace std; using namespace std;

View File

@@ -24,6 +24,7 @@
#include "util.h" #include "util.h"
#include <wx/stdpaths.h> #include <wx/stdpaths.h>
#include <platform_util.h> #include <platform_util.h>
#include <memory>
using namespace std; using namespace std;
using namespace Shared::PlatformCommon; using namespace Shared::PlatformCommon;

View File

@@ -105,6 +105,7 @@ const wxChar *GAME_ARGS[] = {
wxT("--rotate-x-value"), wxT("--rotate-x-value"),
wxT("--rotate-y-value"), wxT("--rotate-y-value"),
wxT("--screenshot-format"), wxT("--screenshot-format"),
wxT("--verbose"),
}; };
enum GAME_ARG_TYPE { enum GAME_ARG_TYPE {
@@ -121,6 +122,7 @@ enum GAME_ARG_TYPE {
GAME_ARG_ROTATE_X_VALUE, GAME_ARG_ROTATE_X_VALUE,
GAME_ARG_ROTATE_Y_VALUE, GAME_ARG_ROTATE_Y_VALUE,
GAME_ARG_SCREENSHOT_FORMAT, GAME_ARG_SCREENSHOT_FORMAT,
GAME_ARG_VERBOSE,
}; };
bool hasCommandArgument(int argc, wxChar** argv,const string argName, bool hasCommandArgument(int argc, wxChar** argv,const string argName,
@@ -197,9 +199,9 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
printf("\n \t\t of the optional settings:"); printf("\n \t\t of the optional settings:");
printf("\n \t\ttransparent, enable_grid, enable_wireframe,"); printf("\n \t\ttransparent, enable_grid, enable_wireframe,");
printf("\n \t\tenable_normals, disable_grid, disable_wireframe,"); printf("\n \t\tenable_normals, disable_grid, disable_wireframe,");
printf("\n \t\tdisable_normals, saveas-<filename>"); printf("\n \t\tdisable_normals, saveas-<filename>, resize-wxh");
printf("\n \t\texample:"); printf("\n \t\texample:");
printf("\n %s %s=transparent,disable_grid,saveas-test.png %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL])); printf("\n %s %s=transparent,disable_grid,saveas-test.png,resize-800x600 %s=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d",extractFileFromDirectoryPath(argv0).c_str(),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT]),(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_MODEL]));
// "================================================================================" // "================================================================================"
printf("\n%s=x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_PARTICLE])); printf("\n%s=x",(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_LOAD_PARTICLE]));
@@ -258,6 +260,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) {
bool autoScreenShotAndExit = false; bool autoScreenShotAndExit = false;
vector<string> autoScreenShotParams; vector<string> autoScreenShotParams;
std::pair<int,int> overrideSize(0,0);
// =============================================== // ===============================================
// class MainWindow // class MainWindow
@@ -291,6 +294,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad,
//getGlPlatformExtensions(); //getGlPlatformExtensions();
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
glCanvas = new GlCanvas(this, args); glCanvas = new GlCanvas(this, args);
#if wxCHECK_VERSION(2, 9, 1) #if wxCHECK_VERSION(2, 9, 1)
@@ -567,31 +571,25 @@ void MainWindow::onPaint(wxPaintEvent &event) {
setupStartupSettings(); setupStartupSettings();
} }
//wxClientDC &dc = event.GetDC();
// wxPaintDC dc(this);
// if(overrideSize.first > 0 && overrideSize.second > 0) {
// wxRect r(0,0,100,100);
// dc.SetDeviceClippingRegion(r);
// // Then I destroy the clipping region
// dc.DestroyClippingRegion();
// }
// notice that we use GetSize() here and not GetClientSize() because // notice that we use GetSize() here and not GetClientSize() because
// the latter doesn't return correct results for the minimized windows // the latter doesn't return correct results for the minimized windows
// (at least not under Windows) // (at least not under Windows)
int viewportW = GetClientSize().x;
int viewportH = GetClientSize().y;
#if defined(WIN32) #if defined(WIN32)
/* renderer->reset(viewportW, viewportH, playerColor);
//Seems like windows cannot handle this consistently
if(autoScreenShotAndExit == true) {
printf("\n\n$$$ GetSize() x = %d y = %d, Renderer::windowW = %d H = %d\n",GetSize().x,GetSize().y,Renderer::windowW,Renderer::windowH);
//renderer->reset(GetSize().x, GetSize().y-10, playerColor);
//renderer->reset(Renderer::windowW, Renderer::windowH-20, playerColor);
//this->Iconize(false);
//this->Refresh();
//renderer->reset(GetClientSize().x, GetClientSize().y, playerColor);
renderer->reset(Renderer::windowW, Renderer::windowH-20, playerColor);
}
else {
printf("\n\n### GetClientSize() x = %d y = %d\n",GetClientSize().x,GetClientSize().y);
renderer->reset(GetClientSize().x, GetClientSize().y, playerColor);
}
*/
renderer->reset(GetClientSize().x, GetClientSize().y, playerColor);
#else #else
renderer->reset(GetClientSize().x, GetClientSize().y, playerColor); renderer->reset(viewportW, viewportH, playerColor);
#endif #endif
renderer->transform(rotX, rotY, zoom); renderer->transform(rotX, rotY, zoom);
@@ -616,7 +614,6 @@ void MainWindow::onPaint(wxPaintEvent &event) {
} }
renderer->renderParticleManager(); renderer->renderParticleManager();
glCanvas->SwapBuffers();
bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false); bool haveLoadedParticles = (particleProjectilePathList.empty() == false || particleSplashPathList.empty() == false);
@@ -629,7 +626,10 @@ void MainWindow::onPaint(wxPaintEvent &event) {
Close(); Close();
return; return;
} }
else if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) {
glCanvas->SwapBuffers();
if((modelPathList.empty() == false) && resetAnimation && haveLoadedParticles) {
if(anim >= resetAnim && resetAnim > 0) { if(anim >= resetAnim && resetAnim > 0) {
printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim); printf("RESETTING EVERYTHING [%f][%f]...\n",anim,resetAnim);
fflush(stdout); fflush(stdout);
@@ -963,7 +963,7 @@ void MainWindow::saveScreenshot() {
FILE *f= fopen(saveAsFilename.c_str(), "rb"); FILE *f= fopen(saveAsFilename.c_str(), "rb");
#endif #endif
if(f == NULL) { if(f == NULL) {
renderer->saveScreen(saveAsFilename.c_str()); renderer->saveScreen(saveAsFilename.c_str(),&overrideSize);
} }
else { else {
if(f) { if(f) {
@@ -998,7 +998,7 @@ void MainWindow::saveScreenshot() {
FILE *f= fopen(path.c_str(), "rb"); FILE *f= fopen(path.c_str(), "rb");
#endif #endif
if(f == NULL) { if(f == NULL) {
renderer->saveScreen(path); renderer->saveScreen(path,&overrideSize);
break; break;
} }
else { else {
@@ -1095,10 +1095,11 @@ void MainWindow::loadUnit(string path, string skillName) {
string skillParticleFile = ""; string skillParticleFile = "";
string skillParticleProjectileFile = ""; string skillParticleProjectileFile = "";
string skillParticleSplashFile = ""; string skillParticleSplashFile = "";
bool fileFound = fileExists(unitXML);
printf("Loading unit from file [%s]\n",unitXML.c_str()); printf("Loading unit from file [%s] fileFound = %d\n",unitXML.c_str(),fileFound);
if(fileExists(unitXML) == true) { if(fileFound == true) {
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues()); xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *unitNode= xmlTree.getRootNode();
@@ -1270,15 +1271,19 @@ void MainWindow::loadParticle(string path) {
//int height = -1; //int height = -1;
if(fileExists(unitXML) == true) { if(fileExists(unitXML) == true) {
int size = 0;
int height= 0;
{
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues()); xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *unitNode= xmlTree.getRootNode();
const XmlNode *parametersNode= unitNode->getChild("parameters"); const XmlNode *parametersNode= unitNode->getChild("parameters");
//size //size
int size= parametersNode->getChild("size")->getAttribute("value")->getIntValue(); size= parametersNode->getChild("size")->getAttribute("value")->getIntValue();
//height //height
int height= parametersNode->getChild("height")->getAttribute("value")->getIntValue(); height= parametersNode->getChild("height")->getAttribute("value")->getIntValue();
}
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
@@ -1323,6 +1328,8 @@ void MainWindow::loadParticle(string path) {
} }
void MainWindow::loadProjectileParticle(string path) { void MainWindow::loadProjectileParticle(string path) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleProjectilePathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleProjectilePathList.size());
if(timer) timer->Stop(); if(timer) timer->Stop();
if(path != "" && fileExists(path) == true) { if(path != "" && fileExists(path) == true) {
renderer->end(); renderer->end();
@@ -1342,7 +1349,7 @@ void MainWindow::loadProjectileParticle(string path) {
try { try {
if(this->particleProjectilePathList.empty() == false) { if(this->particleProjectilePathList.empty() == false) {
printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("this->particleProjectilePathList.size() = %lu\n",this->particleProjectilePathList.size());
string titlestring=winHeader; string titlestring=winHeader;
for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) { for(unsigned int idx = 0; idx < this->particleProjectilePathList.size(); idx++) {
@@ -1363,6 +1370,8 @@ void MainWindow::loadProjectileParticle(string path) {
int height = -1; int height = -1;
if(fileExists(unitXML) == true) { if(fileExists(unitXML) == true) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,unitXML.c_str(),idx);
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(unitXML,Properties::getTagReplacementValues()); xmlTree.load(unitXML,Properties::getTagReplacementValues());
const XmlNode *unitNode= xmlTree.getRootNode(); const XmlNode *unitNode= xmlTree.getRootNode();
@@ -1375,18 +1384,21 @@ void MainWindow::loadProjectileParticle(string path) {
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
string particleFile = dir + folderDelimiter + particlePath;
{ {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); xmlTree.load(particleFile,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode(); //const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl; // std::cout << "Loaded successfully, loading values..." << std::endl;
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loading [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
std::map<string,vector<pair<string, string> > > loadedFileList; std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile(); ParticleSystemTypeProjectile *projectileParticleSystemType= new ParticleSystemTypeProjectile();
projectileParticleSystemType->load(NULL, dir, //### we don't know if there are overrides in the unit XML projectileParticleSystemType->load(NULL, dir, //### we don't know if there are overrides in the unit XML
dir + folderDelimiter + particlePath,renderer, loadedFileList, particleFile,renderer, loadedFileList,
"g3dviewer",""); "g3dviewer","");
// std::cout << "Values loaded, about to read..." << std::endl; // std::cout << "Values loaded, about to read..." << std::endl;
@@ -1412,6 +1424,8 @@ void MainWindow::loadProjectileParticle(string path) {
ps->setVisible(true); ps->setVisible(true);
renderer->manageParticleSystem(ps); renderer->manageParticleSystem(ps);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] loaded [%s] idx = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,particleFile.c_str(),idx);
} }
SetTitle(ToUnicode(titlestring)); SetTitle(ToUnicode(titlestring));
@@ -1428,9 +1442,12 @@ void MainWindow::loadProjectileParticle(string path) {
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
if(timer) timer->Start(100); if(timer) timer->Start(100);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
} }
void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...) void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSplash::load (and own list...)
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size());
if(timer) timer->Stop(); if(timer) timer->Stop();
if(path != "" && fileExists(path) == true) { if(path != "" && fileExists(path) == true) {
renderer->end(); renderer->end();
@@ -1481,11 +1498,12 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
// std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl; // std::cout << "About to load [" << particlePath << "] from [" << dir << "] unit [" << unitXML << "]" << std::endl;
{
XmlTree xmlTree; XmlTree xmlTree;
xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues()); xmlTree.load(dir + folderDelimiter + particlePath,Properties::getTagReplacementValues());
//const XmlNode *particleSystemNode= xmlTree.getRootNode(); //const XmlNode *particleSystemNode= xmlTree.getRootNode();
// std::cout << "Loaded successfully, loading values..." << std::endl; // std::cout << "Loaded successfully, loading values..." << std::endl;
}
std::map<string,vector<pair<string, string> > > loadedFileList; std::map<string,vector<pair<string, string> > > loadedFileList;
ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash(); ParticleSystemTypeSplash *splashParticleSystemType= new ParticleSystemTypeSplash();
@@ -1531,6 +1549,7 @@ void MainWindow::loadSplashParticle(string path) { // uses ParticleSystemTypeSp
wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal(); wxMessageDialog(NULL, ToUnicode(e.what()), ToUnicode("Not a Mega-Glest projectile particle XML file, or broken"), wxOK | wxICON_ERROR).ShowModal();
} }
if(timer) timer->Start(100); if(timer) timer->Start(100);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] after load [%s] particleSplashPathList.size() = %lu\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),this->particleSplashPathList.size());
} }
void MainWindow::onMenuModeNormals(wxCommandEvent &event){ void MainWindow::onMenuModeNormals(wxCommandEvent &event){
@@ -1980,6 +1999,10 @@ END_EVENT_TABLE()
bool App::OnInit() { bool App::OnInit() {
SystemFlags::VERBOSE_MODE_ENABLED = false; SystemFlags::VERBOSE_MODE_ENABLED = false;
//Renderer::windowW = 1920;
//Renderer::windowH = 1440;
//Renderer::windowX= 0;
//Renderer::windowY= 0;
string modelPath=""; string modelPath="";
string particlePath=""; string particlePath="";
@@ -2005,6 +2028,10 @@ bool App::OnInit() {
return false; return false;
} }
if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_VERBOSE])) == true) {
SystemFlags::VERBOSE_MODE_ENABLED = true;
}
if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT])) == true) { if(hasCommandArgument(argc, argv,(const char *)wxConvCurrent->cWX2MB(GAME_ARGS[GAME_ARG_AUTO_SCREENSHOT])) == true) {
autoScreenShotAndExit = true; autoScreenShotAndExit = true;
@@ -2026,13 +2053,29 @@ bool App::OnInit() {
autoScreenShotParams.clear(); autoScreenShotParams.clear();
Tokenize(optionsValue,autoScreenShotParams,","); Tokenize(optionsValue,autoScreenShotParams,",");
#ifdef WIN32
for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) { for(unsigned int i = 0; i < autoScreenShotParams.size(); ++i) {
#ifdef WIN32
std::auto_ptr<wchar_t> wstr(Ansi2WideString(autoScreenShotParams[i].c_str())); std::auto_ptr<wchar_t> wstr(Ansi2WideString(autoScreenShotParams[i].c_str()));
autoScreenShotParams[i] = utf8_encode(wstr.get()); autoScreenShotParams[i] = utf8_encode(wstr.get());
}
#endif #endif
if(_strnicmp(autoScreenShotParams[i].c_str(),"resize-",7) == 0) {
printf("Screenshot option [%s]\n",autoScreenShotParams[i].c_str());
string resize = autoScreenShotParams[i];
resize = resize.erase(0,7);
vector<string> values;
Tokenize(resize,values,"x");
overrideSize.first = strToInt(values[0]);
overrideSize.second = strToInt(values[1]);
Renderer::windowX= 0;
Renderer::windowY= 0;
Renderer::windowW = overrideSize.first;
Renderer::windowH = overrideSize.second + 25;
}
}
} }
} }

View File

@@ -21,6 +21,11 @@ using namespace Shared::Graphics::Gl;
namespace Shared{ namespace G3dViewer{ namespace Shared{ namespace G3dViewer{
int Renderer::windowX= 100;
int Renderer::windowY= 100;
int Renderer::windowW= 640;
int Renderer::windowH= 480;
// =============================================== // ===============================================
// class MeshCallbackTeamColor // class MeshCallbackTeamColor
// =============================================== // ===============================================
@@ -483,16 +488,21 @@ void Renderer::setAlphaColor(float alpha) {
//printf("#3.1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits); //printf("#3.1 The framebuffer uses %d bit(s) per the alpha component\n", alpha_bits);
} }
void Renderer::saveScreen(const string &path) { void Renderer::saveScreen(const string &path,std::pair<int,int> *overrideSize) {
Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 4); Pixmap2D *pixmapScreenShot = new Pixmap2D(width, height, 4);
glFinish(); //glFinish();
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(),GL_RGBA, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels()); glReadPixels(0, 0, pixmapScreenShot->getW(), pixmapScreenShot->getH(),
GL_RGBA, GL_UNSIGNED_BYTE, pixmapScreenShot->getPixels());
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
//if(overrideSize != NULL && overrideSize->first > 0 && overrideSize->second > 0) {
// pixmapScreenShot->Scale(GL_RGBA,overrideSize->first,overrideSize->second);
//}
pixmapScreenShot->save(path); pixmapScreenShot->save(path);
delete pixmapScreenShot; delete pixmapScreenShot;
} }

View File

@@ -68,10 +68,10 @@ public:
class Renderer : public RendererInterface { class Renderer : public RendererInterface {
public: public:
static const int windowX= 100; static int windowX;
static const int windowY= 100; static int windowY;
static const int windowW= 640; static int windowW;
static const int windowH= 480; static int windowH;
public: public:
enum PlayerColor{ enum PlayerColor{
@@ -157,7 +157,7 @@ public:
void setBackgroundColor(float red, float green, float blue); void setBackgroundColor(float red, float green, float blue);
void setAlphaColor(float alpha); void setAlphaColor(float alpha);
void saveScreen(const string &path); void saveScreen(const string &path,std::pair<int,int> *overrideSize);
bool hasActiveParticleSystem(ParticleSystem::ParticleSystemType typeName) const; bool hasActiveParticleSystem(ParticleSystem::ParticleSystemType typeName) const;
}; };

View File

@@ -27,7 +27,7 @@ using namespace Shared::Platform;
namespace Glest { namespace Game { namespace Glest { namespace Game {
const char *mailString = " http://bugs.megaglest.org"; const char *mailString = " http://bugs.megaglest.org";
const string glestVersionString = "v3.6.0.2"; const string glestVersionString = "v3.6.0.3";
#if defined(SVNVERSION) #if defined(SVNVERSION)
const string SVN_Rev = string("Rev: ") + string(SVNVERSION); const string SVN_Rev = string("Rev: ") + string(SVNVERSION);
#elif defined(SVNVERSIONHEADER) #elif defined(SVNVERSIONHEADER)

View File

@@ -147,7 +147,7 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
if(foundPath == false) { if(foundPath == false) {
foundPath = tryCustomPath(cfgType, fileName, CUSTOM_DATA_INSTALL_PATH); foundPath = tryCustomPath(cfgType, fileName, TOSTRING(CUSTOM_DATA_INSTALL_PATH));
} }
#endif #endif

View File

@@ -350,7 +350,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
displayFont= renderer.newFont(rsGlobal); displayFont= renderer.newFont(rsGlobal);
if(displayFont) { if(displayFont) {
displayFont->setType(displayFontName,config.getString("FontDisplay","")); displayFont->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
displayFont->setSize(displayFontSize); displayFont->setSize(displayFontSize);
//displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFont->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -363,7 +363,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
displayFont3D= renderer.newFont3D(rsGlobal); displayFont3D= renderer.newFont3D(rsGlobal);
if(displayFont3D) { if(displayFont3D) {
displayFont3D->setType(displayFontName,config.getString("FontDisplay","")); displayFont3D->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
displayFont3D->setSize(displayFontSize); displayFont3D->setSize(displayFontSize);
//displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFont3D->setYOffsetFactor(config.getFloat("FontDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -395,7 +395,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
displayFontSmall= renderer.newFont(rsGlobal); displayFontSmall= renderer.newFont(rsGlobal);
if(displayFontSmall) { if(displayFontSmall) {
displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
displayFontSmall->setSize(displayFontNameSmallSize); displayFontSmall->setSize(displayFontNameSmallSize);
//displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFontSmall->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -408,7 +408,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
displayFontSmall3D= renderer.newFont3D(rsGlobal); displayFontSmall3D= renderer.newFont3D(rsGlobal);
if(displayFontSmall3D) { if(displayFontSmall3D) {
displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay","")); displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
displayFontSmall3D->setSize(displayFontNameSmallSize); displayFontSmall3D->setSize(displayFontNameSmallSize);
//displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //displayFontSmall3D->setYOffsetFactor(config.getFloat("FontSmallDisplayYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -439,7 +439,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontNormal= renderer.newFont(rsGlobal); menuFontNormal= renderer.newFont(rsGlobal);
if(menuFontNormal) { if(menuFontNormal) {
menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
menuFontNormal->setSize(menuFontNameNormalSize); menuFontNormal->setSize(menuFontNameNormalSize);
menuFontNormal->setWidth(Font::wBold); menuFontNormal->setWidth(Font::wBold);
//menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontNormal->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
@@ -453,7 +453,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontNormal3D= renderer.newFont3D(rsGlobal); menuFontNormal3D= renderer.newFont3D(rsGlobal);
if(menuFontNormal3D) { if(menuFontNormal3D) {
menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal","")); menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
menuFontNormal3D->setSize(menuFontNameNormalSize); menuFontNormal3D->setSize(menuFontNameNormalSize);
menuFontNormal3D->setWidth(Font::wBold); menuFontNormal3D->setWidth(Font::wBold);
//menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontNormal3D->setYOffsetFactor(config.getFloat("FontMenuNormalYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
@@ -485,7 +485,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontBig= renderer.newFont(rsGlobal); menuFontBig= renderer.newFont(rsGlobal);
if(menuFontBig) { if(menuFontBig) {
menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig","")); menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
menuFontBig->setSize(menuFontNameBigSize); menuFontBig->setSize(menuFontNameBigSize);
//menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontBig->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -498,7 +498,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontBig3D= renderer.newFont3D(rsGlobal); menuFontBig3D= renderer.newFont3D(rsGlobal);
if(menuFontBig3D) { if(menuFontBig3D) {
menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig","")); menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
menuFontBig3D->setSize(menuFontNameBigSize); menuFontBig3D->setSize(menuFontNameBigSize);
//menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontBig3D->setYOffsetFactor(config.getFloat("FontMenuBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -529,7 +529,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
menuFontVeryBig= renderer.newFont(rsGlobal); menuFontVeryBig= renderer.newFont(rsGlobal);
if(menuFontVeryBig) { if(menuFontVeryBig) {
menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
menuFontVeryBig->setSize(menuFontNameVeryBigSize); menuFontVeryBig->setSize(menuFontNameVeryBigSize);
//menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontVeryBig->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -542,7 +542,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
menuFontVeryBig3D= renderer.newFont3D(rsGlobal); menuFontVeryBig3D= renderer.newFont3D(rsGlobal);
if(menuFontVeryBig3D) { if(menuFontVeryBig3D) {
menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig","")); menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
menuFontVeryBig3D->setSize(menuFontNameVeryBigSize); menuFontVeryBig3D->setSize(menuFontNameVeryBigSize);
//menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //menuFontVeryBig3D->setYOffsetFactor(config.getFloat("FontMenuVeryBigYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -576,7 +576,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == false) { if(Renderer::renderText3DEnabled == false) {
consoleFont= renderer.newFont(rsGlobal); consoleFont= renderer.newFont(rsGlobal);
if(consoleFont) { if(consoleFont) {
consoleFont->setType(consoleFontName,config.getString("FontConsole","")); consoleFont->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
consoleFont->setSize(consoleFontNameSize); consoleFont->setSize(consoleFontNameSize);
//consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //consoleFont->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }
@@ -589,7 +589,7 @@ void CoreData::loadFonts() {
if(Renderer::renderText3DEnabled == true) { if(Renderer::renderText3DEnabled == true) {
consoleFont3D= renderer.newFont3D(rsGlobal); consoleFont3D= renderer.newFont3D(rsGlobal);
if(consoleFont3D) { if(consoleFont3D) {
consoleFont3D->setType(consoleFontName,config.getString("FontConsole","")); consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
consoleFont3D->setSize(consoleFontNameSize); consoleFont3D->setSize(consoleFontNameSize);
//consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str())); //consoleFont3D->setYOffsetFactor(config.getFloat("FontConsoleYOffsetFactor",floatToStr(FontMetrics::DEFAULT_Y_OFFSET_FACTOR).c_str()));
} }

View File

@@ -107,6 +107,15 @@ void Lang::loadStrings(string uselanguage, bool loadFonts,
#endif #endif
} }
if( lang.hasString("MEGAGLEST_FONT_FAMILY")) {
#if defined(WIN32)
string newEnvValue = "MEGAGLEST_FONT_FAMILY=" + lang.get("MEGAGLEST_FONT_FAMILY");
_putenv(newEnvValue.c_str());
#else
setenv("MEGAGLEST_FONT_FAMILY",lang.get("MEGAGLEST_FONT_FAMILY").c_str(),0);
#endif
}
// if( lang.hasString("FONT_YOFFSET_FACTOR")) { // if( lang.hasString("FONT_YOFFSET_FACTOR")) {
// FontMetrics::DEFAULT_Y_OFFSET_FACTOR = strToFloat(lang.get("FONT_YOFFSET_FACTOR")); // FontMetrics::DEFAULT_Y_OFFSET_FACTOR = strToFloat(lang.get("FONT_YOFFSET_FACTOR"));
// } // }

View File

@@ -43,7 +43,8 @@ ParticleSystemType::ParticleSystemType() {
teamcolorNoEnergy=false; teamcolorNoEnergy=false;
teamcolorEnergy=false; teamcolorEnergy=false;
alternations=false; alternations=0;
particleSystemStartDelay=0;
texture=NULL; texture=NULL;
model=NULL; model=NULL;
minmaxEnabled=false; minmaxEnabled=false;
@@ -101,6 +102,7 @@ void ParticleSystemType::copyAll(const ParticleSystemType &src) {
this->teamcolorNoEnergy = src.teamcolorNoEnergy; this->teamcolorNoEnergy = src.teamcolorNoEnergy;
this->teamcolorEnergy = src.teamcolorEnergy; this->teamcolorEnergy = src.teamcolorEnergy;
this->alternations = src.alternations; this->alternations = src.alternations;
this->particleSystemStartDelay= src.particleSystemStartDelay;
for(Children::iterator it = children.begin(); it != children.end(); ++it) { for(Children::iterator it = children.begin(); it != children.end(); ++it) {
UnitParticleSystemType *child = *it; UnitParticleSystemType *child = *it;
@@ -239,6 +241,11 @@ void ParticleSystemType::load(const XmlNode *particleSystemNode, const string &d
const XmlNode *alternatingNode= particleSystemNode->getChild("alternations"); const XmlNode *alternatingNode= particleSystemNode->getChild("alternations");
alternations= alternatingNode->getAttribute("value")->getIntValue(); alternations= alternatingNode->getAttribute("value")->getIntValue();
} }
//particleSystemStartDelay
if(particleSystemNode->hasChild("particleSystemStartDelay")){
const XmlNode *node= particleSystemNode->getChild("particleSystemStartDelay");
particleSystemStartDelay= node->getAttribute("value")->getIntValue();
}
//mode //mode
if(particleSystemNode->hasChild("mode")) { if(particleSystemNode->hasChild("mode")) {
const XmlNode *modeNode= particleSystemNode->getChild("mode"); const XmlNode *modeNode= particleSystemNode->getChild("mode");
@@ -293,6 +300,7 @@ void ParticleSystemType::setValues(AttackParticleSystem *ats){
ats->setTeamcolorNoEnergy(teamcolorNoEnergy); ats->setTeamcolorNoEnergy(teamcolorNoEnergy);
ats->setTeamcolorEnergy(teamcolorEnergy); ats->setTeamcolorEnergy(teamcolorEnergy);
ats->setAlternations(alternations); ats->setAlternations(alternations);
ats->setParticleSystemStartDelay(particleSystemStartDelay);
ats->setBlendMode(ParticleSystem::strToBlendMode(mode)); ats->setBlendMode(ParticleSystem::strToBlendMode(mode));
} }

View File

@@ -69,6 +69,7 @@ protected:
bool teamcolorNoEnergy; bool teamcolorNoEnergy;
bool teamcolorEnergy; bool teamcolorEnergy;
int alternations; int alternations;
int particleSystemStartDelay;
typedef std::list<UnitParticleSystemType*> Children; typedef std::list<UnitParticleSystemType*> Children;
Children children; Children children;

View File

@@ -839,7 +839,7 @@ void Renderer::setupLighting() {
assertGl(); assertGl();
//sun/moon light //sun/moon light
Vec3f lightColor= computeLightColor(time); Vec3f lightColor= timeFlow->computeLightColor();
Vec3f fogColor= world->getTileset()->getFogColor(); Vec3f fogColor= world->getTileset()->getFogColor();
Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time); Vec4f lightPos= timeFlow->isDay()? computeSunPos(time): computeMoonPos(time);
nearestLightPos= lightPos; nearestLightPos= lightPos;
@@ -3260,7 +3260,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOVertices ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, vertices, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
assertGl(); assertGl();
// Generate And Bind The Texture Coordinate Buffer // Generate And Bind The Texture Coordinate Buffer
@@ -3268,7 +3268,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOFowTexCoords ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoords, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
assertGl(); assertGl();
// Generate And Bind The Texture Coordinate Buffer // Generate And Bind The Texture Coordinate Buffer
@@ -3276,7 +3276,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBOSurfaceTexCoords ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f) * cellData->bufferCount, texCoordsSurface, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
assertGl(); assertGl();
// Generate And Bind The Normal Buffer // Generate And Bind The Normal Buffer
@@ -3284,7 +3284,7 @@ VisibleQuadContainerVBOCache * Renderer::GetSurfaceVBOs(SurfaceData *cellData) {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache.m_nVBONormals ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f) * cellData->bufferCount, normals, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
vboCache.hasBuiltVBOs = true; vboCache.hasBuiltVBOs = true;
@@ -3333,7 +3333,7 @@ template<typename T> void _loadVBO(GLuint &vbo,std::vector<T> buf,int target=GL_
assert(vbo); assert(vbo);
glBindBufferARB(target,vbo); glBindBufferARB(target,vbo);
glBufferDataARB(target,sizeof(T)*buf.size(),&buf[0],GL_STATIC_DRAW_ARB); glBufferDataARB(target,sizeof(T)*buf.size(),&buf[0],GL_STATIC_DRAW_ARB);
glBindBuffer(target,0); glBindBufferARB(target,0);
assertGl(); assertGl();
buf.clear(); buf.clear();
} }
@@ -4183,7 +4183,7 @@ void Renderer::renderObjects(const int renderFps) {
const Texture2D *fowTex = world->getMinimap()->getFowTexture(); const Texture2D *fowTex = world->getMinimap()->getFowTexture();
const Pixmap2D *fowTexPixmap = fowTex->getPixmapConst(); const Pixmap2D *fowTexPixmap = fowTex->getPixmapConst();
Vec3f baseFogColor = world->getTileset()->getFogColor() * computeLightColor(world->getTimeFlow()->getTime()); Vec3f baseFogColor = world->getTileset()->getFogColor() * world->getTimeFlow()->computeLightColor();
bool modelRenderStarted = false; bool modelRenderStarted = false;
@@ -6395,7 +6395,7 @@ void Renderer::saveScreen(const string &path) {
Pixmap2D *pixmapScreenShot = new Pixmap2D(sm.getScreenW(), sm.getScreenH(), 3); Pixmap2D *pixmapScreenShot = new Pixmap2D(sm.getScreenW(), sm.getScreenH(), 3);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
glFinish(); //glFinish();
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
@@ -6461,35 +6461,6 @@ Vec4f Renderer::computeMoonPos(float time) {
#endif #endif
} }
Vec3f Renderer::computeLightColor(float time) {
const Tileset *tileset= game->getWorld()->getTileset();
Vec3f color;
const float transition= 2;
const float dayStart= TimeFlow::dawn;
const float dayEnd= TimeFlow::dusk-transition;
const float nightStart= TimeFlow::dusk;
const float nightEnd= TimeFlow::dawn-transition;
if(time>dayStart && time<dayEnd) {
color= tileset->getSunLightColor();
}
else if(time>nightStart || time<nightEnd) {
color= tileset->getMoonLightColor();
}
else if(time>=dayEnd && time<=nightStart) {
color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor());
}
else if(time>=nightEnd && time<=dayStart) {
color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor());
}
else {
assert(false);
color= tileset->getSunLightColor();
}
return color;
}
Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) { Vec4f Renderer::computeWaterColor(float waterLevel, float cellHeight) {
const float waterFactor= 1.5f; const float waterFactor= 1.5f;
return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f)); return Vec4f(1.f, 1.f, 1.f, clamp((waterLevel-cellHeight)*waterFactor, 0.f, 1.f));

View File

@@ -581,7 +581,6 @@ private:
float computeMoonAngle(float time); float computeMoonAngle(float time);
Vec4f computeSunPos(float time); Vec4f computeSunPos(float time);
Vec4f computeMoonPos(float time); Vec4f computeMoonPos(float time);
Vec3f computeLightColor(float time);
Vec4f computeWaterColor(float waterLevel, float cellHeight); Vec4f computeWaterColor(float waterLevel, float cellHeight);
void checkExtension(const string &extension, const string &msg); void checkExtension(const string &extension, const string &msg);

View File

@@ -40,8 +40,9 @@ UnitParticleSystemType::UnitParticleSystemType() : ParticleSystemType() {
relativeDirection = false; relativeDirection = false;
fixed = false; fixed = false;
staticParticleCount = 0; staticParticleCount = 0;
isVisibleAtNight = false; isVisibleAtNight = true;
isVisibleAtDay = false; isVisibleAtDay = true;
isDaylightAffected = false;
radiusBasedStartenergy = false; radiusBasedStartenergy = false;
delay = 0; delay = 0;
lifetime = 0; lifetime = 0;
@@ -146,6 +147,15 @@ void UnitParticleSystemType::load(const XmlNode *particleSystemNode, const strin
isVisibleAtDay=true; isVisibleAtDay=true;
} }
//isDaylightAffected
if(particleSystemNode->hasChild("isDaylightAffected")){
const XmlNode *node= particleSystemNode->getChild("isDaylightAffected");
isDaylightAffected= node->getAttribute("value")->getBoolValue();
}
else {
isDaylightAffected=false;
}
//radiusBasedStartenergy //radiusBasedStartenergy
if(particleSystemNode->hasChild("radiusBasedStartenergy")){ if(particleSystemNode->hasChild("radiusBasedStartenergy")){
const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy"); const XmlNode *isVisibleAtDayNode= particleSystemNode->getChild("radiusBasedStartenergy");
@@ -217,9 +227,11 @@ const void UnitParticleSystemType::setValues(UnitParticleSystem *ups){
ups->setTeamcolorNoEnergy(teamcolorNoEnergy); ups->setTeamcolorNoEnergy(teamcolorNoEnergy);
ups->setTeamcolorEnergy(teamcolorEnergy); ups->setTeamcolorEnergy(teamcolorEnergy);
ups->setAlternations(alternations); ups->setAlternations(alternations);
ups->setParticleSystemStartDelay(particleSystemStartDelay);
ups->setIsVisibleAtNight(isVisibleAtNight); ups->setIsVisibleAtNight(isVisibleAtNight);
ups->setIsVisibleAtDay(isVisibleAtDay); ups->setIsVisibleAtDay(isVisibleAtDay);
ups->setIsDaylightAffected(isDaylightAffected);
ups->setStaticParticleCount(staticParticleCount); ups->setStaticParticleCount(staticParticleCount);
ups->setRadius(radius); ups->setRadius(radius);
ups->setMinRadius(minRadius); ups->setMinRadius(minRadius);

View File

@@ -58,6 +58,7 @@ protected:
int staticParticleCount; int staticParticleCount;
bool isVisibleAtNight; bool isVisibleAtNight;
bool isVisibleAtDay; bool isVisibleAtDay;
bool isDaylightAffected;
bool radiusBasedStartenergy; bool radiusBasedStartenergy;
int delay; int delay;
int lifetime; int lifetime;

View File

@@ -237,7 +237,7 @@ void BattleEnd::render() {
} }
realPlayerCount++; realPlayerCount++;
int textX= lm + 60 + (realPlayerCount*110); int textX= lm + 60 + (realPlayerCount*100);
int team= stats.getTeam(i) + 1; int team= stats.getTeam(i) + 1;
int kills= stats.getKills(i); int kills= stats.getKills(i);
int enemykills= stats.getEnemyKills(i); int enemykills= stats.getEnemyKills(i);
@@ -292,7 +292,7 @@ void BattleEnd::render() {
} }
if(stats.getControl(i) != ctHuman && stats.getControl(i) != ctNetwork ) { if(stats.getControl(i) != ctHuman && stats.getControl(i) != ctNetwork ) {
controlString += " x " + floatToStr(stats.getResourceMultiplier(i),1); controlString += "\nx " + floatToStr(stats.getResourceMultiplier(i),1);
} }
if(score == bestScore && stats.getVictory(i)) { if(score == bestScore && stats.getVictory(i)) {
@@ -408,7 +408,7 @@ void BattleEnd::render() {
//GameConstants::updateFps //GameConstants::updateFps
//string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2); //string header2 = lang.get("GameDuration") + " " + floatToStr(stats.getWorldTimeElapsed() / 24.0,2);
string header2 = lang.get("GameDuration") + ": " + intToStr(stats.getFramesToCalculatePlaytime()/GameConstants::updateFps/60); string header2 = lang.get("GameDuration") + ": " + floatToStr((float)stats.getFramesToCalculatePlaytime() / (float)GameConstants::updateFps / 60.0,2);
textRenderer->render(header2, lm+250, bm+530); textRenderer->render(header2, lm+250, bm+530);
header2 = lang.get("GameMaxConcurrentUnitCount") + ": " + intToStr(stats.getMaxConcurrentUnitCount()); header2 = lang.get("GameMaxConcurrentUnitCount") + ": " + intToStr(stats.getMaxConcurrentUnitCount());

View File

@@ -2459,7 +2459,7 @@ int glestMain(int argc, char** argv) {
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",CUSTOM_DATA_INSTALL_PATH); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("\n\nCUSTOM_DATA_INSTALL_PATH = [%s]\n\n",TOSTRING(CUSTOM_DATA_INSTALL_PATH));
#endif #endif
const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]); const int knownArgCount = sizeof(GAME_ARGS) / sizeof(GAME_ARGS[0]);
@@ -3543,6 +3543,10 @@ int glestMain(int argc, char** argv) {
cinfd[0].events = POLLIN; cinfd[0].events = POLLIN;
#else #else
h = GetStdHandle(STD_INPUT_HANDLE); h = GetStdHandle(STD_INPUT_HANDLE);
//DWORD dwMode;
//GetConsoleMode(h, &dwMode);
//SetConsoleMode(h, dwMode & ~ENABLE_MOUSE_INPUT);
FlushConsoleInputBuffer(h);
#endif #endif
} }
@@ -3568,10 +3572,45 @@ int glestMain(int argc, char** argv) {
// line buffer input. This does work okay as long as the user doesn't enter characters // line buffer input. This does work okay as long as the user doesn't enter characters
// without pressing enter, and then try to end the server another way (say a remote // without pressing enter, and then try to end the server another way (say a remote
// console command), in which case we'll still be waiting for the stdin EOL and hang. // console command), in which case we'll still be waiting for the stdin EOL and hang.
if (WaitForSingleObject(h, 0) == WAIT_OBJECT_0)
DWORD saveMode;
GetConsoleMode(h, &saveMode);
DWORD dwMode = saveMode;
dwMode &= ~ENABLE_MOUSE_INPUT;
dwMode &= ~ENABLE_WINDOW_INPUT;
SetConsoleMode(h, dwMode);
bool gotData = (WaitForSingleObject(h, 0) == WAIT_OBJECT_0);
SetConsoleMode(h, saveMode);
if(gotData == true)
#endif #endif
{ {
bool skip = true;
#ifdef WIN32
DWORD nNumberOfCharsToRead = 1024;
DWORD nRead = 0;
INPUT_RECORD irInRec[1025];
PeekConsoleInput(h,&irInRec[0],nNumberOfCharsToRead,&nRead);
for(int i = 0; i < nRead; ++i) {
INPUT_RECORD &inr = irInRec[i];
//printf("inr.EventType = %d\n",inr.EventType);
if(inr.EventType == KEY_EVENT) {
if(inr.Event.KeyEvent.bKeyDown) {
char cHoldKey = inr.Event.KeyEvent.uChar.AsciiChar;
if(cHoldKey == '\r') {
skip = false;
break;
}
}
}
}
#else
skip = false;
#endif
if(skip == false) {
getline(cin, command); getline(cin, command);
cin.clear(); cin.clear();
@@ -3600,6 +3639,7 @@ int glestMain(int argc, char** argv) {
#endif #endif
} }
} }
}
//printf("looping\n"); //printf("looping\n");
} }

View File

@@ -385,9 +385,9 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] about to accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] about to accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex);
Socket *newSocket = serverInterface->getServerSocket()->accept(); Socket *newSocket = serverInterface->getServerSocket()->accept(false);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d\n",__FILE__,__FUNCTION__,__LINE__,playerIndex); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] called accept new client connection playerIndex = %d newSocket = %p\n",__FILE__,__FUNCTION__,__LINE__,playerIndex,newSocket);
if(newSocket != NULL) { if(newSocket != NULL) {
// Set Socket as non-blocking // Set Socket as non-blocking
newSocket->setBlock(false); newSocket->setBlock(false);
@@ -436,14 +436,19 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
} }
else {
close();
return;
}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
} //}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
//send intro message when connected //send intro message when connected
if(hasData == true && this->isConnected() == true) { //if(hasData == true && 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(time(NULL) / (this->playerIndex + 1));
@@ -475,6 +480,7 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
} }
} }
} }
}
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
} }
else { else {
@@ -707,14 +713,14 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
throw runtime_error(szBuf); throw runtime_error(szBuf);
} }
GameSettings gameSettings; GameSettings gameSettingsBuffer;
networkMessageLaunch.buildGameSettings(&gameSettings); networkMessageLaunch.buildGameSettings(&gameSettingsBuffer);
//printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str()); //printf("Connection slot got networkMessageLaunch.getMessageType() = %d, got map [%s]\n",networkMessageLaunch.getMessageType(),gameSettings.getMap().c_str());
//printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str()); //printf("\n\n\n\n=====Connection slot got settings:\n%s\n",gameSettings.toString().c_str());
this->serverInterface->setGameSettings(&gameSettings,false); //this->serverInterface->setGameSettings(&gameSettingsBuffer,false);
this->serverInterface->broadcastGameSetup(&gameSettings); this->serverInterface->broadcastGameSetup(&gameSettingsBuffer, true);
if(networkMessageLaunch.getMessageType() == nmtLaunch) { if(networkMessageLaunch.getMessageType() == nmtLaunch) {
this->serverInterface->setMasterserverAdminRequestLaunch(true); this->serverInterface->setMasterserverAdminRequestLaunch(true);
@@ -1031,7 +1037,8 @@ void ConnectionSlot::update(bool checkForNewClients,int lockedSlotIndex) {
} }
void ConnectionSlot::validateConnection() { void ConnectionSlot::validateConnection() {
if(gotIntro == false && connectedTime > 0 && if(this->isConnected() == true &&
gotIntro == false && connectedTime > 0 &&
difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) { difftime(time(NULL),connectedTime) > GameConstants::maxClientConnectHandshakeSecs) {
close(); close();
} }
@@ -1063,6 +1070,7 @@ void ConnectionSlot::close() {
ready = false; ready = false;
gotIntro = false; gotIntro = false;
connectedTime = 0;
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] END\n",__FILE__,__FUNCTION__);
} }

View File

@@ -1708,10 +1708,17 @@ bool ServerInterface::launchGame(const GameSettings *gameSettings) {
return bOkToStart; return bOkToStart;
} }
void ServerInterface::broadcastGameSetup(const GameSettings *gameSettings) { void ServerInterface::broadcastGameSetup(GameSettings *gameSettingsBuffer, bool setGameSettingsBuffer) {
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__);
if(setGameSettingsBuffer == true) {
validateGameSettings(gameSettingsBuffer);
//setGameSettings(gameSettingsBuffer,false);
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
NetworkMessageLaunch networkMessageLaunch(gameSettings, nmtBroadCastSetup); gameSettings = *gameSettingsBuffer;
gameSettingsUpdateCount++;
}
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
NetworkMessageLaunch networkMessageLaunch(gameSettingsBuffer, nmtBroadCastSetup);
broadcastMessage(&networkMessageLaunch); broadcastMessage(&networkMessageLaunch);
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__);
} }
@@ -1833,17 +1840,47 @@ int ServerInterface::getOpenSlotCount() {
} }
int ServerInterface::getGameSettingsUpdateCount() { int ServerInterface::getGameSettingsUpdateCount() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount);
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount);
int result = gameSettingsUpdateCount; int result = gameSettingsUpdateCount;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
return result; return result;
} }
void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck) { void ServerInterface::validateGameSettings(GameSettings *serverGameSettings) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck);
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE); MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s]\n",__FILE__,__FUNCTION__);
string mapFile = serverGameSettings->getMap();
if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) {
printf("Reverting map from [%s] to [%s]\n",serverGameSettings->getMap().c_str(),gameSettings.getMap().c_str());
serverGameSettings->setMapFilterIndex(gameSettings.getMapFilterIndex());
serverGameSettings->setMap(gameSettings.getMap());
serverGameSettings->setMapCRC(gameSettings.getMapCRC());
}
string tilesetFile = serverGameSettings->getTileset();
if(find(tilesetFiles.begin(),tilesetFiles.end(),tilesetFile) == tilesetFiles.end()) {
printf("Reverting tileset from [%s] to [%s]\n",serverGameSettings->getTileset().c_str(),gameSettings.getTileset().c_str());
serverGameSettings->setTileset(gameSettings.getTileset());
serverGameSettings->setTilesetCRC(gameSettings.getTilesetCRC());
}
string techtreeFile = serverGameSettings->getTech();
if(find(techTreeFiles.begin(),techTreeFiles.end(),techtreeFile) == techTreeFiles.end()) {
printf("Reverting tech from [%s] to [%s]\n",serverGameSettings->getTech().c_str(),gameSettings.getTech().c_str());
serverGameSettings->setTech(gameSettings.getTech());
serverGameSettings->setTechCRC(gameSettings.getTechCRC());
}
}
void ServerInterface::setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck) {
MutexSafeWrapper safeMutex(serverSynchAccessor,CODE_AT_LINE);
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] START gameSettingsUpdateCount = %d, waitForClientAck = %d\n",__FILE__,__FUNCTION__,gameSettingsUpdateCount,waitForClientAck);
string mapFile = serverGameSettings->getMap(); string mapFile = serverGameSettings->getMap();
if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) { if(find(mapFiles.begin(),mapFiles.end(),mapFile) == mapFiles.end()) {

View File

@@ -124,8 +124,9 @@ public:
int getConnectedSlotCount(); int getConnectedSlotCount();
int getOpenSlotCount(); int getOpenSlotCount();
bool launchGame(const GameSettings *gameSettings); bool launchGame(const GameSettings *gameSettings);
void validateGameSettings(GameSettings *serverGameSettings);
void setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck); void setGameSettings(GameSettings *serverGameSettings, bool waitForClientAck);
void broadcastGameSetup(const GameSettings *gameSettings); void broadcastGameSetup(GameSettings *gameSettingsBuffer, bool setGameSettingsBuffer=false);
int getGameSettingsUpdateCount(); int getGameSettingsUpdateCount();

View File

@@ -55,6 +55,7 @@ void TimeFlow::update() {
soundRenderer.stopAmbient(ambientSounds->getNight()); soundRenderer.stopAmbient(ambientSounds->getNight());
UnitParticleSystem::isNight=false; UnitParticleSystem::isNight=false;
} }
UnitParticleSystem::lightColor=computeLightColor();
if((lastTime<dawn && time>=dawn) || firstTime){ if((lastTime<dawn && time>=dawn) || firstTime){
@@ -94,4 +95,35 @@ void TimeFlow::update() {
// return (this->time>=time) && (this->time<time+timeInc); // return (this->time>=time) && (this->time<time+timeInc);
//} //}
Vec3f TimeFlow::computeLightColor() const {
Vec3f color;
float time=getTime();
const float transition= 2;
const float dayStart= TimeFlow::dawn;
const float dayEnd= TimeFlow::dusk-transition;
const float nightStart= TimeFlow::dusk;
const float nightEnd= TimeFlow::dawn-transition;
if(time>dayStart && time<dayEnd) {
color= tileset->getSunLightColor();
}
else if(time>nightStart || time<nightEnd) {
color= tileset->getMoonLightColor();
}
else if(time>=dayEnd && time<=nightStart) {
color= tileset->getSunLightColor().lerp((time-dayEnd)/transition, tileset->getMoonLightColor());
}
else if(time>=nightEnd && time<=dayStart) {
color= tileset->getMoonLightColor().lerp((time-nightEnd)/transition, tileset->getSunLightColor());
}
else {
assert(false);
color= tileset->getSunLightColor();
}
return color;
}
}}//end namespace }}//end namespace

View File

@@ -57,6 +57,7 @@ public:
bool isTotalNight() const {return time<dawn+1.f || time>dusk-1.f;} bool isTotalNight() const {return time<dawn+1.f || time>dusk-1.f;}
float getTimeInc() const {return timeInc;} float getTimeInc() const {return timeInc;}
Vec3f computeLightColor() const;
void update(); void update();
private: private:
//bool isAproxTime(float time) const; //bool isAproxTime(float time) const;

View File

@@ -17,12 +17,6 @@ IF(BUILD_MEGAGLEST_MAP_EDITOR)
IF(NOT WIN32) IF(NOT WIN32)
# It was noticed that when using MinGW gcc it is essential that 'core' is mentioned before 'base'. # It was noticed that when using MinGW gcc it is essential that 'core' is mentioned before 'base'.
IF(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
SET(wxWidgets_CONFIG_OPTIONS --prefix=/usr/local)
MESSAGE(STATUS "Detected FreeBSD.....")
ENDIF()
FIND_PACKAGE(wxWidgets COMPONENTS core base gl REQUIRED) FIND_PACKAGE(wxWidgets COMPONENTS core base gl REQUIRED)
# wxWidgets include (this will do all the magic to configure everything) # wxWidgets include (this will do all the magic to configure everything)

View File

@@ -21,6 +21,7 @@
#ifndef WIN32 #ifndef WIN32
#include <errno.h> #include <errno.h>
#endif #endif
#include <memory>
using namespace Shared::Util; using namespace Shared::Util;
using namespace Shared::PlatformCommon; using namespace Shared::PlatformCommon;

View File

@@ -138,7 +138,10 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
FIND_PACKAGE(FontConfig) FIND_PACKAGE(FontConfig)
IF(FONTCONFIG_FOUND) IF(FONTCONFIG_FOUND)
MESSAGE(STATUS "**NOTE: FontConfig support was detected and enabled.")
SET(HAVE_FONTCONFIG 1) SET(HAVE_FONTCONFIG 1)
ADD_DEFINITIONS(-DHAVE_FONTCONFIG)
INCLUDE_DIRECTORIES( ${FONTCONFIG_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( ${FONTCONFIG_INCLUDE_DIR} )
SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FONTCONFIG_LIBRARIES} ) SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${FONTCONFIG_LIBRARIES} )
ENDIF(FONTCONFIG_FOUND) ENDIF(FONTCONFIG_FOUND)
@@ -348,9 +351,9 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
ENDIF() ENDIF()
# FIXME: hackish... # FIXME: hackish...
IF(WANT_STREFLOP) # IF(WANT_STREFLOP)
SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32") # SET(STREFLOP_PROPERTIES "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32")
ENDIF() # ENDIF()
SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS SET_SOURCE_FILES_PROPERTIES(${MG_SOURCE_FILES} PROPERTIES COMPILE_FLAGS
"${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}") "${PLATFORM_SPECIFIC_DEFINES} ${STREFLOP_PROPERTIES} ${CXXFLAGS}")

View File

@@ -101,7 +101,7 @@ public:
string getType() const; string getType() const;
//set //set
void setType(string typeX11, string typeGeneric); void setType(string typeX11, string typeGeneric, string typeGenericFamily);
void setWidth(int width); void setWidth(int width);
int getSize() const; int getSize() const;
@@ -139,7 +139,7 @@ public:
Font3D *ConvertFont2DTo3D(Font2D *font); Font3D *ConvertFont2DTo3D(Font2D *font);
const char* findFont(const char *firstFontToTry=NULL); const char* findFont(const char *firstFontToTry=NULL,const char *firstFontFamilyToTry=NULL);
}}//end namespace }}//end namespace

View File

@@ -36,7 +36,7 @@ public:
Text(FontTextHandlerType type); Text(FontTextHandlerType type);
virtual ~Text(); virtual ~Text();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();

View File

@@ -33,7 +33,7 @@ public:
TextFTGL(FontTextHandlerType type); TextFTGL(FontTextHandlerType type);
virtual ~TextFTGL(); virtual ~TextFTGL();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();

View File

@@ -41,7 +41,7 @@ public:
TextFreetypeGL(FontTextHandlerType type); TextFreetypeGL(FontTextHandlerType type);
virtual ~TextFreetypeGL(); virtual ~TextFreetypeGL();
virtual void init(string fontName, int fontSize); virtual void init(string fontName, string fontFamilyName, int fontSize);
virtual void SetFaceSize(int); virtual void SetFaceSize(int);
virtual int GetFaceSize(); virtual int GetFaceSize();
@@ -66,6 +66,7 @@ private:
int fontFaceSize; int fontFaceSize;
string fontName; string fontName;
string fontFamilyName;
const char* fontFile; const char* fontFile;
void cleanupFont(); void cleanupFont();

View File

@@ -43,10 +43,11 @@
#endif // _WIN32 #endif // _WIN32
#include <GL/glew.h> #include <GL/glew.h>
#ifndef _WIN32
//#include <boost/shared_ptr.hpp> #if !defined(_WIN32) || defined(__MINGW32__)
#include <tr1/memory> #include <tr1/memory>
#endif #endif
#include <stdexcept> #include <stdexcept>
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
@@ -61,7 +62,7 @@ using std::cout;
using std::endl; using std::endl;
using std::string; using std::string;
#ifdef _WIN32 #if defined(_WIN32)
using std::tr1::shared_ptr; using std::tr1::shared_ptr;
#endif #endif

View File

@@ -48,7 +48,11 @@
#include <map> #include <map>
#include <fstream> #include <fstream>
#include <stdexcept> #include <stdexcept>
//#include <tr1/memory>
#if !defined(_WIN32) || defined(__MINGW32__)
#include <tr1/memory>
#endif
#include <GL/glew.h> #include <GL/glew.h>
#include "Mathlib.h" #include "Mathlib.h"
@@ -60,7 +64,7 @@ using std::string;
using std::vector; using std::vector;
using std::map; using std::map;
#ifdef _WIN32 #if defined(_WIN32)
using std::tr1::shared_ptr; using std::tr1::shared_ptr;
#endif #endif

View File

@@ -132,6 +132,7 @@ protected:
bool teamcolorNoEnergy; bool teamcolorNoEnergy;
bool teamcolorEnergy; bool teamcolorEnergy;
int alternations; int alternations;
int particleSystemStartDelay;
ParticleObserver *particleObserver; ParticleObserver *particleObserver;
public: public:
@@ -173,6 +174,7 @@ public:
void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;} void setTeamcolorNoEnergy(bool teamcolorNoEnergy) {this->teamcolorNoEnergy= teamcolorNoEnergy;}
void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;} void setTeamcolorEnergy(bool teamcolorEnergy) {this->teamcolorEnergy= teamcolorEnergy;}
void setAlternations(int alternations) {this->alternations= alternations;} void setAlternations(int alternations) {this->alternations= alternations;}
void setParticleSystemStartDelay(int delay) {this->particleSystemStartDelay= delay;}
virtual void setFactionColor(Vec3f factionColor); virtual void setFactionColor(Vec3f factionColor);
static BlendMode strToBlendMode(const string &str); static BlendMode strToBlendMode(const string &str);
@@ -269,6 +271,7 @@ protected:
class UnitParticleSystem: public GameParticleSystem{ class UnitParticleSystem: public GameParticleSystem{
public: public:
static bool isNight; static bool isNight;
static Vec3f lightColor;
private: private:
float radius; float radius;
float minRadius; float minRadius;
@@ -296,6 +299,7 @@ public:
float rotation; float rotation;
bool isVisibleAtNight; bool isVisibleAtNight;
bool isVisibleAtDay; bool isVisibleAtDay;
bool isDaylightAffected;
bool radiusBasedStartenergy; bool radiusBasedStartenergy;
int staticParticleCount; int staticParticleCount;
int delay; int delay;
@@ -339,6 +343,7 @@ public:
void setPrimitive(Primitive primitive) {this->primitive= primitive;} void setPrimitive(Primitive primitive) {this->primitive= primitive;}
void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;} void setStaticParticleCount(int staticParticleCount){this->staticParticleCount= staticParticleCount;}
void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;} void setIsVisibleAtNight(bool value) {this->isVisibleAtNight= value;}
void setIsDaylightAffected(bool value) {this->isDaylightAffected= value;}
void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;} void setIsVisibleAtDay(bool value) {this->isVisibleAtDay= value;}
void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;} void setRadiusBasedStartenergy(bool value) {this->radiusBasedStartenergy= value;}
void setShape(Shape shape) {this->shape= shape;} void setShape(Shape shape) {this->shape= shape;}

View File

@@ -253,7 +253,7 @@ public:
virtual ~ServerSocket(); virtual ~ServerSocket();
void bind(int port); void bind(int port);
void listen(int connectionQueueSize= SOMAXCONN); void listen(int connectionQueueSize= SOMAXCONN);
Socket *accept(); Socket *accept(bool errorOnFail=true);
void stopBroadCastThread(); void stopBroadCastThread();
void pauseBroadcast(); void pauseBroadcast();

View File

@@ -388,7 +388,8 @@ int mainSetup(int argc, char **argv) {
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_VERSION])) == true || hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_VERSION])) == true ||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS])) == true || hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS])) == true ||
hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) { hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_MASTERSERVER_MODE])) == true) {
if(SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK) < 0) { // Use this for masterserver mode for timers like Chrono
if(SDL_Init(SDL_INIT_TIMER) < 0) {
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n";
return 1; return 1;
} }
@@ -398,9 +399,9 @@ int mainSetup(int argc, char **argv) {
std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n"; std::cerr << "Couldn't initialize SDL: " << SDL_GetError() << "\n";
return 1; return 1;
} }
}
SDL_EnableUNICODE(1); SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
}
return 0; return 0;
} }

View File

@@ -33,10 +33,9 @@ typedef unsigned int uint32;
typedef long long int64; typedef long long int64;
typedef unsigned long long uint64; typedef unsigned long long uint64;
//typedef uint8 byte;
}}//end namespace }}//end namespace
#ifndef __MINGW32__
// ISO C9x compliant stdint.h for Microsoft Visual Studio // ISO C9x compliant stdint.h for Microsoft Visual Studio
// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 // Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124
@@ -287,3 +286,5 @@ typedef uint64_t uintmax_t;
#endif // _MSC_STDINT_H_ ] #endif // _MSC_STDINT_H_ ]
#endif #endif
#endif

View File

@@ -25,6 +25,10 @@
# include <string> # include <string>
#include "types.h" #include "types.h"
#ifdef __MINGW32__
typedef unsigned char byte;
#endif
//! \name Macros for Shared::Util::String //! \name Macros for Shared::Util::String
//@{ //@{

View File

@@ -84,8 +84,11 @@ void Font::resetToDefaults() {
#if defined(WIN32) #if defined(WIN32)
string newEnvValue = "MEGAGLEST_FONT="; string newEnvValue = "MEGAGLEST_FONT=";
_putenv(newEnvValue.c_str()); _putenv(newEnvValue.c_str());
newEnvValue = "MEGAGLEST_FONT_FAMILY=";
_putenv(newEnvValue.c_str());
#else #else
unsetenv("MEGAGLEST_FONT"); unsetenv("MEGAGLEST_FONT");
unsetenv("MEGAGLEST_FONT_FAMILY");
#endif #endif
} }
@@ -212,11 +215,11 @@ string Font::getType() const {
return this->type; return this->type;
} }
void Font::setType(string typeX11, string typeGeneric) { void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily) {
if(textHandler) { if(textHandler) {
try { try {
this->type= typeGeneric; this->type= typeGeneric;
textHandler->init(typeGeneric,textHandler->GetFaceSize()); textHandler->init(typeGeneric,typeGenericFamily,textHandler->GetFaceSize());
metrics.setTextHandler(this->textHandler); metrics.setTextHandler(this->textHandler);
} }
catch(exception &ex) { catch(exception &ex) {
@@ -269,54 +272,11 @@ Font3D::Font3D(FontTextHandlerType type) : Font(type) {
depth= 10.f; depth= 10.f;
} }
const char* findFont(const char *firstFontToTry) { string findFontFamily(const char* font, const char *fontFamily) {
const char* font = NULL; string resultFile = "";
const char* path = NULL;
#define CHECK_FONT_PATH(filename) \
{ \
path = filename; \
if( !font && path && fileExists(path) == true ) \
font = strdup(path); \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found font file [%s]\n",font); \
}
string tryFont = "";
if(firstFontToTry) {
tryFont = firstFontToTry;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
}
// Get user-specified font path
if(getenv("MEGAGLEST_FONT") != NULL) {
tryFont = getenv("MEGAGLEST_FONT");
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
}
string data_path = Text::DEFAULT_FONT_PATH;
string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf
tryFont = defaultFont;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str())
#ifdef FONT_PATH
// Get distro-specified font path
CHECK_FONT_PATH(FONT_PATH)
#endif
#ifdef HAVE_FONTCONFIG #ifdef HAVE_FONTCONFIG
// Get default font via fontconfig // Get default font via fontconfig
if( !font && FcInit() ) { if( !font && FcInit() && fontFamily) {
FcResult result; FcResult result;
FcFontSet *fs; FcFontSet *fs;
FcPattern* pat; FcPattern* pat;
@@ -327,30 +287,107 @@ const char* findFont(const char *firstFontToTry) {
name of a font that contains all the Unicode characters in use in name of a font that contains all the Unicode characters in use in
your translation. your translation.
*/ */
pat = FcNameParse((FcChar8 *)"Gothic Uralic"); //pat = FcNameParse((FcChar8 *)"Gothic Uralic");
pat = FcNameParse((FcChar8 *)fontFamily);
FcConfigSubstitute(0, pat, FcMatchPattern); FcConfigSubstitute(0, pat, FcMatchPattern);
FcPatternDel(pat, FC_WEIGHT); //FcPatternDel(pat, FC_WEIGHT);
FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD); //FcPatternAddInteger(pat, FC_WEIGHT, FC_WEIGHT_BOLD);
FcDefaultSubstitute(pat); FcDefaultSubstitute(pat);
fs = FcFontSetCreate(); fs = FcFontSetCreate();
match = FcFontMatch(0, pat, &result); match = FcFontMatch(0, pat, &result);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Trying fontconfig for fontfamily [%s]\n",fontFamily);
if (match) FcFontSetAdd(fs, match); if (match) FcFontSetAdd(fs, match);
if (pat) FcPatternDestroy(pat); if (pat) FcPatternDestroy(pat);
if(fs) { if(fs) {
FcChar8* file; FcChar8* file;
if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) { if( FcPatternGetString (fs->fonts[0], FC_FILE, 0, &file) == FcResultMatch ) {
CHECK_FONT_PATH((const char*)file) //CHECK_FONT_PATH((const char*)file,NULL)
resultFile = (const char*)file;
} }
FcFontSetDestroy(fs); FcFontSetDestroy(fs);
} }
FcFini(); FcFini();
} }
#else
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("******************* NO FONT CONFIG ENABLED!\n");
#endif #endif
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") return resultFile;
}
const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry) {
const char* font = NULL;
const char* path = NULL;
#define CHECK_FONT_PATH(filename,fontFamily) \
{ \
path = filename; \
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
font = strdup(path); \
} \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",path,font); \
if( !font && fontFamily && strlen(fontFamily) > 0) { \
string fileFound = findFontFamily(font, fontFamily); \
if(fileFound != "") { \
path = fileFound.c_str(); \
if( !font && path && strlen(path) > 0 && fileExists(path) == true ) { \
font = strdup(path); \
} \
} \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font family [%s] result [%s]\n",fontFamily,font); \
} \
}
string tryFont = "";
if(firstFontToTry || firstFontFamilyToTry) {
if(firstFontToTry && strlen(firstFontToTry) > 0) {
tryFont = firstFontToTry;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),firstFontFamilyToTry)
}
else {
CHECK_FONT_PATH(NULL,firstFontFamilyToTry)
}
}
// Get user-specified font path
if(getenv("MEGAGLEST_FONT") != NULL || getenv("MEGAGLEST_FONT_FAMILY") != NULL) {
if(getenv("MEGAGLEST_FONT") != NULL) {
tryFont = getenv("MEGAGLEST_FONT");
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),getenv("MEGAGLEST_FONT_FAMILY"))
}
else {
CHECK_FONT_PATH(NULL,getenv("MEGAGLEST_FONT_FAMILY"))
}
}
string data_path = Text::DEFAULT_FONT_PATH;
string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf
tryFont = defaultFont;
#ifdef WIN32
replaceAll(tryFont, "/", "\\");
#endif
CHECK_FONT_PATH(tryFont.c_str(),"Linux Biolinum O:style=Bold")
#ifdef FONT_PATH
// Get distro-specified font path
CHECK_FONT_PATH(FONT_PATH)
#endif
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
// Check a couple of common paths for Gothic Uralic/bold as a last resort // Check a couple of common paths for Gothic Uralic/bold as a last resort
// Debian // Debian
@@ -359,44 +396,44 @@ const char* findFont(const char *firstFontToTry) {
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Debian it should be the Debian path. If the font is available in Debian it should be the Debian path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a TRANSLATORS: If using the FTGL backend, this should be the path of a
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Debian it should be the Debian path. If the font is available in Debian it should be the Debian path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular")
// Mandrake // Mandrake
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a bold TRANSLATORS: If using the FTGL backend, this should be the path of a bold
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Mandrake it should be the Mandrake path. If the font is available in Mandrake it should be the Mandrake path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Bold")
/* /*
TRANSLATORS: If using the FTGL backend, this should be the path of a TRANSLATORS: If using the FTGL backend, this should be the path of a
font that contains all the Unicode characters in use in your translation. font that contains all the Unicode characters in use in your translation.
If the font is available in Mandrake it should be the Mandrake path. If the font is available in Mandrake it should be the Mandrake path.
*/ */
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular")
// Check the non-translated versions of the above // Check the non-translated versions of the above
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothu___.ttf","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHUB__.TTF","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF") CHECK_FONT_PATH("/usr/share/fonts/TTF/uralic/GOTHU___.TTF","Gothic Uralic:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/linux-libertine/LinLibertine_Re.ttf","Linux Libertine O:style=Regular")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSerif.ttf","FreeSerif")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf","FreeSans")
CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf","FreeMono")
#ifdef _WIN32 #ifdef _WIN32
CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf",NULL)
CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf",NULL)
CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf") CHECK_FONT_PATH("c:\\windows\\fonts\\arial.ttf",NULL)
CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf") CHECK_FONT_PATH("\\windows\\fonts\\arial.ttf",NULL)
#endif #endif
return font; return font;

View File

@@ -19,7 +19,7 @@ Text::Text(FontTextHandlerType type) {
this->type = type; this->type = type;
} }
Text::~Text() {} Text::~Text() {}
void Text::init(string fontName, int fontSize) {} void Text::init(string fontName, string fontFamilyName, int fontSize) {}
void Text::Render(const char*, const int) {} void Text::Render(const char*, const int) {}
float Text::Advance(const char*, const int) {return 0;} float Text::Advance(const char*, const int) {return 0;}
float Text::LineHeight(const char*, const int) {return 0;} float Text::LineHeight(const char*, const int) {return 0;}

View File

@@ -84,17 +84,16 @@ void Font3DGl::end() {
}}}//end namespace }}}//end namespace
namespace Shared { namespace Graphics { //namespace Shared { namespace Graphics {
//
using namespace Gl; // using namespace Gl;
Font3D * ConvertFont2DTo3D(Font2D *font) { //Font3D * ConvertFont2DTo3D(Font2D *font) {
//
Font3D *result = new Font3DGl(); // Font3D *result = new Font3DGl();
result->setSize(font->getSize()); // result->setSize(font->getSize());
result->setType("",font->getType()); // result->setType("",font->getType());
result->setWidth(font->getWidth()); // result->setWidth(font->getWidth());
result->init(); // result->init();
return result; // return result;
} //}
//}}
}}

View File

@@ -78,7 +78,7 @@ TextFTGL::TextFTGL(FontTextHandlerType type) : Text(type) {
delete ftFont; ftFont = NULL; delete ftFont; ftFont = NULL;
free((void*)fontFile); free((void*)fontFile);
fontFile = NULL; fontFile = NULL;
throw runtime_error("FTGL: error loading font"); throw runtime_error(string("FTGL: error loading font: ") + string(fontFile));
} }
free((void*)fontFile); free((void*)fontFile);
fontFile = NULL; fontFile = NULL;
@@ -123,9 +123,9 @@ void TextFTGL::cleanupFont() {
fontFile = NULL; fontFile = NULL;
} }
void TextFTGL::init(string fontName, int fontSize) { void TextFTGL::init(string fontName, string fontFamilyName, int fontSize) {
cleanupFont(); cleanupFont();
fontFile = findFont(fontName.c_str()); fontFile = findFont(fontName.c_str(),fontFamilyName.c_str());
//ftFont = new FTBufferFont(fontFile); //ftFont = new FTBufferFont(fontFile);
//ftFont = new FTGLPixmapFont(fontFile); //ftFont = new FTGLPixmapFont(fontFile);

View File

@@ -38,7 +38,7 @@ TextFreetypeGL::TextFreetypeGL(FontTextHandlerType type) : Text(type) {
font=NULL; font=NULL;
manager=NULL; manager=NULL;
init("", 24); init("", "", 24);
} }
TextFreetypeGL::~TextFreetypeGL() { TextFreetypeGL::~TextFreetypeGL() {
@@ -52,10 +52,11 @@ void TextFreetypeGL::cleanupFont() {
} }
} }
void TextFreetypeGL::init(string fontName, int fontSize) { void TextFreetypeGL::init(string fontName, string fontFamilyName, int fontSize) {
cleanupFont(); cleanupFont();
this->fontName = fontName; this->fontName = fontName;
this->fontFile = findFont(this->fontName.c_str()); this->fontFamilyName = fontFamilyName;
this->fontFile = findFont(this->fontName.c_str(),this->fontFamilyName.c_str());
this->fontFaceSize = fontSize; this->fontFaceSize = fontSize;
const wchar_t *cache = L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"; const wchar_t *cache = L" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
@@ -77,7 +78,7 @@ void TextFreetypeGL::init(string fontName, int fontSize) {
void TextFreetypeGL::SetFaceSize(int value) { void TextFreetypeGL::SetFaceSize(int value) {
this->fontFaceSize = value; this->fontFaceSize = value;
init(this->fontName,this->fontFaceSize); init(this->fontName,this->fontFamilyName,this->fontFaceSize);
} }
int TextFreetypeGL::GetFaceSize() { int TextFreetypeGL::GetFaceSize() {

View File

@@ -141,28 +141,28 @@ void Mesh::BuildVBOs() {
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOVertices ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getVertices(), GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getVertices(), GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Texture Coordinate Buffer // Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB( 1, (GLuint*)&m_nVBOTexCoords ); // Get A Valid Name glGenBuffersARB( 1, (GLuint*)&m_nVBOTexCoords ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBOTexCoords ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f)*vertexCount, texCoords, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec2f)*vertexCount, texCoords, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Normal Buffer // Generate And Bind The Normal Buffer
glGenBuffersARB( 1, (GLuint*)&m_nVBONormals ); // Get A Valid Name glGenBuffersARB( 1, (GLuint*)&m_nVBONormals ); // Get A Valid Name
glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBONormals ); // Bind The Buffer glBindBufferARB( GL_ARRAY_BUFFER_ARB, m_nVBONormals ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getNormals(), GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ARRAY_BUFFER_ARB, sizeof(Vec3f)*frameCount*vertexCount, getInterpolationData()->getNormals(), GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Index Buffer // Generate And Bind The Index Buffer
glGenBuffersARB( 1, (GLuint*)&m_nVBOIndexes ); // Get A Valid Name glGenBuffersARB( 1, (GLuint*)&m_nVBOIndexes ); // Get A Valid Name
glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nVBOIndexes ); // Bind The Buffer glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, m_nVBOIndexes ); // Bind The Buffer
// Load The Data // Load The Data
glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(uint32)*indexCount, indices, GL_STATIC_DRAW_ARB ); glBufferDataARB( GL_ELEMENT_ARRAY_BUFFER_ARB, sizeof(uint32)*indexCount, indices, GL_STATIC_DRAW_ARB );
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
// Our Copy Of The Data Is No Longer Necessary, It Is Safe In The Graphics Card // Our Copy Of The Data Is No Longer Necessary, It Is Safe In The Graphics Card
delete [] vertices; vertices = NULL; delete [] vertices; vertices = NULL;

View File

@@ -74,6 +74,7 @@ ParticleSystem::ParticleSystem(int particleCount) {
teamcolorNoEnergy= false; teamcolorNoEnergy= false;
teamcolorEnergy= false; teamcolorEnergy= false;
alternations= 0; alternations= 0;
particleSystemStartDelay= 0;
} }
ParticleSystem::~ParticleSystem(){ ParticleSystem::~ParticleSystem(){
@@ -97,8 +98,10 @@ void ParticleSystem::update(){
if(aliveParticleCount > (int) particles.size()){ if(aliveParticleCount > (int) particles.size()){
throw runtime_error("aliveParticleCount >= particles.size()"); throw runtime_error("aliveParticleCount >= particles.size()");
} }
if(particleSystemStartDelay>0){
if(state != sPause){ particleSystemStartDelay--;
}
else if(state != sPause){
for(int i= 0; i < aliveParticleCount; ++i){ for(int i= 0; i < aliveParticleCount; ++i){
updateParticle(&particles[i]); updateParticle(&particles[i]);
@@ -527,6 +530,7 @@ void GameParticleSystem::setTween(float relative,float absolute) {
// UnitParticleSystem // UnitParticleSystem
// =========================================================================== // ===========================================================================
bool UnitParticleSystem::isNight= false; bool UnitParticleSystem::isNight= false;
Vec3f UnitParticleSystem::lightColor=Vec3f(1.0f,1.0f,1.0f);
UnitParticleSystem::UnitParticleSystem(int particleCount): UnitParticleSystem::UnitParticleSystem(int particleCount):
GameParticleSystem(particleCount), GameParticleSystem(particleCount),
@@ -537,11 +541,14 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
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));
sizeNoEnergy=1.0f;
primitive= pQuad; primitive= pQuad;
gravity= 0.0f; gravity= 0.0f;
fixed= false; fixed= false;
shape = UnitParticleSystem::sLinear;
angle= 0.0f;
rotation= 0.0f; rotation= 0.0f;
relativeDirection= true; relativeDirection= true;
relative= false; relative= false;
@@ -549,6 +556,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
isVisibleAtNight= true; isVisibleAtNight= true;
isVisibleAtDay= true; isVisibleAtDay= true;
isDaylightAffected= false;
cRotation= Vec3f(1.0f, 1.0f, 1.0f); cRotation= Vec3f(1.0f, 1.0f, 1.0f);
fixedAddition= Vec3f(0.0f, 0.0f, 0.0f); fixedAddition= Vec3f(0.0f, 0.0f, 0.0f);
@@ -560,6 +568,7 @@ UnitParticleSystem::UnitParticleSystem(int particleCount):
delay = 0; // none delay = 0; // none
lifetime = -1; // forever lifetime = -1; // forever
emissionRateFade=0.0f;
startTime = 0; startTime = 0;
endTime = 1; endTime = 1;
@@ -736,6 +745,12 @@ void UnitParticleSystem::updateParticle(Particle *p){
} }
p->speed+= p->accel; p->speed+= p->accel;
p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio); p->color= color * energyRatio + colorNoEnergy * (1.0f - energyRatio);
if(isDaylightAffected==true)
{
p->color.x=p->color.x*lightColor.x;
p->color.y=p->color.y*lightColor.y;
p->color.z=p->color.z*lightColor.z;
}
p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio); p->size= particleSize * energyRatio + sizeNoEnergy * (1.0f - energyRatio);
if(state == ParticleSystem::sFade || staticParticleCount < 1){ if(state == ParticleSystem::sFade || staticParticleCount < 1){
p->energy--; p->energy--;

View File

@@ -916,20 +916,30 @@ Pixmap2D::~Pixmap2D() {
void Pixmap2D::Scale(int format, int newW, int newH) { void Pixmap2D::Scale(int format, int newW, int newH) {
int useComponents = this->getComponents(); int useComponents = this->getComponents();
int originalW = w;
int originalH = h;
uint8 *newpixels= new uint8[newW * newH * useComponents]; uint8 *newpixels= new uint8[newW * newH * useComponents];
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
int error = gluScaleImage( format, int error = gluScaleImage( format,
w, h, GL_UNSIGNED_BYTE, pixels, w, h, GL_UNSIGNED_BYTE, pixels,
newW, newH, GL_UNSIGNED_BYTE, newpixels); newW, newH, GL_UNSIGNED_BYTE, newpixels);
if(error != GL_NO_ERROR) { glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
if(error == GL_NO_ERROR) {
init(newW,newH,this->components); init(newW,newH,this->components);
pixels = newpixels; pixels = newpixels;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Scaled image from [%d x %d] to [%d x %d]\n",originalW,originalH,w,h);
} }
else { else {
assertGl(); const char *errorString= reinterpret_cast<const char*>(gluErrorString(error));
printf("ERROR Scaling image from [%d x %d] to [%d x %d] error: %d [%s]\n",originalW,originalH,w,h,error,errorString);
GLenum glErr = error;
assertGlWithErrorNumber(glErr);
} }
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
CalculatePixelsCRC(pixels,getPixelByteCount(), crc); CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
} }

View File

@@ -26,6 +26,16 @@ 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 */
static int powerOfTwo(int input) {
int value = 1;
while (value < input) {
value <<= 1;
}
return value;
}
Texture::Texture() { Texture::Texture() {
assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false); assert(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false);
@@ -86,6 +96,102 @@ SDL_Surface* Texture2D::CreateSDLSurface(bool newPixelData) const {
delete[] surfData; delete[] surfData;
} }
// SDL_Surface *prepGLTexture(SDL_Surface *surface, GLfloat *texCoords = NULL, const bool
// freeSource = false) {
/* Use the surface width and height expanded to powers of 2 */
//int w = powerOfTwo(surface->w);
//int h = powerOfTwo(surface->h);
int w = surface->w;
int h = surface->h;
// if (texCoords != 0) {
// texCoords[0] = 0.0f; /* Min
// X */
// texCoords[1] = 0.0f; /* Min
// Y */
// texCoords[2] = (GLfloat)surface->w / w; /* Max X */
// texCoords[3] = (GLfloat)surface->h / h; /* Max Y */
// }
SDL_Surface *image = SDL_CreateRGBSurface(
SDL_SWSURFACE,
w, h,
32,
#if SDL_BYTEORDER == SDL_LIL_ENDIAN /* OpenGL RGBA masks */
0x000000FF,
0x0000FF00,
0x00FF0000,
0xFF000000
#else
0xFF000000,
0x00FF0000,
0x0000FF00,
0x000000FF
#endif
);
if ( image == NULL ) {
return 0;
}
/* Save the alpha blending attributes */
Uint32 savedFlags = surface->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
Uint8 savedAlpha = surface->format->alpha;
if ( (savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
SDL_SetAlpha(surface, 0, 0);
}
SDL_Rect srcArea, destArea;
/* Copy the surface into the GL texture image */
srcArea.x = 0; destArea.x = 0;
/* Copy it in at the bottom, because we're going to flip
this image upside-down in a moment
*/
srcArea.y = 0; destArea.y = h - surface->h;
srcArea.w = surface->w;
srcArea.h = surface->h;
SDL_BlitSurface(surface, &srcArea, image, &destArea);
/* Restore the alpha blending attributes */
if ((savedFlags & SDL_SRCALPHA) == SDL_SRCALPHA) {
SDL_SetAlpha(surface, savedFlags, savedAlpha);
}
/* Turn the image upside-down, because OpenGL textures
start at the bottom-left, instead of the top-left
*/
#ifdef _MSC_VER
Uint8 *line = new Uint8[image->pitch];
#else
Uint8 line[image->pitch];
#endif
/* These two make the following more readable */
Uint8 *pixels = static_cast<Uint8*>(image->pixels);
Uint16 pitch = image->pitch;
int ybegin = 0;
int yend = image->h - 1;
// TODO: consider if this lock is legal/appropriate
if (SDL_MUSTLOCK(image)) { SDL_LockSurface(image); }
while (ybegin < yend) {
memcpy(line, pixels + pitch*ybegin, pitch);
memcpy(pixels + pitch*ybegin, pixels + pitch*yend, pitch);
memcpy(pixels + pitch*yend, line, pitch);
ybegin++;
yend--;
}
if (SDL_MUSTLOCK(image)) { SDL_UnlockSurface(image); }
// if (freeSource) {
// SDL_FreeSurface(surface);
// }
#ifdef _MSC_VER
delete[] line;
#endif
return image;
// }
return surface; return surface;
} }

View File

@@ -192,7 +192,7 @@ void * LuaArguments::getGenericData(int argumentIndex) const{
if(lua_isstring(luaState, argumentIndex)) { if(lua_isstring(luaState, argumentIndex)) {
const char *result = luaL_checkstring(luaState, argumentIndex); const char *result = luaL_checkstring(luaState, argumentIndex);
printf("\nGENERIC param %d is a string, %s!\n",argumentIndex,result); //printf("\nGENERIC param %d is a string, %s!\n",argumentIndex,result);
return (void *)result; return (void *)result;
} }
//else if(lua_isnumber(luaState, argumentIndex)) { //else if(lua_isnumber(luaState, argumentIndex)) {
@@ -202,11 +202,11 @@ void * LuaArguments::getGenericData(int argumentIndex) const{
//} //}
else if(lua_isnumber(luaState, argumentIndex)) { else if(lua_isnumber(luaState, argumentIndex)) {
lua_Integer result = luaL_checkinteger(luaState, argumentIndex); lua_Integer result = luaL_checkinteger(luaState, argumentIndex);
printf("\nGENERIC param %d is an int, %d!\n",argumentIndex,(int)result); //printf("\nGENERIC param %d is an int, %d!\n",argumentIndex,(int)result);
return (void *)result; return (void *)result;
} }
else { else {
printf("\nGENERIC param %d is a NULL!\n",argumentIndex); //printf("\nGENERIC param %d is a NULL!\n",argumentIndex);
return NULL; return NULL;
} }
} }

View File

@@ -1587,6 +1587,11 @@ bool changeVideoMode(int resW, int resH, int colorBits, int ) {
void restoreVideoMode(bool exitingApp) { void restoreVideoMode(bool exitingApp) {
//SDL_Quit(); //SDL_Quit();
if(exitingApp == true && SDL_WasInit(SDL_INIT_VIDEO)) {
SDL_ShowCursor(1);
SDL_WM_GrabInput(SDL_GRAB_OFF);
//SDL_SetGamma(1, 1, 1);
}
} }
int getScreenW() { int getScreenW() {

View File

@@ -313,7 +313,7 @@ string Ip::getString() const{
// class Socket // class Socket
// =============================================== // ===============================================
#if defined(__FreeBSD__) || defined(BSD) || defined(__APPLE__) || defined(__linux__) #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(BSD) || defined(__APPLE__) || defined(__linux__)
# define USE_GETIFADDRS 1 # define USE_GETIFADDRS 1
# include <ifaddrs.h> # include <ifaddrs.h>
#endif #endif
@@ -768,7 +768,7 @@ bool Socket::isSocketValid() const {
bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) { bool Socket::isSocketValid(const PLATFORM_SOCKET *validateSocket) {
#ifdef WIN32 #ifdef WIN32
if(validateSocket == NULL) { if(validateSocket == NULL || (*validateSocket) == 0) {
return false; return false;
} }
else { else {
@@ -959,6 +959,8 @@ void Socket::disconnectSocket() {
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
MutexSafeWrapper safeMutex1(dataSynchAccessorWrite,CODE_AT_LINE); MutexSafeWrapper safeMutex1(dataSynchAccessorWrite,CODE_AT_LINE);
if(isSocketValid() == true) {
::shutdown(sock,2); ::shutdown(sock,2);
#ifndef WIN32 #ifndef WIN32
::close(sock); ::close(sock);
@@ -967,6 +969,7 @@ void Socket::disconnectSocket() {
::closesocket(sock); ::closesocket(sock);
sock = -1; sock = -1;
#endif #endif
}
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
safeMutex1.ReleaseLock(); safeMutex1.ReleaseLock();
} }
@@ -985,6 +988,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
fd_set rfds; fd_set rfds;
FD_ZERO(&rfds); FD_ZERO(&rfds);
string socketDebugList = "";
PLATFORM_SOCKET imaxsocket = 0; PLATFORM_SOCKET imaxsocket = 0;
for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin(); for(std::map<PLATFORM_SOCKET,bool>::iterator itermap = socketTriggeredList.begin();
itermap != socketTriggeredList.end(); ++itermap) itermap != socketTriggeredList.end(); ++itermap)
@@ -994,6 +998,11 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
{ {
FD_SET(socket, &rfds); FD_SET(socket, &rfds);
imaxsocket = max(socket,imaxsocket); imaxsocket = max(socket,imaxsocket);
if(socketDebugList != "") {
socketDebugList += ",";
}
socketDebugList += intToStr(socket);
} }
} }
@@ -1012,7 +1021,7 @@ bool Socket::hasDataToRead(std::map<PLATFORM_SOCKET,bool> &socketTriggeredList)
} }
if(retval < 0) if(retval < 0)
{ {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] ERROR SELECTING SOCKET DATA retval = %d error = %s\n",__FILE__,__FUNCTION__,retval,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s] Line: %d, ERROR SELECTING SOCKET DATA retval = %d error = %s, socketDebugList [%s]\n",__FILE__,__FUNCTION__,__LINE__,retval,getLastSocketErrorFormattedText().c_str(),socketDebugList.c_str());
} }
else if(retval) else if(retval)
{ {
@@ -1147,7 +1156,8 @@ int Socket::getDataToRead(bool wantImmediateReply) {
#else #else
int err= ioctlsocket(sock, FIONREAD, &size); int err= ioctlsocket(sock, FIONREAD, &size);
#endif #endif
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) int lastSocketError = getLastSocketError();
if(err < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN)
{ {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR PEEKING SOCKET DATA, err = %d %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR PEEKING SOCKET DATA, err = %d %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str());
break; break;
@@ -1201,11 +1211,13 @@ int Socket::send(const void *data, int dataSize) {
MutexSafeWrapper safeMutex(dataSynchAccessorWrite,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorWrite,CODE_AT_LINE);
if(isSocketValid() == true) {
#ifdef __APPLE__ #ifdef __APPLE__
bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE); bytesSent = ::send(sock, (const char *)data, dataSize, SO_NOSIGPIPE);
#else #else
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT); bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
#endif #endif
}
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
} }
@@ -1213,15 +1225,16 @@ int Socket::send(const void *data, int dataSize) {
//bytesSent = -1; //bytesSent = -1;
// END TEST // END TEST
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { int lastSocketError = getLastSocketError();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText().c_str()); if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] ERROR WRITING SOCKET DATA, err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesSent,getLastSocketErrorFormattedText(&lastSocketError).c_str());
} }
else if(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN && isConnected() == true) { else if(bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN && isConnected() == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during send, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
int attemptCount = 0; int attemptCount = 0;
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { (difftime(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);
@@ -1243,7 +1256,8 @@ int Socket::send(const void *data, int dataSize) {
#else #else
bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT); bytesSent = ::send(sock, (const char *)data, dataSize, MSG_NOSIGNAL | MSG_DONTWAIT);
#endif #endif
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { lastSocketError = getLastSocketError();
if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
break; break;
} }
@@ -1264,13 +1278,16 @@ int Socket::send(const void *data, int dataSize) {
} }
if(isConnected() == true && bytesSent > 0 && bytesSent < dataSize) { if(isConnected() == true && bytesSent > 0 && bytesSent < dataSize) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketError(),bytesSent,dataSize); lastSocketError = getLastSocketError();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] need to send more data, trying again getLastSocketError() = %d, bytesSent = %d, dataSize = %d\n",__FILE__,__FUNCTION__,__LINE__,lastSocketError,bytesSent,dataSize);
int totalBytesSent = bytesSent; int totalBytesSent = bytesSent;
int attemptCount = 0; int attemptCount = 0;
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while(((bytesSent > 0 && totalBytesSent < dataSize) || while(((bytesSent > 0 && totalBytesSent < dataSize) ||
(bytesSent < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN)) && (bytesSent < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN)) &&
(difftime(time(NULL),tStartTimer) <= MAX_SEND_WAIT_SECONDS)) { (difftime(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);
@@ -1293,11 +1310,12 @@ int Socket::send(const void *data, int dataSize) {
#else #else
bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, MSG_NOSIGNAL | MSG_DONTWAIT); bytesSent = ::send(sock, &sendBuf[totalBytesSent], dataSize - totalBytesSent, MSG_NOSIGNAL | MSG_DONTWAIT);
#endif #endif
lastSocketError = getLastSocketError();
if(bytesSent > 0) { if(bytesSent > 0) {
totalBytesSent += bytesSent; totalBytesSent += bytesSent;
} }
if(bytesSent < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { if(bytesSent < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
break; break;
} }
@@ -1352,17 +1370,20 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
// safeMutexSocketDestructorFlag.ReleaseLock(); // safeMutexSocketDestructorFlag.ReleaseLock();
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
if(isSocketValid() == true) {
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0); bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
}
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
} }
if(bytesReceived < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { int lastSocketError = getLastSocketError();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText().c_str()); if(bytesReceived < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR READING SOCKET DATA error while sending socket data, bytesSent = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived,getLastSocketErrorFormattedText(&lastSocketError).c_str());
} }
else if(bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) { else if(bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 EAGAIN during receive, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((bytesReceived < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((bytesReceived < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) { (difftime(time(NULL),tStartTimer) <= MAX_RECV_WAIT_SECONDS)) {
if(isConnected() == false) { if(isConnected() == false) {
int iErr = getLastSocketError(); int iErr = getLastSocketError();
@@ -1382,6 +1403,7 @@ int Socket::receive(void *data, int dataSize, bool tryReceiveUntilDataSizeMet) {
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0); bytesReceived = recv(sock, reinterpret_cast<char*>(data), dataSize, 0);
lastSocketError = getLastSocketError();
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 EAGAIN during receive, trying again returned: %d\n",__FILE__,__FUNCTION__,__LINE__,bytesReceived);
@@ -1442,8 +1464,9 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
if(isSocketValid() == true) {
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK); err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
}
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
//printf("Peek #1 err = %d\n",err); //printf("Peek #1 err = %d\n",err);
@@ -1452,17 +1475,18 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
} }
//if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); //if(chrono.getMillis() > 1) printf("In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
if(err < 0 && getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { int lastSocketError = getLastSocketError();
if(err < 0 && lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] ERROR PEEKING SOCKET DATA error while sending socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText().c_str());
disconnectSocket(); disconnectSocket();
} }
else if(err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN && mustGetData == true) { else if(err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN && mustGetData == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 ERROR EAGAIN during peek, trying again...\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #1 ERROR EAGAIN during peek, trying again...\n",__FILE__,__FUNCTION__,__LINE__);
//printf("Peek #2 err = %d\n",err); //printf("Peek #2 err = %d\n",err);
time_t tStartTimer = time(NULL); time_t tStartTimer = time(NULL);
while((err < 0 && getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) && while((err < 0 && lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) &&
(difftime(time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) { (difftime(time(NULL),tStartTimer) <= MAX_PEEK_WAIT_SECONDS)) {
/* /*
if(isConnected() == false) { if(isConnected() == false) {
@@ -1484,6 +1508,7 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
//MutexSafeWrapper safeMutex(&dataSynchAccessor,CODE_AT_LINE + "_" + intToStr(sock) + "_" + intToStr(dataSize)); //MutexSafeWrapper safeMutex(&dataSynchAccessor,CODE_AT_LINE + "_" + intToStr(sock) + "_" + intToStr(dataSize));
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK); err = recv(sock, reinterpret_cast<char*>(data), dataSize, MSG_PEEK);
lastSocketError = getLastSocketError();
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) if(chrono.getMillis() > 1) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] action running for msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,(long long int)chrono.getMillis());
@@ -1498,8 +1523,9 @@ int Socket::peek(void *data, int dataSize,bool mustGetData) {
if(err <= 0) { if(err <= 0) {
//printf("Peek #3 err = %d\n",err); //printf("Peek #3 err = %d\n",err);
if(mustGetData == true || getLastSocketError() != PLATFORM_SOCKET_TRY_AGAIN) { lastSocketError = getLastSocketError();
int iErr = getLastSocketError(); if(mustGetData == true || lastSocketError != PLATFORM_SOCKET_TRY_AGAIN) {
int iErr = lastSocketError;
disconnectSocket(); disconnectSocket();
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while peeking socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText(&iErr).c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"[%s::%s Line: %d] DISCONNECTED SOCKET error while peeking socket data, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,err,getLastSocketErrorFormattedText(&iErr).c_str());
@@ -1761,8 +1787,9 @@ void ClientSocket::connect(const Ip &ip, int port)
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #2 Error connecting socket for IP: %s for Port: %d err = %d error = %s\n",__FILE__,__FUNCTION__,__LINE__,ip.getString().c_str(),port,err,getLastSocketErrorFormattedText().c_str());
if (getLastSocketError() == PLATFORM_SOCKET_INPROGRESS || int lastSocketError = getLastSocketError();
getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) { if (lastSocketError == PLATFORM_SOCKET_INPROGRESS ||
lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) {
fd_set myset; fd_set myset;
struct timeval tv; struct timeval tv;
int valopt=0; int valopt=0;
@@ -1781,10 +1808,11 @@ void ClientSocket::connect(const Ip &ip, int port)
{ {
MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE); MutexSafeWrapper safeMutex(dataSynchAccessorRead,CODE_AT_LINE);
err = select((int)sock + 1, NULL, &myset, NULL, &tv); err = select((int)sock + 1, NULL, &myset, NULL, &tv);
lastSocketError = getLastSocketError();
//safeMutex.ReleaseLock(); //safeMutex.ReleaseLock();
} }
if (err < 0 && getLastSocketError() != PLATFORM_SOCKET_INTERRUPTED) { if (err < 0 && lastSocketError != PLATFORM_SOCKET_INTERRUPTED) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str());
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Error connecting %s\n",__FILE__,__FUNCTION__,__LINE__,getLastSocketErrorFormattedText().c_str());
@@ -1900,7 +1928,7 @@ void BroadCastClientSocketThread::execute() {
#else #else
setsockopt(bcfd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val)); setsockopt(bcfd, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
#endif #endif
if(bind( bcfd, (struct sockaddr *)&bcaddr, sizeof(bcaddr) ) < 0 ) { if(::bind( bcfd, (struct sockaddr *)&bcaddr, sizeof(bcaddr) ) < 0 ) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"bind failed: %s\n", getLastSocketErrorFormattedText().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"bind failed: %s\n", getLastSocketErrorFormattedText().c_str());
} }
else { else {
@@ -2189,10 +2217,15 @@ void ServerSocket::listen(int connectionQueueSize) {
} }
} }
Socket *ServerSocket::accept() { Socket *ServerSocket::accept(bool errorOnFail) {
if(isSocketValid() == false) { if(isSocketValid() == false) {
if(errorOnFail == true) {
throwException("socket is invalid!"); throwException("socket is invalid!");
} }
else {
return NULL;
}
}
struct sockaddr_in cli_addr; struct sockaddr_in cli_addr;
socklen_t clilen = sizeof(cli_addr); socklen_t clilen = sizeof(cli_addr);
@@ -2206,11 +2239,16 @@ Socket *ServerSocket::accept() {
sprintf(szBuf, "In [%s::%s Line: %d] Error accepting socket connection sock = %d, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,sock,newSock,getLastSocketErrorFormattedText().c_str()); sprintf(szBuf, "In [%s::%s Line: %d] Error accepting socket connection sock = %d, err = %d, error = %s\n",__FILE__,__FUNCTION__,__LINE__,sock,newSock,getLastSocketErrorFormattedText().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
if(getLastSocketError() == PLATFORM_SOCKET_TRY_AGAIN) int lastSocketError = getLastSocketError();
{ if(lastSocketError == PLATFORM_SOCKET_TRY_AGAIN) {
return NULL; return NULL;
} }
if(errorOnFail == true) {
throwException(szBuf); throwException(szBuf);
}
else {
return NULL;
}
} }
else { else {

View File

@@ -137,13 +137,14 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
//uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255); //uint32 colorkey = SDL_MapRGB(icon->format, 255, 0, 255);
//SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey); //SDL_SetColorKey(icon, SDL_SRCCOLORKEY, colorkey);
SDL_SetColorKey(icon, SDL_SRCCOLORKEY, SDL_MapRGB(icon->format, 255, 0, 255));
SDL_WM_SetIcon(icon, NULL); SDL_WM_SetIcon(icon, NULL);
} }
} }
#endif #endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",__FILE__,__FUNCTION__,__LINE__,resW,resH,colorBits); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to set resolution: %d x %d, colorBits = %d.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,resW,resH,colorBits);
if(screen != NULL) { if(screen != NULL) {
SDL_FreeSurface(screen); SDL_FreeSurface(screen);
@@ -159,8 +160,8 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool
<< "bpp " << stencilBits << " stencil " << "bpp " << stencilBits << " stencil "
<< depthBits << " depth-buffer). SDL Error is: " << SDL_GetError(); << depthBits << " depth-buffer). SDL Error is: " << SDL_GetError();
if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg.str().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugError).enabled) SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",__FILE__,__FUNCTION__,__LINE__,msg.str().c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,msg.str().c_str());
for(int i = 32; i >= 8; i-=8) { for(int i = 32; i >= 8; i-=8) {
// try different color bits // try different color bits

View File

@@ -128,7 +128,7 @@ bool Window::handleEvent() {
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "d"; codeLocation = "d";
setLastMouseEvent(Chrono::getCurMillis()); setLastMouseEvent(Chrono::getCurMillis());
@@ -140,21 +140,21 @@ bool Window::handleEvent() {
switch(event.type) { switch(event.type) {
case SDL_QUIT: case SDL_QUIT:
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "e"; codeLocation = "e";
return false; return false;
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "f"; codeLocation = "f";
if(global_window) { if(global_window) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
global_window->handleMouseDown(event); global_window->handleMouseDown(event);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
break; break;
case SDL_MOUSEBUTTONUP: { case SDL_MOUSEBUTTONUP: {
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "g"; codeLocation = "g";
if(global_window) { if(global_window) {
MouseButton b = getMouseButton(event.button.button); MouseButton b = getMouseButton(event.button.button);
@@ -166,7 +166,7 @@ bool Window::handleEvent() {
break; break;
} }
case SDL_MOUSEMOTION: { case SDL_MOUSEMOTION: {
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//MouseState ms; //MouseState ms;
//ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0; //ms.leftMouse = (event.motion.state & SDL_BUTTON_LMASK) != 0;
//ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0; //ms.rightMouse = (event.motion.state & SDL_BUTTON_RMASK) != 0;
@@ -183,11 +183,11 @@ bool Window::handleEvent() {
break; break;
} }
case SDL_KEYDOWN: case SDL_KEYDOWN:
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
{ {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYDOWN ================================\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYDOWN ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "i"; codeLocation = "i";
Window::isKeyPressedDown = true; Window::isKeyPressedDown = true;
@@ -198,20 +198,20 @@ bool Window::handleEvent() {
keystate = event.key.keysym; keystate = event.key.keysym;
string keyName = SDL_GetKeyName(event.key.keysym.sym); string keyName = SDL_GetKeyName(event.key.keysym.sym);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] unicode [%d - %c] scancode [%d] keyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Raw SDL key [%d - %c] mod [%d] unicode [%d - %c] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d] keyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d] keyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode,keyName.c_str());
/* handle ALT+Return */ /* handle ALT+Return */
if((keyName == "return" || keyName == "enter") if((keyName == "return" || keyName == "enter")
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { && (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] SDLK_RETURN pressed.\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] SDLK_RETURN pressed.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
toggleFullscreen(); toggleFullscreen();
} }
#ifdef WIN32 #ifdef WIN32
/* handle ALT+f4 */ /* handle ALT+f4 */
if((keyName == "f4" || keyName == "F4") if((keyName == "f4" || keyName == "F4")
&& (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) { && (event.key.keysym.mod & (KMOD_LALT | KMOD_RALT))) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ALT-F4 pressed.\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] ALT-F4 pressed.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
return false; return false;
} }
#endif #endif
@@ -224,17 +224,17 @@ bool Window::handleEvent() {
global_window->eventKeyDown(event.key); global_window->eventKeyDown(event.key);
global_window->eventKeyPress(event.key); global_window->eventKeyPress(event.key);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYDOWN ================================\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYDOWN ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
break; break;
case SDL_KEYUP: case SDL_KEYUP:
//printf("In [%s::%s] Line :%d\n",__FILE__,__FUNCTION__,__LINE__); //printf("In [%s::%s] Line :%d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYUP ================================\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== START OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
codeLocation = "j"; codeLocation = "j";
@@ -246,7 +246,7 @@ bool Window::handleEvent() {
keystate = event.key.keysym; keystate = event.key.keysym;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",__FILE__,__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] KEY_UP, Raw SDL key [%d] mod [%d] unicode [%d] scancode [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.key.keysym.sym,event.key.keysym.mod,event.key.keysym.unicode,event.key.keysym.scancode);
if(global_window) { if(global_window) {
//char key = getKey(event.key.keysym,true); //char key = getKey(event.key.keysym,true);
@@ -254,15 +254,15 @@ bool Window::handleEvent() {
global_window->eventKeyUp(event.key); global_window->eventKeyUp(event.key);
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] =================================== END OF SDL SDL_KEYUP ================================\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
break; break;
case SDL_ACTIVEEVENT: case SDL_ACTIVEEVENT:
{ {
// codeLocation = "k"; // codeLocation = "k";
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); // if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain);
// //
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); // if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
// //
// // Check if the program has lost window focus // // Check if the program has lost window focus
// if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) { // if ((event.active.state & SDL_APPACTIVE) == SDL_APPACTIVE) {
@@ -273,9 +273,9 @@ bool Window::handleEvent() {
// Window::isActive = true; // Window::isActive = true;
// } // }
// //
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); // if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
// //
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); // if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
// //
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); // bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
// showCursor(willShowCursor); // showCursor(willShowCursor);
@@ -292,18 +292,18 @@ bool Window::handleEvent() {
// Window::isActive = true; // Window::isActive = true;
// } // }
// //
// if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); // if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
// //
// if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); // if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d, event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
// bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); // bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
// showCursor(willShowCursor); // showCursor(willShowCursor);
// } // }
// } // }
codeLocation = "k"; codeLocation = "k";
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",__FILE__,__FUNCTION__,__LINE__,event.active.state,event.active.gain); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] SDL_ACTIVEEVENT event.active.state = %d event.active. = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,event.active.state,event.active.gain);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive,event.active.state); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d event.active.state = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive,event.active.state);
// Check if the program has lost window focus // Check if the program has lost window focus
if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) { if ((event.active.state & (SDL_APPACTIVE | SDL_APPINPUTFOCUS))) {
@@ -314,9 +314,9 @@ bool Window::handleEvent() {
Window::isActive = true; Window::isActive = true;
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] Window::isActive = %d \n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",__FILE__,__FUNCTION__,__LINE__,Window::isActive); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Window::isActive = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,Window::isActive);
bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly()); bool willShowCursor = (!Window::isActive || (Window::lastShowMouseState == SDL_ENABLE) || Window::getUseDefaultCursorOnly());
showCursor(willShowCursor); showCursor(willShowCursor);
@@ -326,22 +326,22 @@ bool Window::handleEvent() {
} }
} }
catch(const char *e){ catch(const char *e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e,codeLocation.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e,codeLocation.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a1) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e,codeLocation.c_str());
throw runtime_error(e); throw runtime_error(e);
} }
catch(const std::runtime_error& e) { catch(const std::runtime_error& e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (a2) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
throw runtime_error(e.what()); throw runtime_error(e.what());
} }
catch(const std::exception& e) { catch(const std::exception& e) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,e.what(),codeLocation.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (b) Couldn't process event: [%s] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.what(),codeLocation.c_str());
} }
catch(...) { catch(...) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeLocation.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",__FILE__,__FUNCTION__,__LINE__,codeLocation.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] (c) Couldn't process event: [UNKNOWN ERROR] codeLocation = %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,codeLocation.c_str());
} }
} }
@@ -443,7 +443,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
// setup LOD bias factor // setup LOD bias factor
//const float lodBias = std::max(std::min( configHandler->Get("TextureLODBias", 0.0f) , 4.0f), -4.0f); //const float lodBias = std::max(std::min( configHandler->Get("TextureLODBias", 0.0f) , 4.0f), -4.0f);
const float lodBias = max(min(0.0f,4.0f),-4.0f); const float lodBias = max(min(0.0f,4.0f),-4.0f);
//if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("\n\n\n\n\n$$$$ In [%s::%s Line: %d] lodBias = %f\n\n",__FILE__,__FUNCTION__,__LINE__,lodBias); //if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("\n\n\n\n\n$$$$ In [%s::%s Line: %d] lodBias = %f\n\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,lodBias);
#ifdef USE_STREFLOP #ifdef USE_STREFLOP
if (streflop::fabs(lodBias) > 0.01f) { if (streflop::fabs(lodBias) > 0.01f) {
#else #else
@@ -455,7 +455,7 @@ void Window::setupGraphicsScreen(int depthBits, int stencilBits, bool hardware_a
} }
void Window::toggleFullscreen() { void Window::toggleFullscreen() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Window::isFullScreen = !Window::isFullScreen; Window::isFullScreen = !Window::isFullScreen;
#ifdef WIN32 #ifdef WIN32
@@ -486,14 +486,14 @@ void Window::toggleFullscreen() {
if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface. if ( (!surface) || (!(*surface)) ) // don't bother if there's no surface.
return; return;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
tmpflags = (*surface)->flags; tmpflags = (*surface)->flags;
w = (*surface)->w; w = (*surface)->w;
h = (*surface)->h; h = (*surface)->h;
bpp = (*surface)->format->BitsPerPixel; bpp = (*surface)->format->BitsPerPixel;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",__FILE__,__FUNCTION__,__LINE__,w,h,bpp); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n w = %d, h = %d, bpp = %d",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,w,h,bpp);
if (flags == NULL) // use the surface's flags. if (flags == NULL) // use the surface's flags.
flags = &tmpflags; flags = &tmpflags;
@@ -507,16 +507,16 @@ void Window::toggleFullscreen() {
SDL_GetClipRect(*surface, &clip); SDL_GetClipRect(*surface, &clip);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, (*flags)); *surface = SDL_SetVideoMode(w, h, bpp, (*flags));
if (*surface == NULL) { if (*surface == NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
*surface = SDL_SetVideoMode(w, h, bpp, tmpflags); *surface = SDL_SetVideoMode(w, h, bpp, tmpflags);
} // if } // if
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
SDL_SetClipRect(*surface, &clip); SDL_SetClipRect(*surface, &clip);
} }
@@ -524,14 +524,14 @@ void Window::toggleFullscreen() {
else { else {
HWND handle = GetSDLWindow(); HWND handle = GetSDLWindow();
if(Window::isFullScreen == true) { if(Window::isFullScreen == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == true [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_MAXIMIZE); ShowWindow(handle, SW_MAXIMIZE);
//if(Window::getUseDefaultCursorOnly() == false) { //if(Window::getUseDefaultCursorOnly() == false) {
// showCursor(false); // showCursor(false);
//} //}
} }
else { else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",__FILE__,__FUNCTION__,__LINE__,handle); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d] Window::isFullScreen == false [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,handle);
ShowWindow(handle, SW_RESTORE); ShowWindow(handle, SW_RESTORE);
//showCursor(true); //showCursor(true);
} }
@@ -539,31 +539,31 @@ void Window::toggleFullscreen() {
#else #else
if(Window::allowAltEnterFullscreenToggle == true) { if(Window::allowAltEnterFullscreenToggle == true) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) { if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == false) {
SDL_Surface *cur_surface = SDL_GetVideoSurface(); SDL_Surface *cur_surface = SDL_GetVideoSurface();
if(cur_surface != NULL) { if(cur_surface != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
SDL_WM_ToggleFullScreen(cur_surface); SDL_WM_ToggleFullScreen(cur_surface);
} }
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
#endif #endif
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
void Window::handleMouseDown(SDL_Event event) { void Window::handleMouseDown(SDL_Event event) {
static const Uint32 DOUBLECLICKTIME = 500; static const Uint32 DOUBLECLICKTIME = 500;
static const int DOUBLECLICKDELTA = 5; static const int DOUBLECLICKDELTA = 5;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
MouseButton button = getMouseButton(event.button.button); MouseButton button = getMouseButton(event.button.button);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
// windows implementation uses 120 for the resolution of a standard mouse // windows implementation uses 120 for the resolution of a standard mouse
// wheel notch. However, newer mice have finer resolutions. I dunno if SDL // wheel notch. However, newer mice have finer resolutions. I dunno if SDL
@@ -579,35 +579,35 @@ void Window::handleMouseDown(SDL_Event event) {
return; return;
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
Uint32 ticks = SDL_GetTicks(); Uint32 ticks = SDL_GetTicks();
int n = (int) button; int n = (int) button;
assert(n >= 0 && n < mbCount); assert(n >= 0 && n < mbCount);
if(n >= 0 && n < mbCount) { if(n >= 0 && n < mbCount) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(ticks - lastMouseDown[n] < DOUBLECLICKTIME if(ticks - lastMouseDown[n] < DOUBLECLICKTIME
&& abs(lastMouseX[n] - event.button.x) < DOUBLECLICKDELTA && abs(lastMouseX[n] - event.button.x) < DOUBLECLICKDELTA
&& abs(lastMouseY[n] - event.button.y) < DOUBLECLICKDELTA) { && abs(lastMouseY[n] - event.button.y) < DOUBLECLICKDELTA) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
eventMouseDown(event.button.x, event.button.y, button); eventMouseDown(event.button.x, event.button.y, button);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
eventMouseDoubleClick(event.button.x, event.button.y, button); eventMouseDoubleClick(event.button.x, event.button.y, button);
} }
else { else {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
eventMouseDown(event.button.x, event.button.y, button); eventMouseDown(event.button.x, event.button.y, button);
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
lastMouseDown[n] = ticks; lastMouseDown[n] = ticks;
lastMouseX[n] = event.button.x; lastMouseX[n] = event.button.x;
lastMouseY[n] = event.button.y; lastMouseY[n] = event.button.y;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
} }
} }
@@ -625,7 +625,7 @@ MouseButton Window::getMouseButton(int sdlButton) {
return mbWheelDown; return mbWheelDown;
default: default:
//throw std::runtime_error("Mouse Button > 3 not handled."); //throw std::runtime_error("Mouse Button > 3 not handled.");
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",__FILE__,__FUNCTION__,__LINE__,sdlButton); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Mouse Button [%d] not handled.\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,sdlButton);
return mbUnknown; return mbUnknown;
} }
@@ -637,16 +637,16 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
if(input.keysym.unicode > 0) { if(input.keysym.unicode > 0) {
string unicodeKeyName = SDL_GetKeyName((SDLKey)input.keysym.unicode); string unicodeKeyName = SDL_GetKeyName((SDLKey)input.keysym.unicode);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d input.keysym.sym = %d unicodeKeyName [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod,input.keysym.sym,unicodeKeyName.c_str());
// When modifiers are pressed the unicode result is wrong // When modifiers are pressed the unicode result is wrong
// example CTRL-3 will give the ESCAPE vslue 27 in unicode // example CTRL-3 will give the ESCAPE vslue 27 in unicode
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::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
c = input.keysym.unicode; c = input.keysym.unicode;
//c = toupper(c); //c = toupper(c);
@@ -674,38 +674,40 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
input.keysym.unicode == SDLK_COMMA || input.keysym.unicode == SDLK_COMMA ||
input.keysym.unicode == SDLK_MINUS || input.keysym.unicode == SDLK_MINUS ||
input.keysym.unicode == SDLK_PERIOD || input.keysym.unicode == SDLK_PERIOD ||
input.keysym.unicode == SDLK_SLASH)) { input.keysym.unicode == SDLK_SLASH ||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); // Need to allow Shift + # key for AZERTY style keyboards
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9))) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
c = input.keysym.unicode; c = input.keysym.unicode;
} }
else if(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) { else if(input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if( (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9) || if( (input.keysym.unicode >= SDLK_0 && input.keysym.unicode <= SDLK_9) ||
(input.keysym.unicode >= SDLK_KP0 && input.keysym.unicode <= SDLK_KP9)) { (input.keysym.unicode >= SDLK_KP0 && input.keysym.unicode <= SDLK_KP9)) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
c = input.keysym.unicode; c = input.keysym.unicode;
} }
} }
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
} }
//if(c == 0) { //if(c == 0) {
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
c = input.keysym.sym; c = input.keysym.sym;
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
//c = (c & 0xFF); //c = (c & 0xFF);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
// SDL does NOT handle lowercase // SDL does NOT handle lowercase
if(c >= 'A' && c <= 'Z') { if(c >= 'A' && c <= 'Z') {
@@ -806,20 +808,20 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow
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",__FILE__,__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;
} }
} }
string compareKeyName = SDL_GetKeyName(compareKey); string compareKeyName = SDL_GetKeyName(compareKey);
string pressKeyName = SDL_GetKeyName((SDLKey)c); string pressKeyName = SDL_GetKeyName((SDLKey)c);
//printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); //printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
//printf ("ISPRESS compareKey [%d - %s] pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d result = %d\n", //printf ("ISPRESS compareKey [%d - %s] pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d result = %d\n",
// compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod,result); // compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod,result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] compareKey [%d - %s] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,compareKey,compareKeyName.c_str(),c,pressKeyName.c_str(),result);
return result; return result;
} }
@@ -828,7 +830,7 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
wchar_t c = SDLK_UNKNOWN; wchar_t c = SDLK_UNKNOWN;
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) { //if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
if(input.keysym.unicode > 0) { if(input.keysym.unicode > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod);
c = input.keysym.unicode; c = input.keysym.unicode;
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { // if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
@@ -837,18 +839,18 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
//c = toupper(c); //c = toupper(c);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF),c); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF),c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d] c = [%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF),c);
} }
if(c == SDLK_UNKNOWN) { if(c == SDLK_UNKNOWN) {
c = input.keysym.sym; c = input.keysym.sym;
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d][%lc]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d][%lc]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
//c = (SDLKey)(c & 0xFF); //c = (SDLKey)(c & 0xFF);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
string pressKeyName = SDL_GetKeyName((SDLKey)c); string pressKeyName = SDL_GetKeyName((SDLKey)c);
string inputKeyName = SDL_GetKeyName(input.keysym.sym); string inputKeyName = SDL_GetKeyName(input.keysym.sym);
@@ -856,8 +858,8 @@ wchar_t extractKeyPressedUnicode(SDL_KeyboardEvent input) {
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n", //printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod); // c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
return c; return c;
} }
@@ -866,7 +868,7 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
SDLKey c = SDLK_UNKNOWN; SDLKey c = SDLK_UNKNOWN;
//if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) { //if(input.keysym.unicode > 0 && input.keysym.unicode < 0x80) {
if(input.keysym.unicode > 0) { if(input.keysym.unicode > 0) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",__FILE__,__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] input.keysym.unicode = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,input.keysym.unicode,input.keysym.mod);
c = (SDLKey)input.keysym.unicode; c = (SDLKey)input.keysym.unicode;
// if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { // if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
@@ -875,18 +877,18 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
//c = toupper(c); //c = toupper(c);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",__FILE__,__FUNCTION__,__LINE__,(c & 0xFF)); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] #1 (c & 0xFF) [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,(c & 0xFF));
} }
if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) { if(c <= SDLK_UNKNOWN || c >= SDLK_LAST) {
c = input.keysym.sym; c = input.keysym.sym;
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %u] c = [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
//c = (SDLKey)(c & 0xFF); //c = (SDLKey)(c & 0xFF);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",__FILE__,__FUNCTION__,__LINE__,c); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] returning key [%d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c);
string pressKeyName = SDL_GetKeyName((SDLKey)c); string pressKeyName = SDL_GetKeyName((SDLKey)c);
string inputKeyName = SDL_GetKeyName(input.keysym.sym); string inputKeyName = SDL_GetKeyName(input.keysym.sym);
@@ -894,8 +896,8 @@ SDLKey extractKeyPressed(SDL_KeyboardEvent input) {
//printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n", //printf ("PRESS pressed key [%d - %s] input.keysym.sym [%d] input.keysym.unicode [%d] mod = %d\n",
// c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod); // c,pressKeyName.c_str(),input.keysym.sym,input.keysym.unicode,input.keysym.mod);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",__FILE__,__FUNCTION__,__LINE__,c,pressKeyName.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,c,pressKeyName.c_str());
return c; return c;
} }
@@ -954,8 +956,8 @@ bool isAllowedInputTextKey(wchar_t &key) {
key != SDLK_POWER); key != SDLK_POWER);
string inputKeyName = SDL_GetKeyName((SDLKey)key); string inputKeyName = SDL_GetKeyName((SDLKey)key);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
return result; return result;
} }
@@ -1014,8 +1016,8 @@ bool isAllowedInputTextKey(SDLKey key) {
key != SDLK_POWER); key != SDLK_POWER);
string inputKeyName = SDL_GetKeyName(key); string inputKeyName = SDL_GetKeyName(key);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",__FILE__,__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] pressed key [%d - %s] result = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,key,inputKeyName.c_str(),result);
return result; return result;
} }

View File

@@ -257,7 +257,15 @@ void init_win32() {
HWND hwnd = wminfo.window; HWND hwnd = wminfo.window;
::SetClassLong(hwnd, GCL_HICON, (LONG) icon); #ifdef __MINGW32__
#define GCL_HICON -14
#endif
#ifndef __MINGW32__
LONG iconPtr = (LONG)icon;
::SetClassLong(hwnd, GCL_HICON, iconPtr);
#endif
} }
void done_win32() { void done_win32() {
::DestroyIcon(icon); ::DestroyIcon(icon);

View File

@@ -13,7 +13,7 @@ INCLUDE_DIRECTORIES(
SET(STREFLOP_SRC ${STREFLOP_GLOBBED_CPP}) SET(STREFLOP_SRC ${STREFLOP_GLOBBED_CPP})
# use SSE unconditionally (FIXME?) # use SSE unconditionally (FIXME?)
SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}") #SET_SOURCE_FILES_PROPERTIES(${STREFLOP_SRC} PROPERTIES COMPILE_FLAGS "-DSTREFLOP_SSE -DLIBM_COMPILING_FLT32 -O3 ${CXXFLAGS}")
ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL ADD_LIBRARY(streflop STATIC EXCLUDE_FROM_ALL
${STREFLOP_SRC} ${STREFLOP_SRC}

View File

@@ -136,6 +136,9 @@ string doubleToStr(double d,int precsion) {
} }
bool IsNumeric(const char *p, bool allowNegative) { bool IsNumeric(const char *p, bool allowNegative) {
if(p != NULL && strcmp(p,"-") == 0) {
return false;
}
int index = 0; int index = 0;
for ( ; *p; p++) { for ( ; *p; p++) {
if (*p < '0' || *p > '9') { if (*p < '0' || *p > '9') {

View File

@@ -67,7 +67,7 @@ void Properties::load(const string &path, bool clearCurrentProperties) {
#endif #endif
if(fileStream.is_open() == false){ if(fileStream.is_open() == false){
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
throw runtime_error("File NOT FOUND, can't open file: [" + path + "]"); throw runtime_error("File NOT FOUND, can't open file: [" + path + "]");
} }
@@ -215,9 +215,9 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath; mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath;
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
mapTagReplacementValues["$APPLICATIONDATAPATH"] = CUSTOM_DATA_INSTALL_PATH; mapTagReplacementValues["$APPLICATIONDATAPATH"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH);
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = CUSTOM_DATA_INSTALL_PATH; mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH);
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = CUSTOM_DATA_INSTALL_PATH; mapTagReplacementValues["{APPLICATIONDATAPATH}"] = TOSTRING(CUSTOM_DATA_INSTALL_PATH);
//mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
@@ -308,9 +308,9 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath); replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath);
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
replaceAll(value, "$APPLICATIONDATAPATH", CUSTOM_DATA_INSTALL_PATH); replaceAll(value, "$APPLICATIONDATAPATH", TOSTRING(CUSTOM_DATA_INSTALL_PATH));
replaceAll(value, "%%APPLICATIONDATAPATH%%", CUSTOM_DATA_INSTALL_PATH); replaceAll(value, "%%APPLICATIONDATAPATH%%", TOSTRING(CUSTOM_DATA_INSTALL_PATH));
replaceAll(value, "{APPLICATIONDATAPATH}", CUSTOM_DATA_INSTALL_PATH); replaceAll(value, "{APPLICATIONDATAPATH}", TOSTRING(CUSTOM_DATA_INSTALL_PATH));
//replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
@@ -364,7 +364,7 @@ bool Properties::getBool(const string &key, const char *defaultValueIfNotFound)
return strToBool(getString(key,defaultValueIfNotFound)); return strToBool(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -374,7 +374,7 @@ int Properties::getInt(const string &key,const char *defaultValueIfNotFound) con
return strToInt(getString(key,defaultValueIfNotFound)); return strToInt(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -392,7 +392,7 @@ float Properties::getFloat(const string &key, const char *defaultValueIfNotFound
return strToFloat(getString(key,defaultValueIfNotFound)); return strToFloat(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -410,7 +410,7 @@ const string Properties::getString(const string &key, const char *defaultValueIf
it= propertyMap.find(key); it= propertyMap.find(key);
if(it==propertyMap.end()){ if(it==propertyMap.end()){
if(defaultValueIfNotFound != NULL) { if(defaultValueIfNotFound != NULL) {
//printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",__FILE__,__FUNCTION__,__LINE__,defaultValueIfNotFound); //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound);
return string(defaultValueIfNotFound); return string(defaultValueIfNotFound);
} }
else { else {
@@ -456,7 +456,7 @@ bool Properties::getBool(const char *key, const char *defaultValueIfNotFound) co
return strToBool(getString(key,defaultValueIfNotFound)); return strToBool(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -466,7 +466,7 @@ int Properties::getInt(const char *key,const char *defaultValueIfNotFound) const
return strToInt(getString(key,defaultValueIfNotFound)); return strToInt(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -476,7 +476,7 @@ float Properties::getFloat(const char *key, const char *defaultValueIfNotFound)
return strToFloat(getString(key,defaultValueIfNotFound)); return strToFloat(getString(key,defaultValueIfNotFound));
} }
catch(exception &e){ catch(exception &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,e.what()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,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() + "]");
} }
} }
@@ -486,7 +486,7 @@ const string Properties::getString(const char *key, const char *defaultValueIfNo
it= propertyMap.find(key); it= propertyMap.find(key);
if(it==propertyMap.end()){ if(it==propertyMap.end()){
if(defaultValueIfNotFound != NULL) { if(defaultValueIfNotFound != NULL) {
//printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",__FILE__,__FUNCTION__,__LINE__,defaultValueIfNotFound); //printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound);
return string(defaultValueIfNotFound); return string(defaultValueIfNotFound);
} }
else { else {

View File

@@ -70,7 +70,7 @@ XmlIo::XmlIo() {
XmlIo::initialized= true; XmlIo::initialized= true;
} }
catch(const XMLException &e){ catch(const XMLException &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",__FILE__,__FUNCTION__,__LINE__,e.getMessage()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error initializing XML system, msg %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,e.getMessage());
throw runtime_error("Error initializing XML system"); throw runtime_error("Error initializing XML system");
} }
@@ -81,7 +81,7 @@ XmlIo::XmlIo() {
implementation = DOMImplementationRegistry::getDOMImplementation(str); implementation = DOMImplementationRegistry::getDOMImplementation(str);
} }
catch(const DOMException &ex) { catch(const DOMException &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",__FILE__,__FUNCTION__,__LINE__,ex.getMessage()); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while creating XML parser, msg: %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,ex.getMessage());
throw runtime_error("Exception while creating XML parser"); throw runtime_error("Exception while creating XML parser");
} }
} }
@@ -135,7 +135,7 @@ XmlNode *XmlIo::load(const string &path, std::map<string,string> mapTagReplaceme
return rootNode; return rootNode;
} }
catch(const DOMException &ex) { catch(const DOMException &ex) {
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg)); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while loading: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(ex.msg));
throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(ex.msg)); throw runtime_error("Exception while loading: " + path + ": " + XMLString::transcode(ex.msg));
} }
} }
@@ -170,7 +170,7 @@ void XmlIo::save(const string &path, const XmlNode *node){
document->release(); document->release();
} }
catch(const DOMException &e){ catch(const DOMException &e){
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",__FILE__,__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg)); SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Exception while saving: [%s], %s\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str(),XMLString::transcode(e.msg));
throw runtime_error("Exception while saving: " + path + ": " + XMLString::transcode(e.msg)); throw runtime_error("Exception while saving: " + path + ": " + XMLString::transcode(e.msg));
} }
} }
@@ -191,6 +191,8 @@ typedef std::vector<XmlTree*> LoadStack;
static string loadStackCacheName = string(__FILE__) + string("_loadStackCacheName"); static string loadStackCacheName = string(__FILE__) + string("_loadStackCacheName");
void XmlTree::load(const string &path, std::map<string,string> mapTagReplacementValues) { void XmlTree::load(const string &path, std::map<string,string> mapTagReplacementValues) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
//printf("XmlTree::load p [%p]\n",this); //printf("XmlTree::load p [%p]\n",this);
assert(!loadPath.size()); assert(!loadPath.size());
@@ -208,6 +210,8 @@ void XmlTree::load(const string &path, std::map<string,string> mapTagReplacement
loadPath = path; loadPath = path;
this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues); this->rootNode= XmlIo::getInstance().load(path, mapTagReplacementValues);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] about to load [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,path.c_str());
} }
void XmlTree::save(const string &path){ void XmlTree::save(const string &path){