From d5b39728076855a08640785319b8d96a17089f9c Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 14:07:26 -0800 Subject: [PATCH 01/11] added new color picking tests to repo --- .../tests/shared_lib/graphics/model_test.cpp | 84 +++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 source/tests/shared_lib/graphics/model_test.cpp diff --git a/source/tests/shared_lib/graphics/model_test.cpp b/source/tests/shared_lib/graphics/model_test.cpp new file mode 100644 index 00000000..56c524e1 --- /dev/null +++ b/source/tests/shared_lib/graphics/model_test.cpp @@ -0,0 +1,84 @@ +// ============================================================== +// This file is part of MegaGlest Unit Tests (www.megaglest.org) +// +// Copyright (C) 2013 Mark Vejvoda +// +// You can redistribute this code and/or modify it under +// the terms of the GNU General Public License as published +// by the Free Software Foundation; either version 2 of the +// License, or (at your option) any later version +// ============================================================== + +#include +#include +#include "model.h" +#include +#include + +#ifdef WIN32 +#include +#else +#include +#endif + +using namespace Shared::Graphics; + +class TestBaseColorPickEntity : public BaseColorPickEntity { +public: + virtual string getUniquePickName() const { + return getColorDescription(); + } +}; +// +// Tests for font class +// +class ModelTest : public CppUnit::TestFixture { + // Register the suite of tests for this fixture + CPPUNIT_TEST_SUITE( ModelTest ); + + CPPUNIT_TEST( test_ColorPicking_loop ); + CPPUNIT_TEST( test_ColorPicking_prime ); + + CPPUNIT_TEST_SUITE_END(); + // End of Fixture registration + +public: + + void test_ColorPicking_loop() { + + BaseColorPickEntity::setTrackColorUse(true); + BaseColorPickEntity::setUsingLoopMethod(true); + BaseColorPickEntity::resetUniqueColors(); + + TestBaseColorPickEntity colorPicker; + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 32767; + for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD; ++i) { + bool duplicate = colorPicker.get_next_assign_color(colorPicker.getUniqueColorID()); + CPPUNIT_ASSERT_EQUAL( false,duplicate ); + } + + BaseColorPickEntity::setTrackColorUse(false); + } + + void test_ColorPicking_prime() { + + BaseColorPickEntity::setTrackColorUse(true); + BaseColorPickEntity::setUsingLoopMethod(false); + BaseColorPickEntity::resetUniqueColors(); + + TestBaseColorPickEntity colorPicker; + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 472; + for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD; ++i) { + bool duplicate = colorPicker.get_next_assign_color(colorPicker.getUniqueColorID()); + CPPUNIT_ASSERT_EQUAL( false,duplicate ); + } + + BaseColorPickEntity::setTrackColorUse(false); + } + +}; + + +// Test Suite Registrations +CPPUNIT_TEST_SUITE_REGISTRATION( ModelTest ); +// From 2ff75c54e28300e6acd6cbacab95d3aa6cb606a3 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 14:29:02 -0800 Subject: [PATCH 02/11] merged updates --- mk/linux/mg_cppcheck.sh | 1 + source/glest_game/facilities/game_util.cpp | 2 +- source/glest_game/game/game.cpp | 7 + source/shared_lib/include/graphics/model.h | 32 +++- source/shared_lib/sources/graphics/model.cpp | 158 +++++++++++++++++-- 5 files changed, 184 insertions(+), 16 deletions(-) diff --git a/mk/linux/mg_cppcheck.sh b/mk/linux/mg_cppcheck.sh index 39eb54bd..d60a14ca 100755 --- a/mk/linux/mg_cppcheck.sh +++ b/mk/linux/mg_cppcheck.sh @@ -9,6 +9,7 @@ OUTFILE=./cppcheck.log CPUS=`lscpu -p | grep -cv '^#'` if [ "$CPUS" = '' ]; then CPUS=1; fi +#~/cppcheck-1.62/cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE cppcheck ../../source/ -i ../../source/win32_deps -i ../../source/configurator -i ../../source/shared_lib/sources/libircclient -i ../../source/shared_lib/sources/platform/miniupnpc -j $CPUS --enable=all --force --verbose 2> $OUTFILE echo "Results from cppcheck were written to $OUTFILE" diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 4224fb67..4bbc6335 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -36,7 +36,7 @@ const string GIT_Rev = string("Rev: ") + string(GITVERSION); const string GIT_RawRev = string(GITVERSION); const string GIT_Rev = string("Rev: ") + string(GITVERSION); #else -const string GIT_RawRev = "$4790$"; +const string GIT_RawRev = "$4446.1a8673f$"; const string GIT_Rev = "$Rev$"; #endif diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 7200745f..86675551 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -430,6 +430,8 @@ Game::~Game() { world.end(); //must die before selection because of referencers + BaseColorPickEntity::resetUniqueColors(); + if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] aiInterfaces.size() = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,aiInterfaces.size()); delete videoPlayer; @@ -1001,6 +1003,8 @@ void Game::load(int loadTypes) { SoundRenderer &soundRenderer= SoundRenderer::getInstance(); soundRenderer.stopAllSounds(fadeMusicMilliseconds); + BaseColorPickEntity::resetUniqueColors(); + Config &config = Config::getInstance(); Logger &logger= Logger::getInstance(); @@ -2608,6 +2612,8 @@ void Game::update() { aiInterfaces.clear(); gui.end(); //selection must be cleared before deleting units world.end(); //must die before selection because of referencers + + BaseColorPickEntity::resetUniqueColors(); // MUST DO THIS LAST!!!! Because objects above have pointers to things like // unit particles and fade them out etc and this end method deletes the original // object pointers. @@ -2632,6 +2638,7 @@ void Game::update() { soundRenderer.stopAllSounds(fadeMusicMilliseconds); world.endScenario(); + BaseColorPickEntity::resetUniqueColors(); Renderer &renderer= Renderer::getInstance(); renderer.endScenario(); diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 5c6bed45..014929a9 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -263,7 +263,8 @@ public: BaseColorPickEntity(); virtual ~BaseColorPickEntity() {} - static const int COLOR_COMPONENTS = 4; + //static const int COLOR_COMPONENTS = 4; + static const int COLOR_COMPONENTS = 3; static void init(int bufferSize); static void beginPicking(); static void endPicking(); @@ -275,16 +276,39 @@ public: string getColorDescription() const; virtual string getUniquePickName() const = 0; -private: - unsigned char uniqueColorID[COLOR_COMPONENTS]; + static void resetUniqueColors(); - static int nextColorID; + static void setUsingLoopMethod(bool value) { using_loop_method = value; } + + static void setTrackColorUse(bool value) { trackColorUse = value; } + unsigned char * getUniqueColorID() { return &uniqueColorID[0]; } + bool get_next_assign_color(unsigned char *assign_to); + +protected: + + void recycleUniqueColor(); + +private: + unsigned char uniqueColorID[COLOR_COMPONENTS]; + + static unsigned char nextColorID[COLOR_COMPONENTS]; + static int nextColorRGB; static const int k, p; static Mutex mutexNextColorID; + static bool using_loop_method; + + static bool trackColorUse; + static map usedColorIDList; + + static vector > nextColorIDReuseList; + static auto_ptr pbo; void assign_color(); + + void assign_color_using_prime(unsigned char *assign_to); + void assign_color_using_loop(unsigned char *assign_to); }; }}//end namespace diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index fdc14c76..1a499cef 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1828,33 +1828,169 @@ PixelBufferWrapper::~PixelBufferWrapper() { const int BaseColorPickEntity::p = 64007; const int BaseColorPickEntity::k = 43067; -int BaseColorPickEntity::nextColorID = BaseColorPickEntity::k; +int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; Mutex BaseColorPickEntity::mutexNextColorID; +unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1 }; auto_ptr BaseColorPickEntity::pbo; +map BaseColorPickEntity::usedColorIDList; +bool BaseColorPickEntity::trackColorUse = true; + +vector > BaseColorPickEntity::nextColorIDReuseList; + +bool BaseColorPickEntity::using_loop_method = true; + BaseColorPickEntity::BaseColorPickEntity() { assign_color(); } -void BaseColorPickEntity::assign_color() { - +bool BaseColorPickEntity::get_next_assign_color(unsigned char *assign_to) { MutexSafeWrapper safeMutex(&mutexNextColorID); - nextColorID = (nextColorID * k) % p; + if(assign_to == NULL) { + throw megaglest_runtime_error("assign_to == NULL"); + } + + if(BaseColorPickEntity::using_loop_method == true) { + assign_color_using_loop(assign_to); + } + else { + assign_color_using_prime(assign_to); + } + + bool isDuplicate = false; + if(BaseColorPickEntity::trackColorUse == true) { + string color_key = getColorDescription(); + //printf("Assigned color [%s]\n",color_key.c_str()); + + if(usedColorIDList.find(color_key) == usedColorIDList.end()) { + usedColorIDList[color_key] = true; + } + else { + isDuplicate = true; + printf("Line ref: %d *WARNING* color [%s] used count: %d using_loop: %d ALREADY in history list!\n",__LINE__,color_key.c_str(),(int)usedColorIDList.size(),BaseColorPickEntity::using_loop_method); + } + } + return isDuplicate; +} + +void BaseColorPickEntity::assign_color() { + get_next_assign_color(&uniqueColorID[0]); +} + +void BaseColorPickEntity::assign_color_using_prime(unsigned char *assign_to) { + nextColorRGB = (nextColorRGB * k) % p; // nextColorID is a 16-bit (hi)colour (for players with 16-bit display depths) // we expand it to true-color for use with OpenGL +// const int +// r = (nextColorRGB >> 11) & ((1<<6)-1), +// b = (nextColorRGB >> 5) & ((1<<7)-1), +// g = nextColorRGB & ((1<<6)-1); const int - r = (nextColorID >> 11) & ((1<<5)-1), - g = (nextColorID >> 5) & ((1<<6)-1), - b = nextColorID & ((1<<5)-1); - - uniqueColorID[0] = r << 3; - uniqueColorID[1] = g << 2; - uniqueColorID[2] = b << 3; + r = (nextColorRGB >> 11) & ((1<<5)-1), + g = (nextColorRGB >> 5) & ((1<<6)-1), + b = nextColorRGB & ((1<<5)-1); + + assign_to[0] = r << 3; + assign_to[1] = g << 2; + assign_to[2] = b << 3; } +void BaseColorPickEntity::assign_color_using_loop(unsigned char *assign_to) { + if(nextColorIDReuseList.empty() == false) { + assign_to[0] = nextColorIDReuseList.back()[0]; + assign_to[1] = nextColorIDReuseList.back()[1]; + assign_to[2] = nextColorIDReuseList.back()[2]; + + nextColorIDReuseList.pop_back(); + + string color_key = getColorDescription(); + if(usedColorIDList.find(color_key) == usedColorIDList.end()) { + usedColorIDList[color_key] = true; + } + else { + printf("Line ref: %d *WARNING* color [%s] ALREADY FOUND in history list!\n",__LINE__,color_key.c_str()); + assign_color_using_loop(assign_to); + } + } + else { + assign_to[0] = nextColorID[0]; + assign_to[1] = nextColorID[1]; + assign_to[2] = nextColorID[2]; + + const int colorSpacing = 8; + + if((int)(nextColorID[0] + colorSpacing) <= 255) { + nextColorID[0] += colorSpacing; + } + else { + nextColorID[0] = 1; + if((int)(nextColorID[1] + colorSpacing) <= 255) { + nextColorID[1] += colorSpacing; + } + else { + nextColorID[1] = 1; + if((int)(nextColorID[2] + colorSpacing) <= 255) { + nextColorID[2] += colorSpacing; + } + else { + + //printf("Color rolled over on 3rd level!\n"); + + nextColorID[0] = 1; + nextColorID[1] = 1; + nextColorID[2] = 1; + + + // nextColorID[2] = 1; + // nextColorID[3]+=colorSpacing; + // + // if(nextColorID[3] > 255) { + // nextColorID[0] = 1; + // nextColorID[1] = 1; + // nextColorID[2] = 1; + // nextColorID[3] = 1; + // } + } + } + } + } +} + +void BaseColorPickEntity::recycleUniqueColor() { + MutexSafeWrapper safeMutex(&mutexNextColorID); + + vector reUseColor; + reUseColor.push_back(uniqueColorID[0]); + reUseColor.push_back(uniqueColorID[1]); + reUseColor.push_back(uniqueColorID[2]); + nextColorIDReuseList.push_back(reUseColor); + + if(usedColorIDList.size() > 0) { + string color_key = getColorDescription(); + if(usedColorIDList.find(color_key) != usedColorIDList.end()) { + usedColorIDList.erase(color_key); + } + else { + printf("Line ref: %d *WARNING* color [%s] used count: %d NOT FOUND in history list!\n",__LINE__,color_key.c_str(),(int)usedColorIDList.size()); + } + } +} + +void BaseColorPickEntity::resetUniqueColors() { + MutexSafeWrapper safeMutex(&mutexNextColorID); + + BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; + + BaseColorPickEntity::nextColorID[0] = 1; + BaseColorPickEntity::nextColorID[1] = 1; + BaseColorPickEntity::nextColorID[2] = 1; + + usedColorIDList.clear(); + nextColorIDReuseList.clear(); +} void BaseColorPickEntity::init(int bufferSize) { if(BaseColorPickEntity::pbo.get() == NULL) { BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,bufferSize)); From c2929e3d2bcdee2bdf32a1ba58a11e6b3a81f49d Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 14:31:05 -0800 Subject: [PATCH 03/11] merged --- source/shared_lib/sources/graphics/model.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 1a499cef..21d10397 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1889,9 +1889,9 @@ void BaseColorPickEntity::assign_color_using_prime(unsigned char *assign_to) { // b = (nextColorRGB >> 5) & ((1<<7)-1), // g = nextColorRGB & ((1<<6)-1); const int - r = (nextColorRGB >> 11) & ((1<<5)-1), - g = (nextColorRGB >> 5) & ((1<<6)-1), - b = nextColorRGB & ((1<<5)-1); + r = (nextColorRGB >> 11) & ((1<<5)-1), + g = (nextColorRGB >> 5) & ((1<<6)-1), + b = nextColorRGB & ((1<<5)-1); assign_to[0] = r << 3; assign_to[1] = g << 2; From b36244fcbd0673daf561583e740035f7e81cbf4b Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 14:48:11 -0800 Subject: [PATCH 04/11] updated unit test to show max colors supported and when each algorithm fails. --- .../tests/shared_lib/graphics/model_test.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/source/tests/shared_lib/graphics/model_test.cpp b/source/tests/shared_lib/graphics/model_test.cpp index 56c524e1..ee221bc4 100644 --- a/source/tests/shared_lib/graphics/model_test.cpp +++ b/source/tests/shared_lib/graphics/model_test.cpp @@ -51,12 +51,24 @@ public: BaseColorPickEntity::resetUniqueColors(); TestBaseColorPickEntity colorPicker; + // This is the max color count this algorithm supports const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 32767; for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD; ++i) { bool duplicate = colorPicker.get_next_assign_color(colorPicker.getUniqueColorID()); CPPUNIT_ASSERT_EQUAL( false,duplicate ); } + BaseColorPickEntity::resetUniqueColors(); + + TestBaseColorPickEntity colorPicker2; + // This is a test to prove when the algorithm fails + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL = 32768; + for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL; ++i) { + bool duplicate = colorPicker2.get_next_assign_color(colorPicker2.getUniqueColorID()); + CPPUNIT_ASSERT_EQUAL( (i+1 >= MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL),duplicate ); + } + + BaseColorPickEntity::resetUniqueColors(); BaseColorPickEntity::setTrackColorUse(false); } @@ -67,12 +79,24 @@ public: BaseColorPickEntity::resetUniqueColors(); TestBaseColorPickEntity colorPicker; + // This is the max color count this algorithm supports const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 472; for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD; ++i) { bool duplicate = colorPicker.get_next_assign_color(colorPicker.getUniqueColorID()); CPPUNIT_ASSERT_EQUAL( false,duplicate ); } + BaseColorPickEntity::resetUniqueColors(); + + TestBaseColorPickEntity colorPicker2; + // This is a test to prove when the algorithm fails + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL = 473; + for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL; ++i) { + bool duplicate = colorPicker2.get_next_assign_color(colorPicker2.getUniqueColorID()); + CPPUNIT_ASSERT_EQUAL( (i+1 >= MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL),duplicate ); + } + + BaseColorPickEntity::resetUniqueColors(); BaseColorPickEntity::setTrackColorUse(false); } From f7bc5e8f92846dccfc5eb116618e2eb4be5a6b40 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 17:20:30 -0800 Subject: [PATCH 05/11] - bugfix and additional code (for now) to track duplicates and problems in color picking. We now use will's implementation as it supports 64K colors. --- source/shared_lib/include/graphics/model.h | 21 ++++---- source/shared_lib/sources/graphics/model.cpp | 54 +++++++++++-------- .../tests/shared_lib/graphics/model_test.cpp | 4 +- 3 files changed, 46 insertions(+), 33 deletions(-) diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index 014929a9..d4ed8047 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -261,10 +261,12 @@ class BaseColorPickEntity { public: BaseColorPickEntity(); - virtual ~BaseColorPickEntity() {} + virtual ~BaseColorPickEntity() { + recycleUniqueColor(); + } - //static const int COLOR_COMPONENTS = 4; - static const int COLOR_COMPONENTS = 3; + //static const int COLOR_COMPONENTS = 3; + static const int COLOR_COMPONENTS = 4; static void init(int bufferSize); static void beginPicking(); static void endPicking(); @@ -284,17 +286,14 @@ public: unsigned char * getUniqueColorID() { return &uniqueColorID[0]; } bool get_next_assign_color(unsigned char *assign_to); -protected: - - void recycleUniqueColor(); - private: + unsigned char uniqueColorID[COLOR_COMPONENTS]; static unsigned char nextColorID[COLOR_COMPONENTS]; - static int nextColorRGB; - static const int k, p; - static Mutex mutexNextColorID; + static unsigned int nextColorRGB; + static const unsigned int k, p; + //static Mutex mutexNextColorID; static bool using_loop_method; @@ -309,6 +308,8 @@ private: void assign_color_using_prime(unsigned char *assign_to); void assign_color_using_loop(unsigned char *assign_to); + + void recycleUniqueColor(); }; }}//end namespace diff --git a/source/shared_lib/sources/graphics/model.cpp b/source/shared_lib/sources/graphics/model.cpp index 21d10397..1087bb07 100644 --- a/source/shared_lib/sources/graphics/model.cpp +++ b/source/shared_lib/sources/graphics/model.cpp @@ -1826,11 +1826,14 @@ PixelBufferWrapper::~PixelBufferWrapper() { cleanup(); } -const int BaseColorPickEntity::p = 64007; -const int BaseColorPickEntity::k = 43067; -int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; -Mutex BaseColorPickEntity::mutexNextColorID; -unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1 }; +// --------------------------------------------------------------------------- + +const unsigned int BaseColorPickEntity::p = 64007; +const unsigned int BaseColorPickEntity::k = 43067; +unsigned int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; + +//Mutex BaseColorPickEntity::mutexNextColorID; +unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1, 0 }; auto_ptr BaseColorPickEntity::pbo; map BaseColorPickEntity::usedColorIDList; @@ -1838,14 +1841,18 @@ bool BaseColorPickEntity::trackColorUse = true; vector > BaseColorPickEntity::nextColorIDReuseList; -bool BaseColorPickEntity::using_loop_method = true; +bool BaseColorPickEntity::using_loop_method = false; BaseColorPickEntity::BaseColorPickEntity() { - assign_color(); + uniqueColorID[0] = 0; + uniqueColorID[1] = 0; + uniqueColorID[2] = 0; + uniqueColorID[3] = 0; + assign_color(); } bool BaseColorPickEntity::get_next_assign_color(unsigned char *assign_to) { - MutexSafeWrapper safeMutex(&mutexNextColorID); + //MutexSafeWrapper safeMutex(&mutexNextColorID); if(assign_to == NULL) { throw megaglest_runtime_error("assign_to == NULL"); @@ -1865,6 +1872,8 @@ bool BaseColorPickEntity::get_next_assign_color(unsigned char *assign_to) { if(usedColorIDList.find(color_key) == usedColorIDList.end()) { usedColorIDList[color_key] = true; + + //printf("Color added to used list [%s] usedColorIDList = %d nextColorIDReuseList = %d!\n",color_key.c_str(),(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); } else { isDuplicate = true; @@ -1884,11 +1893,7 @@ void BaseColorPickEntity::assign_color_using_prime(unsigned char *assign_to) { // nextColorID is a 16-bit (hi)colour (for players with 16-bit display depths) // we expand it to true-color for use with OpenGL -// const int -// r = (nextColorRGB >> 11) & ((1<<6)-1), -// b = (nextColorRGB >> 5) & ((1<<7)-1), -// g = nextColorRGB & ((1<<6)-1); - const int + const unsigned int r = (nextColorRGB >> 11) & ((1<<5)-1), g = (nextColorRGB >> 5) & ((1<<6)-1), b = nextColorRGB & ((1<<5)-1); @@ -1900,6 +1905,8 @@ void BaseColorPickEntity::assign_color_using_prime(unsigned char *assign_to) { void BaseColorPickEntity::assign_color_using_loop(unsigned char *assign_to) { if(nextColorIDReuseList.empty() == false) { + //printf("Color being reused [%u.%u.%u] usedColorIDList = %d nextColorIDReuseList = %d!\n",nextColorIDReuseList.back()[0],nextColorIDReuseList.back()[1],nextColorIDReuseList.back()[2],(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); + assign_to[0] = nextColorIDReuseList.back()[0]; assign_to[1] = nextColorIDReuseList.back()[1]; assign_to[2] = nextColorIDReuseList.back()[2]; @@ -1908,7 +1915,8 @@ void BaseColorPickEntity::assign_color_using_loop(unsigned char *assign_to) { string color_key = getColorDescription(); if(usedColorIDList.find(color_key) == usedColorIDList.end()) { - usedColorIDList[color_key] = true; + //usedColorIDList[color_key] = true; + //printf("Color added to used list [%s] usedColorIDList = %d nextColorIDReuseList = %d!\n",color_key.c_str(),(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); } else { printf("Line ref: %d *WARNING* color [%s] ALREADY FOUND in history list!\n",__LINE__,color_key.c_str()); @@ -1937,11 +1945,11 @@ void BaseColorPickEntity::assign_color_using_loop(unsigned char *assign_to) { } else { - //printf("Color rolled over on 3rd level!\n"); + printf("Color rolled over on 3rd level usedColorIDList = %d!\n",(int)usedColorIDList.size()); - nextColorID[0] = 1; - nextColorID[1] = 1; - nextColorID[2] = 1; + nextColorID[0] = 1; + nextColorID[1] = 1; + nextColorID[2] = 1; // nextColorID[2] = 1; @@ -1960,7 +1968,7 @@ void BaseColorPickEntity::assign_color_using_loop(unsigned char *assign_to) { } void BaseColorPickEntity::recycleUniqueColor() { - MutexSafeWrapper safeMutex(&mutexNextColorID); + //MutexSafeWrapper safeMutex(&mutexNextColorID); vector reUseColor; reUseColor.push_back(uniqueColorID[0]); @@ -1968,10 +1976,14 @@ void BaseColorPickEntity::recycleUniqueColor() { reUseColor.push_back(uniqueColorID[2]); nextColorIDReuseList.push_back(reUseColor); - if(usedColorIDList.size() > 0) { + //printf("RECYCLE Color [%u.%u.%u] usedColorIDList = %d nextColorIDReuseList = %d!\n",reUseColor[0],reUseColor[1],reUseColor[2],(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); + + if(usedColorIDList.empty() == false) { string color_key = getColorDescription(); if(usedColorIDList.find(color_key) != usedColorIDList.end()) { usedColorIDList.erase(color_key); + + //printf("REMOVING used Color [%s] usedColorIDList = %d nextColorIDReuseList = %d!\n",color_key.c_str(),(int)usedColorIDList.size(),(int)nextColorIDReuseList.size()); } else { printf("Line ref: %d *WARNING* color [%s] used count: %d NOT FOUND in history list!\n",__LINE__,color_key.c_str(),(int)usedColorIDList.size()); @@ -1980,7 +1992,7 @@ void BaseColorPickEntity::recycleUniqueColor() { } void BaseColorPickEntity::resetUniqueColors() { - MutexSafeWrapper safeMutex(&mutexNextColorID); + //MutexSafeWrapper safeMutex(&mutexNextColorID); BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k; diff --git a/source/tests/shared_lib/graphics/model_test.cpp b/source/tests/shared_lib/graphics/model_test.cpp index ee221bc4..ae8b5a27 100644 --- a/source/tests/shared_lib/graphics/model_test.cpp +++ b/source/tests/shared_lib/graphics/model_test.cpp @@ -80,7 +80,7 @@ public: TestBaseColorPickEntity colorPicker; // This is the max color count this algorithm supports - const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 472; + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD = 64005; for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD; ++i) { bool duplicate = colorPicker.get_next_assign_color(colorPicker.getUniqueColorID()); CPPUNIT_ASSERT_EQUAL( false,duplicate ); @@ -90,7 +90,7 @@ public: TestBaseColorPickEntity colorPicker2; // This is a test to prove when the algorithm fails - const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL = 473; + const int MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL = 64006; for(unsigned int i = 0; i < MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL; ++i) { bool duplicate = colorPicker2.get_next_assign_color(colorPicker2.getUniqueColorID()); CPPUNIT_ASSERT_EQUAL( (i+1 >= MAX_SUPPORTED_COLORS_USING_THIS_METHOD_FAIL),duplicate ); From 4b50560ca9cadf749e2d850daeb710f7fbca7d5e Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 17:38:32 -0800 Subject: [PATCH 06/11] - added color picking used colors count in debug view --- source/glest_game/game/game.cpp | 7 ++++++- source/shared_lib/include/graphics/model.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 86675551..7b5e23f8 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5275,7 +5275,12 @@ string Game::getDebugStats(std::map &factionDebugInfo) { str+= "ExploredCellsLookupItemCache: " + world.getExploredCellsLookupItemCacheStats()+"\n"; str+= "FowAlphaCellsLookupItemCache: " + world.getFowAlphaCellsLookupItemCacheStats()+"\n"; - str += "Selection type: "+toLower(Config::getInstance().getString("SelectionType",Config::colorPicking))+"\n"; + const string selectionType = toLower(Config::getInstance().getString("SelectionType",Config::colorPicking)); + str += "Selection type: " + toLower(selectionType) + "\n"; + + if(selectionType == Config::colorPicking) { + str += "Color picking used color list size: " + intToStr(BaseColorPickEntity::getUsedColorIDListSize()) +"\n"; + } //str+= "AllFactionsCacheStats: " + world.getAllFactionsCacheStats()+"\n"; //str+= "AttackWarningCount: " + intToStr(world.getUnitUpdater()->getAttackWarningCount()) + "\n"; diff --git a/source/shared_lib/include/graphics/model.h b/source/shared_lib/include/graphics/model.h index d4ed8047..909a492c 100644 --- a/source/shared_lib/include/graphics/model.h +++ b/source/shared_lib/include/graphics/model.h @@ -286,6 +286,8 @@ public: unsigned char * getUniqueColorID() { return &uniqueColorID[0]; } bool get_next_assign_color(unsigned char *assign_to); + static int getUsedColorIDListSize() { return (int)usedColorIDList.size(); } + private: unsigned char uniqueColorID[COLOR_COMPONENTS]; From b868a8468b097c7ac506de111a211a1baa69a563 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sat, 30 Nov 2013 20:33:25 -0800 Subject: [PATCH 07/11] - bugfixes to winner / loser logic to keep calculating stats and publish to masterserver after we determine a winner or loser as the game may not yet be fully over and we want accurate game stats on the masterserver. --- source/glest_game/game/game.cpp | 303 ++++++++++++++++++-------------- source/glest_game/game/game.h | 3 + 2 files changed, 171 insertions(+), 135 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 7b5e23f8..8c1018b2 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -5600,7 +5600,10 @@ void Game::render2d() { // ==================== misc ==================== void Game::checkWinner() { - if(gameOver == false) { + // lookup int is team #, value is players alive on team + std::map teamsAlive = getTeamsAlive(); + + if(gameOver == false || teamsAlive.size() > 1) { if(gameSettings.getDefaultVictoryConditions()) { checkWinnerStandard(); } @@ -5675,55 +5678,62 @@ void Game::setEndGameTeamWinnersAndLosers() { } } -void Game::checkWinnerStandard() { - if(world.getFactionCount() <= 0) { - return; +std::map Game::getTeamsAlive() { + std::map teamsAlive; + for (int factionIndex = 0; factionIndex < world.getFactionCount(); ++factionIndex) { + if (factionIndex != world.getThisFactionIndex()) { + //if(hasBuilding(world.getFaction(i))) { + if (factionLostGame(world.getFaction(factionIndex)) == false) { + teamsAlive[world.getFaction(factionIndex)->getTeam()] = + teamsAlive[world.getFaction(factionIndex)->getTeam()] + 1; + } + } } - if(this->masterserverMode == true || world.getThisFaction()->getPersonalityType() == fpt_Observer) { - // lookup int is team #, value is players alive on team - std::map teamsAlive; - for(int i = 0; i < world.getFactionCount(); ++i) { - if(i != world.getThisFactionIndex()) { - //if(hasBuilding(world.getFaction(i))) { - if(factionLostGame(world.getFaction(i)) == false) { - teamsAlive[world.getFaction(i)->getTeam()] = teamsAlive[world.getFaction(i)->getTeam()] + 1; + // did some team win + return teamsAlive; +} + +void Game::checkWinnerStandardHeadlessOrObserver() { + // lookup int is team #, value is players alive on team + std::map teamsAlive = getTeamsAlive(); + + // did some team win + if (teamsAlive.size() <= 1) { + if (this->masterserverMode == true) { + printf("Game finished...\n"); + } + for (int factionIndex = 0; factionIndex < world.getFactionCount(); ++factionIndex) { + Faction* faction = world.getFaction(factionIndex); + if (factionIndex != world.getThisFactionIndex() && + teamsAlive.find(faction->getTeam()) != teamsAlive.end()) { + world.getStats()->setVictorious(factionIndex); + if (this->masterserverMode == true) { + printf("Player: %s is on the winning team #: %d\n", + this->gameSettings.getNetworkPlayerName(factionIndex).c_str(), + faction->getTeam()); } } } + bool wasGameOverAlready = gameOver; + gameOver = true; - // did some team win - if(teamsAlive.size() <= 1) { - if(this->masterserverMode == true) { - printf("Game finished...\n"); - } - for(int i=0; i< world.getFactionCount(); ++i) { - Faction *faction = world.getFaction(i); - - if(i != world.getThisFactionIndex() && teamsAlive.find(faction->getTeam()) != teamsAlive.end()) { - world.getStats()->setVictorious(i); - if(this->masterserverMode == true) { - printf("Player: %s is on the winning team #: %d\n",this->gameSettings.getNetworkPlayerName(i).c_str(),faction->getTeam()); - } - } - } - gameOver= true; - if( this->gameSettings.isNetworkGame() == false || - this->gameSettings.getEnableObserverModeAtEndGame() == true) { + // Only need to process this once + if(wasGameOverAlready == false) { + if (this->gameSettings.isNetworkGame() == false || + this->gameSettings.getEnableObserverModeAtEndGame() + == true) { // Let the happy winner view everything left in the world - // This caused too much LAG for network games - if(this->gameSettings.isNetworkGame() == false) { + if (this->gameSettings.isNetworkGame() == false) { Renderer::getInstance().setPhotoMode(true); gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); } // END } - scriptManager.onGameOver(true); - - if(world.getFactionCount() == 1 && world.getFaction(0)->getPersonalityType() == fpt_Observer) { + if (world.getFactionCount() == 1 && + world.getFaction(0)->getPersonalityType() == fpt_Observer) { //printf("!!!!!!!!!!!!!!!!!!!!"); - //gameCamera.setMoveY(100.0); gameCamera.zoom(-300); //gameCamera.update(); @@ -5733,23 +5743,121 @@ void Game::checkWinnerStandard() { } } } - else { - //lose - bool lose= false; - //if(hasBuilding(world.getThisFaction()) == false) { - if(factionLostGame(world.getThisFaction()) == true) { - lose= true; - for(int i=0; igetPersonalityType() != fpt_Observer) { - if(world.getFaction(i)->isAlly(world.getThisFaction()) == false) { - world.getStats()->setVictorious(i); +} + +void Game::checkWinnerStandardPlayer() { + //lose + bool lose = false; + //if(hasBuilding(world.getThisFaction()) == false) { + if (factionLostGame(world.getThisFaction()) == true) { + lose = true; + for (int factionIndex = 0; factionIndex < world.getFactionCount(); ++factionIndex) { + if (world.getFaction(factionIndex)->getPersonalityType() != fpt_Observer) { + if (world.getFaction(factionIndex)->isAlly(world.getThisFaction()) == false) { + world.getStats()->setVictorious(factionIndex); + } + } + } + bool wasGameOverAlready = gameOver; + gameOver = true; + + // Only need to process losing once + if(wasGameOverAlready == false) { + if (this->gameSettings.isNetworkGame() == false || + this->gameSettings.getEnableObserverModeAtEndGame() + == true) { + // Let the poor user watch everything unfold + // This caused too much LAG for network games + if (this->gameSettings.isNetworkGame() == false) { + Renderer::getInstance().setPhotoMode(true); + gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); + } + // END + // but don't let him cheat via teamchat + chatManager.setDisableTeamMode(true); + } + scriptManager.onGameOver(!lose); + showLoseMessageBox(); + } + } + //win + if (lose == false) { + bool win = true; + for (int factionIndex = 0; factionIndex < world.getFactionCount(); ++factionIndex) { + if (factionIndex != world.getThisFactionIndex()) { + if (world.getFaction(factionIndex)->getPersonalityType() != fpt_Observer) { + //if(hasBuilding(world.getFaction(i)) && + if (factionLostGame(world.getFaction(factionIndex)) == false && + world.getFaction(factionIndex)->isAlly(world.getThisFaction()) == false) { + win = false; } } } - gameOver= true; + } + //if win + if (win) { + for (int factionIndex = 0; factionIndex < world.getFactionCount(); ++factionIndex) { + if (world.getFaction(factionIndex)->getPersonalityType() != fpt_Observer) { + if (world.getFaction(factionIndex)->isAlly(world.getThisFaction())) { + world.getStats()->setVictorious(factionIndex); + } + } + } + + bool wasGameOverAlready = gameOver; + gameOver = true; + + // Only need to process winning once + if(wasGameOverAlready == false) { + if (this->gameSettings.isNetworkGame() == false || + this->gameSettings.getEnableObserverModeAtEndGame() == true) { + // Let the happy winner view everything left in the world + //world.setFogOfWar(false); + // This caused too much LAG for network games + if (this->gameSettings.isNetworkGame() == false) { + Renderer::getInstance().setPhotoMode(true); + gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); + } + // END + } + scriptManager.onGameOver(win); + showWinMessageBox(); + } + } + } +} + +void Game::checkWinnerStandard() { + if(world.getFactionCount() <= 0) { + return; + } + if(this->masterserverMode == true || + world.getThisFaction()->getPersonalityType() == fpt_Observer) { + checkWinnerStandardHeadlessOrObserver(); + } + else { + checkWinnerStandardPlayer(); + } +} + +void Game::checkWinnerScripted() { + if(scriptManager.getIsGameOver()) { + bool wasGameOverAlready = gameOver; + gameOver= true; + + + for(int i= 0; igetWinner()) { + world.getStats()->setVictorious(i); + } + } + + // Only need to process winning once + if(wasGameOverAlready == false) { if( this->gameSettings.isNetworkGame() == false || this->gameSettings.getEnableObserverModeAtEndGame() == true) { - // Let the poor user watch everything unfold + // Let the happy winner view everything left in the world + //world.setFogOfWar(false); // This caused too much LAG for network games if(this->gameSettings.isNetworkGame() == false) { @@ -5757,95 +5865,20 @@ void Game::checkWinnerStandard() { gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); } // END - - // but don't let him cheat via teamchat - chatManager.setDisableTeamMode(true); } - scriptManager.onGameOver(!lose); - - showLoseMessageBox(); - } - - //win - if(lose == false) { - bool win= true; - for(int i = 0; i < world.getFactionCount(); ++i) { - if(i != world.getThisFactionIndex()) { - if(world.getFaction(i)->getPersonalityType() != fpt_Observer) { - //if(hasBuilding(world.getFaction(i)) && - if(factionLostGame(world.getFaction(i)) == false && - world.getFaction(i)->isAlly(world.getThisFaction()) == false) { - win= false; - } - } - } - } - - //if win - if(win) { - for(int i=0; i< world.getFactionCount(); ++i) { - if(world.getFaction(i)->getPersonalityType() != fpt_Observer) { - if(world.getFaction(i)->isAlly(world.getThisFaction())) { - world.getStats()->setVictorious(i); - } - } - } - gameOver= true; - if( this->gameSettings.isNetworkGame() == false || - this->gameSettings.getEnableObserverModeAtEndGame() == true) { - // Let the happy winner view everything left in the world - //world.setFogOfWar(false); - - // This caused too much LAG for network games - if(this->gameSettings.isNetworkGame() == false) { - Renderer::getInstance().setPhotoMode(true); - gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); - } - // END - } - - scriptManager.onGameOver(win); - + if(this->masterserverMode == true || world.getThisFaction()->getPersonalityType() == fpt_Observer) { showWinMessageBox(); } - } - } -} + else { + scriptManager.onGameOver(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()); -void Game::checkWinnerScripted() { - if(scriptManager.getIsGameOver()) { - gameOver= true; - for(int i= 0; igetWinner()) { - world.getStats()->setVictorious(i); - } - } - - if( this->gameSettings.isNetworkGame() == false || - this->gameSettings.getEnableObserverModeAtEndGame() == true) { - // Let the happy winner view everything left in the world - //world.setFogOfWar(false); - - // This caused too much LAG for network games - if(this->gameSettings.isNetworkGame() == false) { - Renderer::getInstance().setPhotoMode(true); - gameCamera.setMaxHeight(PHOTO_MODE_MAXHEIGHT); - } - // END - } - - if(this->masterserverMode == true || world.getThisFaction()->getPersonalityType() == fpt_Observer) { - showWinMessageBox(); - } - else { - scriptManager.onGameOver(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()); - - if(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()){ - showWinMessageBox(); - } - else{ - showLoseMessageBox(); + if(scriptManager.getPlayerModifiers(world.getThisFactionIndex())->getWinner()){ + showWinMessageBox(); + } + else { + showLoseMessageBox(); + } } } } @@ -5857,10 +5890,10 @@ bool Game::factionLostGame(int factionIndex) { bool Game::factionLostGame(const Faction *faction) { if(faction != NULL) { - for(int i=0; igetUnitCount(); ++i) { - const UnitType *ut = faction->getUnit(i)->getType(); + for(int factionIndex=0; factionIndexgetUnitCount(); ++factionIndex) { + const UnitType *ut = faction->getUnit(factionIndex)->getType(); if(ut->getCountInVictoryConditions() == ucvcNotSet) { - if(faction->getUnit(i)->getType()->hasSkillClass(scBeBuilt)) { + if(faction->getUnit(factionIndex)->getType()->hasSkillClass(scBeBuilt)) { return false; } } diff --git a/source/glest_game/game/game.h b/source/glest_game/game/game.h index dc669596..d9903531 100644 --- a/source/glest_game/game/game.h +++ b/source/glest_game/game/game.h @@ -395,6 +395,9 @@ private: int startIndex, int endIndex, bool onlyNetworkUnassigned); void processNetworkSynchChecksIfRequired(); Stats getEndGameStats(); + void checkWinnerStandardHeadlessOrObserver(); + void checkWinnerStandardPlayer(); + std::map getTeamsAlive(); }; }}//end namespace From c97825d898f5d6de6179df4d1e81ed14b40b6014 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 2 Dec 2013 09:45:46 -0800 Subject: [PATCH 08/11] - updated windows x64 build to use git revision stamp --- mk/windoze/build-mg-2012.bat | 45 +++++++++++++---------- mk/windoze/vc2012/glest_game.vcxproj | 2 +- mk/windoze/vc2012/megaglest_tests.vcxproj | 1 + 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/mk/windoze/build-mg-2012.bat b/mk/windoze/build-mg-2012.bat index 91e2f7a4..415bf612 100644 --- a/mk/windoze/build-mg-2012.bat +++ b/mk/windoze/build-mg-2012.bat @@ -50,7 +50,7 @@ ECHO Setting up Visual Studio 2012 environment vars... REM Ensure ultifds HP doesn't mess the build up SET Platform= if "%DevEnvDir%." == "." goto SETVCVARS -GOTO SVNSECTION +GOTO GITSECTION :SETVCVARS @@ -61,45 +61,50 @@ IF EXIST "\Program Files (x86)\Microsoft Visual Studio 11.0\" GOTO VC_64_12 rem IF EXIST "%VS100COMNTOOLS%..\..\" GOTO VC_Common rem IF EXIST "\Program Files\Microsoft Visual Studio 10.0\" GOTO VC_32 rem IF EXIST "\Program Files (x86)\Microsoft Visual Studio 10.0\" GOTO VC_64 -goto SVNSECTION +goto GITSECTION :VC_Common_12 call "%VS110COMNTOOLS%..\..\vc\vcvarsall.bat" %VCVARS_PLATFORM% -goto SVNSECTION +goto GITSECTION :VC_32_12 ECHO 32 bit Windows detected... call "\Program Files\Microsoft Visual Studio 11.0\vc\vcvarsall.bat" %VCVARS_PLATFORM% -goto SVNSECTION +goto GITSECTION :VC_64_12 ECHO 64 bit Windows detected... call "\Program Files (x86)\Microsoft Visual Studio 11.0\vc\vcvarsall.bat" %VCVARS_PLATFORM% -goto SVNSECTION +goto GITSECTION :VC_Common rem call "%VS100COMNTOOLS%..\..\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION :VC_32 ECHO 32 bit Windows detected... rem call "\Program Files\Microsoft Visual Studio 10.0\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION :VC_64 ECHO 64 bit Windows detected... rem call "\Program Files (x86)\Microsoft Visual Studio 10.0\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION -:SVNSECTION -rem Update from SVN to latest rev +:GITSECTION +rem Update from GIT to latest rev ECHO -------------------------------- -Echo Updating Code from SVN to latest Revision... -svn update ..\..\ +Echo Updating Code from GIT to latest Revision... +cd ..\..\ +git pull -set SVNVERSION=. -for /f "delims=" %%a in ('svnversion ..\..\ -n') do @set SVNVERSION=%%a -ECHO Will build using SVN Revision: [%SVNVERSION%] +set GITVERSION_SHA1=. +set GITVERSION_REV=. +set GET_GIT_SHA1="git log -1 --format=%%h" +for /f "delims=" %%a in ('%GET_GIT_SHA1%') do @set GITVERSION_SHA1=%%a +for /f "delims=" %%a in ('git rev-list HEAD --count') do @set GITVERSION_REV=%%a +ECHO Will build using GIT Revision: [%GITVERSION_REV%.%GITVERSION_SHA1%] +cd mk\windoze rem pause ECHO -------------------------------- @@ -127,12 +132,12 @@ rem set CL=/D_USING_V110_SDK71_ %CL% rem set PlatformToolset=v110_xp rem set PlatformToolset=V110 -del ..\..\source\glest_game\facilities\svnversion.h +del ..\..\source\glest_game\facilities\gitversion.h -if not "%SVNVERSION%" == "." set CL=/DSVNVERSIONHEADER -if not "%SVNVERSION%" == "." echo building with CL [%CL%] -if not "%SVNVERSION%" == "." echo #define SVNVERSION "%SVNVERSION%" > ..\..\source\glest_game\facilities\svnversion.h -if not "%SVNVERSION%" == "." copy /b ..\..\source\glest_game\facilities\game_util.cpp +,, +if not "%GITVERSION_SHA1%" == "." set CL=/DGITVERSIONHEADER +if not "%GITVERSION_SHA1%" == "." echo building with CL [%CL%] +if not "%GITVERSION_SHA1%" == "." echo #define GITVERSION "%GITVERSION_REV%.%GITVERSION_SHA1%" > ..\..\source\glest_game\facilities\gitversion.h +if not "%GITVERSION_SHA1%" == "." copy /b ..\..\source\glest_game\facilities\game_util.cpp +,, rem set VisualStudioVersion=11.0 set msBuildMaxCPU= diff --git a/mk/windoze/vc2012/glest_game.vcxproj b/mk/windoze/vc2012/glest_game.vcxproj index fe44bebf..86fc6dcd 100644 --- a/mk/windoze/vc2012/glest_game.vcxproj +++ b/mk/windoze/vc2012/glest_game.vcxproj @@ -272,7 +272,7 @@ true - dsound.lib;dxguid.lib;glew32s.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;opengl32.lib;glu32.lib;wsock32.lib;libglest.lib;mmc.lib;lua.lib;xerces-c_static_3.lib;Dbghelp.lib;libpng15.lib;jpeg.lib;zlibstat.lib;sdl.lib;sdlmain.lib;winmm.lib;openal64.lib;iphlpapi.lib;libstreflop.lib;libcurl.lib;ws2_32.lib;libircclient.lib;freetype244MT.lib;ftgl_static.lib;%(AdditionalDependencies) + dsound.lib;dxguid.lib;glew32s.lib;libogg_static.lib;libvorbis_static.lib;libvorbisfile_static.lib;opengl32.lib;glu32.lib;wsock32.lib;libglest.lib;mmc.lib;lua.lib;xerces-c_static_3.lib;Dbghelp.lib;libpng15.lib;jpeg.lib;zlibstat.lib;sdl.lib;sdlmain.lib;winmm.lib;openal64.lib;iphlpapi.lib;libcurl.lib;ws2_32.lib;libircclient.lib;freetype244MT.lib;ftgl_static.lib;%(AdditionalDependencies) ../../../source/windows_deps_2012/lib;../../../build/$(Configuration)/libglest;$(DXSDK_DIR)/lib/x64;../../../source/windows_deps_2012/Microsoft DirectX SDK %28November 2007%29/Lib/x64;%(AdditionalLibraryDirectories) ;%(IgnoreSpecificDefaultLibraries) true diff --git a/mk/windoze/vc2012/megaglest_tests.vcxproj b/mk/windoze/vc2012/megaglest_tests.vcxproj index 509c0683..56f02c9e 100644 --- a/mk/windoze/vc2012/megaglest_tests.vcxproj +++ b/mk/windoze/vc2012/megaglest_tests.vcxproj @@ -194,6 +194,7 @@ + From 7d4bbeadfd53d2e5ea1e73fa220be7bb86f915c1 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 2 Dec 2013 09:48:23 -0800 Subject: [PATCH 09/11] - added windows deps to ignore list --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 40024fa2..bb0ecf34 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,6 @@ data/glest_game/lua/ # +/source/windows_deps_2012 +/source/windows_deps_2010 +/source/windows_deps_2010_old From 1e50f1cb93344a29434ee49b95bea246e0bea452 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 2 Dec 2013 12:59:36 -0800 Subject: [PATCH 10/11] - updated vc++ 2010 build file to use git --- mk/windoze/build-mg-2010.bat | 39 ++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mk/windoze/build-mg-2010.bat b/mk/windoze/build-mg-2010.bat index ec930069..b0b58103 100644 --- a/mk/windoze/build-mg-2010.bat +++ b/mk/windoze/build-mg-2010.bat @@ -43,39 +43,44 @@ ECHO Setting up Visual Studio 2010 environment vars... REM Ensure ultifds HP doesn't mess the build up SET Platform= if "%DevEnvDir%." == "." goto SETVCVARS -GOTO SVNSECTION +GOTO GITSECTION :SETVCVARS IF EXIST "%VS100COMNTOOLS%..\..\" GOTO VC_Common IF EXIST "\Program Files\Microsoft Visual Studio 10.0\" GOTO VC_32 IF EXIST "\Program Files (x86)\Microsoft Visual Studio 10.0\" GOTO VC_64 -goto SVNSECTION +goto GITSECTION :VC_Common call "%VS100COMNTOOLS%..\..\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION :VC_32 ECHO 32 bit Windows detected... call "\Program Files\Microsoft Visual Studio 10.0\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION :VC_64 ECHO 64 bit Windows detected... call "\Program Files (x86)\Microsoft Visual Studio 10.0\vc\vcvarsall.bat" -goto SVNSECTION +goto GITSECTION -:SVNSECTION -rem Update from SVN to latest rev +:GITSECTION +rem Update from GIT to latest rev ECHO -------------------------------- -Echo Updating Code from SVN to latest Revision... -svn update ..\..\ +Echo Updating Code from GIT to latest Revision... +cd ..\..\ +git pull -set SVNVERSION=. -for /f "delims=" %%a in ('svnversion ..\..\ -n') do @set SVNVERSION=%%a -ECHO Will build using SVN Revision: [%SVNVERSION%] +set GITVERSION_SHA1=. +set GITVERSION_REV=. +set GET_GIT_SHA1="git log -1 --format=%%h" +for /f "delims=" %%a in ('%GET_GIT_SHA1%') do @set GITVERSION_SHA1=%%a +for /f "delims=" %%a in ('git rev-list HEAD --count') do @set GITVERSION_REV=%%a +ECHO Will build using GIT Revision: [%GITVERSION_REV%.%GITVERSION_SHA1%] +cd mk\windoze rem pause ECHO -------------------------------- @@ -88,12 +93,12 @@ ECHO -------------------------------- Echo Building Mega-Glest using Visual Studio 2010... set CL= -del ..\..\source\glest_game\facilities\svnversion.h +del ..\..\source\glest_game\facilities\gitversion.h -if not "%SVNVERSION%" == "." set CL=/DSVNVERSIONHEADER -if not "%SVNVERSION%" == "." echo building with CL [%CL%] -if not "%SVNVERSION%" == "." echo #define SVNVERSION "%SVNVERSION%" > ..\..\source\glest_game\facilities\svnversion.h -if not "%SVNVERSION%" == "." copy /b ..\..\source\glest_game\facilities\game_util.cpp +,, +if not "%GITVERSION_SHA1%" == "." set CL=/DGITVERSIONHEADER +if not "%GITVERSION_SHA1%" == "." echo building with CL [%CL%] +if not "%GITVERSION_SHA1%" == "." echo #define GITVERSION "%GITVERSION_REV%.%GITVERSION_SHA1%" > ..\..\source\glest_game\facilities\gitversion.h +if not "%GITVERSION_SHA1%" == "." copy /b ..\..\source\glest_game\facilities\game_util.cpp +,, set msBuildMaxCPU= SET BuildInParallel=false From f9e217df947b81050a579be6b8712fa026bfae80 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Wed, 4 Dec 2013 13:34:00 -0800 Subject: [PATCH 11/11] - bugfix so Mac builds --- source/shared_lib/sources/platform/sdl/gl_wrap.cpp | 9 +++++++++ source/shared_lib/sources/platform/unix/gl_wrap.cpp | 8 -------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index 3c95041e..6a927b44 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -33,6 +33,15 @@ using namespace Shared::PlatformCommon; namespace Shared{ namespace Platform{ +// Example values: +// DEFAULT_CHARSET (English) = 1 +// GB2312_CHARSET (Chinese) = 134 +#ifdef WIN32 +DWORD PlatformContextGl::charSet = DEFAULT_CHARSET; +#else +int PlatformContextGl::charSet = 1; +#endif + // ====================================== // class PlatformContextGl // ====================================== diff --git a/source/shared_lib/sources/platform/unix/gl_wrap.cpp b/source/shared_lib/sources/platform/unix/gl_wrap.cpp index 8d3e8e59..07f6c74f 100644 --- a/source/shared_lib/sources/platform/unix/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/unix/gl_wrap.cpp @@ -28,14 +28,6 @@ using namespace Shared::Util; namespace Shared { namespace Platform { -// Example values: -// DEFAULT_CHARSET (English) = 1 -// GB2312_CHARSET (Chinese) = 134 -#ifdef WIN32 -DWORD PlatformContextGl::charSet = DEFAULT_CHARSET; -#else -int PlatformContextGl::charSet = 1; -#endif // ====================================== // Global Fcs