mirror of
https://github.com/glest/glest-source.git
synced 2025-08-09 09:56:30 +02:00
merged updates
This commit is contained in:
@@ -9,6 +9,7 @@ OUTFILE=./cppcheck.log
|
|||||||
CPUS=`lscpu -p | grep -cv '^#'`
|
CPUS=`lscpu -p | grep -cv '^#'`
|
||||||
if [ "$CPUS" = '' ]; then CPUS=1; fi
|
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
|
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"
|
echo "Results from cppcheck were written to $OUTFILE"
|
||||||
|
@@ -36,7 +36,7 @@ const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
|||||||
const string GIT_RawRev = string(GITVERSION);
|
const string GIT_RawRev = string(GITVERSION);
|
||||||
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
const string GIT_Rev = string("Rev: ") + string(GITVERSION);
|
||||||
#else
|
#else
|
||||||
const string GIT_RawRev = "$4790$";
|
const string GIT_RawRev = "$4446.1a8673f$";
|
||||||
const string GIT_Rev = "$Rev$";
|
const string GIT_Rev = "$Rev$";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -430,6 +430,8 @@ Game::~Game() {
|
|||||||
|
|
||||||
world.end(); //must die before selection because of referencers
|
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());
|
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;
|
delete videoPlayer;
|
||||||
@@ -1001,6 +1003,8 @@ void Game::load(int loadTypes) {
|
|||||||
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
SoundRenderer &soundRenderer= SoundRenderer::getInstance();
|
||||||
soundRenderer.stopAllSounds(fadeMusicMilliseconds);
|
soundRenderer.stopAllSounds(fadeMusicMilliseconds);
|
||||||
|
|
||||||
|
BaseColorPickEntity::resetUniqueColors();
|
||||||
|
|
||||||
Config &config = Config::getInstance();
|
Config &config = Config::getInstance();
|
||||||
Logger &logger= Logger::getInstance();
|
Logger &logger= Logger::getInstance();
|
||||||
|
|
||||||
@@ -2608,6 +2612,8 @@ void Game::update() {
|
|||||||
aiInterfaces.clear();
|
aiInterfaces.clear();
|
||||||
gui.end(); //selection must be cleared before deleting units
|
gui.end(); //selection must be cleared before deleting units
|
||||||
world.end(); //must die before selection because of referencers
|
world.end(); //must die before selection because of referencers
|
||||||
|
|
||||||
|
BaseColorPickEntity::resetUniqueColors();
|
||||||
// MUST DO THIS LAST!!!! Because objects above have pointers to things like
|
// 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
|
// unit particles and fade them out etc and this end method deletes the original
|
||||||
// object pointers.
|
// object pointers.
|
||||||
@@ -2632,6 +2638,7 @@ void Game::update() {
|
|||||||
soundRenderer.stopAllSounds(fadeMusicMilliseconds);
|
soundRenderer.stopAllSounds(fadeMusicMilliseconds);
|
||||||
|
|
||||||
world.endScenario();
|
world.endScenario();
|
||||||
|
BaseColorPickEntity::resetUniqueColors();
|
||||||
|
|
||||||
Renderer &renderer= Renderer::getInstance();
|
Renderer &renderer= Renderer::getInstance();
|
||||||
renderer.endScenario();
|
renderer.endScenario();
|
||||||
|
@@ -263,7 +263,8 @@ public:
|
|||||||
BaseColorPickEntity();
|
BaseColorPickEntity();
|
||||||
virtual ~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 init(int bufferSize);
|
||||||
static void beginPicking();
|
static void beginPicking();
|
||||||
static void endPicking();
|
static void endPicking();
|
||||||
@@ -275,16 +276,39 @@ public:
|
|||||||
string getColorDescription() const;
|
string getColorDescription() const;
|
||||||
virtual string getUniquePickName() const = 0;
|
virtual string getUniquePickName() const = 0;
|
||||||
|
|
||||||
private:
|
static void resetUniqueColors();
|
||||||
unsigned char uniqueColorID[COLOR_COMPONENTS];
|
|
||||||
|
|
||||||
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 const int k, p;
|
||||||
static Mutex mutexNextColorID;
|
static Mutex mutexNextColorID;
|
||||||
|
|
||||||
|
static bool using_loop_method;
|
||||||
|
|
||||||
|
static bool trackColorUse;
|
||||||
|
static map<string,bool> usedColorIDList;
|
||||||
|
|
||||||
|
static vector<vector<unsigned char> > nextColorIDReuseList;
|
||||||
|
|
||||||
static auto_ptr<PixelBufferWrapper> pbo;
|
static auto_ptr<PixelBufferWrapper> pbo;
|
||||||
|
|
||||||
void assign_color();
|
void assign_color();
|
||||||
|
|
||||||
|
void assign_color_using_prime(unsigned char *assign_to);
|
||||||
|
void assign_color_using_loop(unsigned char *assign_to);
|
||||||
};
|
};
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
@@ -1828,33 +1828,169 @@ PixelBufferWrapper::~PixelBufferWrapper() {
|
|||||||
|
|
||||||
const int BaseColorPickEntity::p = 64007;
|
const int BaseColorPickEntity::p = 64007;
|
||||||
const int BaseColorPickEntity::k = 43067;
|
const int BaseColorPickEntity::k = 43067;
|
||||||
int BaseColorPickEntity::nextColorID = BaseColorPickEntity::k;
|
int BaseColorPickEntity::nextColorRGB = BaseColorPickEntity::k;
|
||||||
Mutex BaseColorPickEntity::mutexNextColorID;
|
Mutex BaseColorPickEntity::mutexNextColorID;
|
||||||
|
unsigned char BaseColorPickEntity::nextColorID[COLOR_COMPONENTS] = { 1, 1, 1 };
|
||||||
auto_ptr<PixelBufferWrapper> BaseColorPickEntity::pbo;
|
auto_ptr<PixelBufferWrapper> BaseColorPickEntity::pbo;
|
||||||
|
|
||||||
|
map<string,bool> BaseColorPickEntity::usedColorIDList;
|
||||||
|
bool BaseColorPickEntity::trackColorUse = true;
|
||||||
|
|
||||||
|
vector<vector<unsigned char> > BaseColorPickEntity::nextColorIDReuseList;
|
||||||
|
|
||||||
|
bool BaseColorPickEntity::using_loop_method = true;
|
||||||
|
|
||||||
BaseColorPickEntity::BaseColorPickEntity() {
|
BaseColorPickEntity::BaseColorPickEntity() {
|
||||||
assign_color();
|
assign_color();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseColorPickEntity::assign_color() {
|
bool BaseColorPickEntity::get_next_assign_color(unsigned char *assign_to) {
|
||||||
|
|
||||||
MutexSafeWrapper safeMutex(&mutexNextColorID);
|
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)
|
// nextColorID is a 16-bit (hi)colour (for players with 16-bit display depths)
|
||||||
// we expand it to true-color for use with OpenGL
|
// 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 int
|
||||||
r = (nextColorID >> 11) & ((1<<5)-1),
|
r = (nextColorRGB >> 11) & ((1<<5)-1),
|
||||||
g = (nextColorID >> 5) & ((1<<6)-1),
|
g = (nextColorRGB >> 5) & ((1<<6)-1),
|
||||||
b = nextColorID & ((1<<5)-1);
|
b = nextColorRGB & ((1<<5)-1);
|
||||||
|
|
||||||
uniqueColorID[0] = r << 3;
|
assign_to[0] = r << 3;
|
||||||
uniqueColorID[1] = g << 2;
|
assign_to[1] = g << 2;
|
||||||
uniqueColorID[2] = b << 3;
|
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<unsigned char> 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) {
|
void BaseColorPickEntity::init(int bufferSize) {
|
||||||
if(BaseColorPickEntity::pbo.get() == NULL) {
|
if(BaseColorPickEntity::pbo.get() == NULL) {
|
||||||
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,bufferSize));
|
BaseColorPickEntity::pbo.reset(new PixelBufferWrapper(2,bufferSize));
|
||||||
|
Reference in New Issue
Block a user