Implemented the new g3d spec

This commit is contained in:
mathusummut
2018-06-28 21:36:10 +02:00
parent 90556c870e
commit b1760253fd
24 changed files with 225 additions and 338 deletions

View File

@@ -12,10 +12,14 @@
#ifndef _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_
#define _SHARED_GRAPHICS_GL_MODELRENDERERGL_H_
#include <array>
#include "model_renderer.h"
#include "model.h"
#include "opengl.h"
#include "leak_dumper.h"
#include "texture_gl.h"
using ::Shared::Graphics::Gl::Texture2DGl;
namespace Shared {
namespace Graphics {
@@ -52,6 +56,23 @@ namespace Shared {
void renderMeshNormals(Mesh *mesh);
};
class MeshCallbackTeamColor : public MeshCallback {
private:
const Texture *teamTexture;
public:
MeshCallbackTeamColor() : MeshCallback() {
teamTexture = NULL;
}
void setTeamTexture(const Texture *teamTexture) {
this->teamTexture = teamTexture;
}
virtual void execute(const Mesh *mesh);
static bool noTeamColors;
};
}
}
}//end namespace

View File

@@ -46,7 +46,7 @@ namespace Shared {
class Mesh {
private:
//mesh data
Texture2D *textures[meshTextureCount];
Texture2D * textures[meshTextureCount];
bool texturesOwned[meshTextureCount];
string texturePaths[meshTextureCount];
@@ -75,6 +75,7 @@ namespace Shared {
bool customColor;
bool noSelect;
bool glow;
uint8 factionColorOpacity;
uint32 textureFlags;
@@ -175,6 +176,9 @@ namespace Shared {
bool getCustomTexture() const {
return customColor;
}
uint8 getFactionColorOpacity() const {
return factionColorOpacity;
}
bool getNoSelect() const {
return noSelect;
}
@@ -235,7 +239,7 @@ namespace Shared {
class Model {
private:
TextureManager *textureManager;
TextureManager * textureManager;
private:
uint8 fileVersion;

View File

@@ -72,7 +72,6 @@ namespace Shared {
virtual void render(Model *model, int renderMode = rmNormal, float alpha = 1.0f) = 0;
virtual void renderNormalsOnly(Model *model) = 0;
};
}
}//end namespace

View File

@@ -115,7 +115,7 @@ namespace Shared {
float getFloat(const string &key, const char *defaultValueIfNotFound = NULL) const;
float getFloat(const string &key, float min, float max, const char *defaultValueIfNotFound = NULL) const;
const string getString(const string &key, const char *defaultValueIfNotFound = NULL) const;
const string getString(const string &key, const char *defaultValueIfNotFound = "") const;
int getInt(const char *key, const char *defaultValueIfNotFound = NULL) const;
bool getBool(const char *key, const char *defaultValueIfNotFound = NULL) const;

View File

@@ -107,14 +107,14 @@ const char* ftpReadDir(void* dirHandle) {
else
strcat(p->path, "*");
p->findHandle = FindFirstFile(p->path, &findData);
p->findHandle = FindFirstFileA(p->path, &findData);
if (p->findHandle != INVALID_HANDLE_VALUE) {
strcpy(p->path, findData.cFileName);
return p->path;
}
return NULL;
} else {
if (FindNextFile(p->findHandle, &findData)) {
if (FindNextFileA(p->findHandle, &findData)) {
strcpy(p->path, findData.cFileName);
return p->path;
}
@@ -186,11 +186,11 @@ int ftpStat(const char* path, ftpPathInfo_S *info) {
int ftpMakeDir(const char* path) {
return !CreateDirectory(path, NULL);
return !CreateDirectoryA(path, NULL);
}
int ftpRemoveDir(const char* path) {
return !RemoveDirectory(path);
return !RemoveDirectoryA(path);
}

View File

@@ -239,7 +239,7 @@ namespace Shared {
ftFont->Render(str, len);
//assertGl();
GLenum error = glGetError();
/*GLenum error =*/ glGetError();
/*if (error != GL_NO_ERROR) {
printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n", __FILE__, __FUNCTION__, __LINE__, error, gluErrorString(error), str);
fflush(stdout);
@@ -307,7 +307,7 @@ namespace Shared {
//if(result == -1000) {
FTBBox box = ftFont->BBox(TextFTGL::langHeightText.c_str());
GLenum error = glGetError();
/*GLenum error =*/ glGetError();
/*if (error != GL_NO_ERROR) {
printf("\n[%s::%s] Line %d Error = %d [%s] for text [%s]\n", __FILE__, __FUNCTION__, __LINE__, error, gluErrorString(error), str);
fflush(stdout);

View File

@@ -22,6 +22,68 @@ using namespace Shared::Platform;
namespace Shared {
namespace Graphics {
namespace Gl {
bool MeshCallbackTeamColor::noTeamColors = false;
void MeshCallbackTeamColor::execute(const Mesh *mesh) {
//team color
uint8 opacity = mesh->getFactionColorOpacity();
if (!mesh->getCustomTexture() || opacity == 0 || teamTexture == NULL || MeshCallbackTeamColor::noTeamColors) {
glActiveTexture(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
} else {
//texture 0
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
//set color to interpolation
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_RGB, GL_SRC_ALPHA);
//set alpha to 1
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_REPLACE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
//texture 1
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glMultiTexCoord2f(GL_TEXTURE1, 0.f, 0.f);
GLuint handle = static_cast<const Texture2DGl*>(teamTexture)->getHandle();
glBindTexture(GL_TEXTURE_2D, handle);
float color[4];
color[0] = 1.0f; // Red
color[1] = 1.0f; // Green
color[2] = 1.0f; // Blue
color[3] = opacity * 0.00392156862f; // Alpha
glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, color);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
//set alpha to 1
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_INTERPOLATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_ALPHA, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_ALPHA, GL_CONSTANT);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_ALPHA, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_ALPHA, GL_SRC_ALPHA);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND2_ALPHA, GL_SRC_ALPHA);
glActiveTexture(GL_TEXTURE0);
}
}
// =====================================================
// class MyClass

View File

@@ -227,6 +227,7 @@ namespace Shared {
customColor = false;
noSelect = false;
glow = false;
factionColorOpacity = 255;
textureFlags = 0;
@@ -335,28 +336,28 @@ namespace Shared {
// Generate And Bind The Vertex Buffer
glGenBuffersARB(1, (GLuint*) &m_nVBOVertices); // Get A Valid Name
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, vertices, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Texture Coordinate Buffer
glGenBuffersARB(1, (GLuint*) &m_nVBOTexCoords); // Get A Valid Name
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);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Normal Buffer
glGenBuffersARB(1, (GLuint*) &m_nVBONormals); // Get A Valid Name
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, normals, GL_STATIC_DRAW_ARB);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
// Generate And Bind The Index Buffer
glGenBuffersARB(1, (GLuint*) &m_nVBOIndexes); // Get A Valid Name
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);
glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
@@ -445,6 +446,7 @@ namespace Shared {
customColor = false;
noSelect = false;
glow = false;
factionColorOpacity = 255;
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("Load v2, this = %p Found meshHeader.hasTexture = %d, texName [%s] mtDiffuse = %d meshIndex = %d modelFile [%s]\n", this, meshHeader.hasTexture, toLower(reinterpret_cast<char*>(meshHeader.texName)).c_str(), mtDiffuse, meshIndex, modelFile.c_str());
@@ -583,6 +585,7 @@ namespace Shared {
//misc
twoSided = (meshHeader.properties & mp3TwoSided) != 0;
customColor = (meshHeader.properties & mp3CustomColor) != 0;
factionColorOpacity = 255 - (meshHeader.properties >> 24);
noSelect = false;
glow = false;
@@ -779,6 +782,7 @@ namespace Shared {
twoSided = (meshHeader.properties & mpfTwoSided) != 0;
noSelect = (meshHeader.properties & mpfNoSelect) != 0;
glow = (meshHeader.properties & mpfGlow) != 0;
factionColorOpacity = 255 - (meshHeader.properties >> 24);
//material
diffuseColor = Vec3f(meshHeader.diffuseColor);
@@ -890,7 +894,7 @@ namespace Shared {
//properties
meshHeader.properties = 0;
if (customColor) {
meshHeader.properties |= mpfCustomColor;
meshHeader.properties |= (255 - (factionColorOpacity << 24)) | mpfCustomColor;
}
if (twoSided) {
meshHeader.properties |= mpfTwoSided;
@@ -1516,6 +1520,7 @@ namespace Shared {
dest->customColor = this->customColor;
dest->noSelect = this->noSelect;
dest->glow = this->glow;
dest->factionColorOpacity = this->factionColorOpacity;
dest->textureFlags = this->textureFlags;
@@ -1535,33 +1540,33 @@ namespace Shared {
void Model::autoJoinMeshFrames() {
/*
print "auto-joining compatible meshes..."
meshes = {}
for mesh in self.meshes:
key = (mesh.texture,mesh.frame_count,mesh.twoSided|mesh.customColour)
if key in meshes:
meshes[key].append(mesh)
else:
meshes[key] = [mesh]
for joinable in meshes.values():
if len(joinable) < 2: continue
base = joinable[0]
print "\tjoining to",base
for mesh in joinable[1:]:
if base.index_count+mesh.index_count > 0xffff:
base = mesh
print "\tjoining to",base
continue
print "\t\t",mesh
for a,b in zip(base.frames,mesh.frames):
a.vertices.extend(b.vertices)
a.normals.extend(b.normals)
if base.texture:
base.textures.extend(mesh.textures)
base.indices.extend(index+base.vertex_count for index in mesh.indices)
base.vertex_count += mesh.vertex_count
base.index_count += mesh.index_count
self.meshes.remove(mesh)
print "auto-joining compatible meshes..."
meshes = {}
for mesh in self.meshes:
key = (mesh.texture,mesh.frame_count,mesh.twoSided|mesh.customColour)
if key in meshes:
meshes[key].append(mesh)
else:
meshes[key] = [mesh]
for joinable in meshes.values():
if len(joinable) < 2: continue
base = joinable[0]
print "\tjoining to",base
for mesh in joinable[1:]:
if base.index_count+mesh.index_count > 0xffff:
base = mesh
print "\tjoining to",base
continue
print "\t\t",mesh
for a,b in zip(base.frames,mesh.frames):
a.vertices.extend(b.vertices)
a.normals.extend(b.normals)
if base.texture:
base.textures.extend(mesh.textures)
base.indices.extend(index+base.vertex_count for index in mesh.indices)
base.vertex_count += mesh.vertex_count
base.index_count += mesh.index_count
self.meshes.remove(mesh)
*/
@@ -1576,13 +1581,13 @@ namespace Shared {
// Duplicate mesh vertices are considered to be those with the same
// 1. texture 2. framecount 3. twosided flag value 4. same custom texture color
// It's possible the texture is missing and will be NULL
// if(mesh.getTextureFlags() & 1) {
// printf("Mesh has textures:\n");
// for(unsigned int meshTexIndex = 0; meshTexIndex < meshTextureCount; ++meshTexIndex) {
// printf("Mesh texture index: %d [%p] [%s]\n",meshTexIndex,mesh.getTexture(meshTexIndex),(mesh.getTexture(meshTexIndex) != NULL ? mesh.getTexture(meshTexIndex)->getPath().c_str() : "n/a"));
// }
// }
// It's possible the texture is missing and will be NULL
// if(mesh.getTextureFlags() & 1) {
// printf("Mesh has textures:\n");
// for(unsigned int meshTexIndex = 0; meshTexIndex < meshTextureCount; ++meshTexIndex) {
// printf("Mesh texture index: %d [%p] [%s]\n",meshTexIndex,mesh.getTexture(meshTexIndex),(mesh.getTexture(meshTexIndex) != NULL ? mesh.getTexture(meshTexIndex)->getPath().c_str() : "n/a"));
// }
// }
string mesh_key = ((mesh.getTextureFlags() & 1) && mesh.getTexture(0) ? mesh.getTexture(0)->getPath() : "none");
mesh_key += string("_") + intToStr(mesh.getFrameCount()) +
string("_") + intToStr(mesh.getTwoSided()) +
@@ -1590,6 +1595,7 @@ namespace Shared {
string("_") + intToStr(mesh.getNoSelect()) +
string("_") + floatToStr(mesh.getOpacity()) +
string("_") + floatToStr(mesh.getGlow()) +
string("_") + intToStr(mesh.getFactionColorOpacity()) +
string("_") + mesh.getDiffuseColor().getString() +
string("_") + mesh.getSpecularColor().getString() +
string("_") + floatToStr(mesh.getSpecularPower());
@@ -1638,7 +1644,7 @@ namespace Shared {
// mesh->copyInto(base, true, true);
//}
//else {
// Need to add verticies for each from from mesh to base
// Need to add verticies for each from from mesh to base
uint32 originalBaseVertexCount = base->getVertexCount();
uint32 newVertexCount =
@@ -1748,14 +1754,14 @@ namespace Shared {
/*
for(int i = 0; i < pboCount; ++i) {
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("PBO Gen i = %d\n",i);
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("PBO Gen i = %d\n",i);
pboIds.push_back(0);
glGenBuffersARB(1, (GLuint*)&pboIds[i]);
// create pixel buffer objects, you need to delete them when program exits.
// glBufferDataARB with NULL pointer reserves only memory space.
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[i]);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufferSize, 0, GL_STREAM_READ_ARB);
pboIds.push_back(0);
glGenBuffersARB(1, (GLuint*)&pboIds[i]);
// create pixel buffer objects, you need to delete them when program exits.
// glBufferDataARB with NULL pointer reserves only memory space.
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, pboIds[i]);
glBufferDataARB(GL_PIXEL_PACK_BUFFER_ARB, bufferSize, 0, GL_STREAM_READ_ARB);
}
glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0);
*/
@@ -1849,7 +1855,7 @@ namespace Shared {
codeSection = "J";
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
glUnmapBufferARB(GL_PIXEL_PACK_BUFFER_ARB); // release pointer to the mapped buffer
//pixmapScreenShot->save("debugPBO.png");
//pixmapScreenShot->save("debugPBO.png");
}
codeSection = "K";
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
@@ -2184,7 +2190,7 @@ namespace Shared {
// if(memcmp(pixel,oldpixel,3)) continue;
// }
// Skip duplicate scanned colors
// Skip duplicate scanned colors
map<unsigned char, map<unsigned char, map<unsigned char, bool> > >::const_iterator iterFind1 = colorAlreadyPickedList.find(pixel[0]);
if (iterFind1 != colorAlreadyPickedList.end()) {
map<unsigned char, map<unsigned char, bool> >::const_iterator iterFind2 = iterFind1->second.find(pixel[1]);
@@ -2241,12 +2247,12 @@ namespace Shared {
uniqueColorID[2]);
/*
glColor3f( uniqueColorID[0] / 255.0f,
uniqueColorID[1] / 255.0f,
uniqueColorID[2] / 255.0f);
//uniqueColorID[3] / 255.0f);
*
*/
glColor3f( uniqueColorID[0] / 255.0f,
uniqueColorID[1] / 255.0f,
uniqueColorID[2] / 255.0f);
//uniqueColorID[3] / 255.0f);
*
*/
}

View File

@@ -723,7 +723,7 @@ namespace Shared {
float numUsedToSmooth = 0.f;
for (int k = -1; k <= 1; ++k) {
for (int l = -1; l <= 1; ++l) {
int tmpHeight = oldHeights[(j + k) * w + (i + l)];
int tmpHeight = (int) oldHeights[(j + k) * w + (i + l)];
if (limitHeight && tmpHeight > 20) {
tmpHeight = 20;
}

View File

@@ -91,9 +91,8 @@ namespace Shared {
if (masterThreadList.find(this) == masterThreadList.end()) {
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n", __FILE__, __FUNCTION__, __LINE__, uniqueID.c_str(), ret);
char szBuf[8096] = "";
snprintf(szBuf, 8096, "invalid thread delete for ptr: %p", this);
throw megaglest_runtime_error(szBuf);
printf("invalid thread delete for ptr: %p", this);
//throw megaglest_runtime_error(szBuf);
}
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s] ret [%d] END\n", __FILE__, __FUNCTION__, __LINE__, uniqueID.c_str(), ret);

View File

@@ -121,13 +121,13 @@ namespace Shared {
findDirs(techDataPaths, techPaths);
if (techPaths.empty() == false) {
// Always calc megapack first so its up to date sooner
const string megapackTechtreeName = "megapack";
vector<string>::iterator iterFindMegaPack = std::find(techPaths.begin(), techPaths.end(), megapackTechtreeName);
if (iterFindMegaPack != techPaths.end()) {
techPaths.erase(iterFindMegaPack);
techPaths.insert(techPaths.begin(), megapackTechtreeName);
const string zetapackTechtreeName = "zetapack";
vector<string>::iterator iterFindZetaPack = std::find(techPaths.begin(), techPaths.end(), zetapackTechtreeName);
if (iterFindZetaPack != techPaths.end()) {
techPaths.erase(iterFindZetaPack);
techPaths.insert(techPaths.begin(), zetapackTechtreeName);
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Found megapack techtree and placing it at the TOP of the list\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
if (SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] Found zetapack techtree and placing it at the TOP of the list\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
}
unsigned int techsPerWorker = ((unsigned int) techPaths.size() / (unsigned int) MAX_FileCRCPreCacheThread_WORKER_THREADS);
if (techPaths.size() % MAX_FileCRCPreCacheThread_WORKER_THREADS != 0) {
@@ -433,7 +433,7 @@ namespace Shared {
SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] Error [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, ex.what());
if (SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem, "In [%s::%s Line: %d] uniqueID [%s]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, this->getUniqueID().c_str());
throw megaglest_runtime_error(ex.what());
//throw megaglest_runtime_error(ex.what());
//abort();
}
//printf("~SimpleTaskThread LINE: %d this = %p\n",__LINE__,this);

View File

@@ -510,9 +510,8 @@ namespace Shared {
MutexSafeWrapper safeMutexX(Mutex::mutexMutexList.get());
std::vector<Mutex *>::iterator iterFind = std::find(Mutex::mutexList.begin(), Mutex::mutexList.end(), this);
if (iterFind == Mutex::mutexList.end()) {
char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] iterFind == Mutex::mutexList.end()", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
throw megaglest_runtime_error(szBuf);
printf("In [%s::%s Line: %d] iterFind == Mutex::mutexList.end()", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
//throw megaglest_runtime_error(szBuf);
}
Mutex::mutexList.erase(iterFind);
safeMutexX.ReleaseLock();
@@ -520,14 +519,12 @@ namespace Shared {
SDLMutexSafeWrapper safeMutex(&mutexAccessor, true);
if (mutex == NULL) {
char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str());
throw megaglest_runtime_error(szBuf);
printf("In [%s::%s Line: %d] mutex == NULL refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str());
//throw megaglest_runtime_error(szBuf);
//printf("%s\n",szBuf);
} else if (refCount >= 1) {
char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str());
throw megaglest_runtime_error(szBuf);
printf("In [%s::%s Line: %d] about to destroy mutex refCount = %d owner [%s] deleteownerId [%s]", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__, refCount, ownerId.c_str(), deleteownerId.c_str());
//throw megaglest_runtime_error(szBuf);
}
if (debugMutexLock == true) {
@@ -609,9 +606,8 @@ namespace Shared {
Semaphore::~Semaphore() {
if (semaphore == NULL) {
char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] semaphore == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
throw megaglest_runtime_error(szBuf);
printf("In [%s::%s Line: %d] semaphore == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
//throw megaglest_runtime_error(szBuf);
}
SDL_DestroySemaphore(semaphore);
semaphore = NULL;
@@ -728,9 +724,8 @@ namespace Shared {
if (debugMasterSlaveThreadController) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
if (trigger == NULL) {
char szBuf[8096] = "";
snprintf(szBuf, 8095, "In [%s::%s Line: %d] trigger == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
throw megaglest_runtime_error(szBuf);
printf("In [%s::%s Line: %d] trigger == NULL", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);
//throw megaglest_runtime_error(szBuf);
}
if (debugMasterSlaveThreadController) printf("In [%s::%s Line: %d]\n", extractFileFromDirectoryPath(__FILE__).c_str(), __FUNCTION__, __LINE__);

View File

@@ -218,9 +218,9 @@ namespace Shared {
double getTimeDuationMinutes(int frames, int updateFps) {
int framesleft = frames;
double hours = (int) ((int) frames / (float) updateFps / 3600.0f);
framesleft = framesleft - hours * 3600 * updateFps;
framesleft = (int) (framesleft - hours * 3600 * updateFps);
double minutes = (int) ((int) framesleft / (float) updateFps / 60.0f);
framesleft = framesleft - minutes * 60 * updateFps;
framesleft = (int) (framesleft - minutes * 60 * updateFps);
double seconds = (int) ((int) framesleft / (float) updateFps);
double result = (hours * 60.0) + minutes;

View File

@@ -514,8 +514,8 @@ namespace Shared {
//printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound);
return string(defaultValueIfNotFound);
} else {
//throw megaglest_runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path);
throw runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path);
//throw runtime_error("Value not found in propertyMap: " + key + ", loaded from: " + path);
return string();
}
} else {
return (it->second != "" ? it->second : (defaultValueIfNotFound != NULL ? defaultValueIfNotFound : it->second));
@@ -618,8 +618,8 @@ namespace Shared {
//printf("In [%s::%s - %d]defaultValueIfNotFound = [%s]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,defaultValueIfNotFound);
return string(defaultValueIfNotFound);
} else {
//throw megaglest_runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path);
throw runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path);
//throw runtime_error("Value not found in propertyMap: " + string(key) + ", loaded from: " + path);
return string();
}
} else {
return (it->second != "" ? it->second : (defaultValueIfNotFound != NULL ? defaultValueIfNotFound : it->second));