- round #2 of coverity bug fixes
This commit is contained in:
parent
b8ab732b85
commit
f269273f07
|
@ -14,7 +14,7 @@
|
||||||
#include "graphics_factory_gl.h"
|
#include "graphics_factory_gl.h"
|
||||||
#include "graphics_interface.h"
|
#include "graphics_interface.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
//#include <png.h>
|
#include "platform_common.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
using namespace Shared::Graphics;
|
using namespace Shared::Graphics;
|
||||||
|
|
|
@ -195,10 +195,10 @@ TravelState PathFinder::findPath(Unit *unit, const Vec2i &finalPos, bool *wasStu
|
||||||
|
|
||||||
UnitPathInterface *path= unit->getPath();
|
UnitPathInterface *path= unit->getPath();
|
||||||
if(path->isEmpty() == false) {
|
if(path->isEmpty() == false) {
|
||||||
if(dynamic_cast<UnitPathBasic *>(path) != NULL) {
|
UnitPathBasic *basic_path = dynamic_cast<UnitPathBasic *>(path);
|
||||||
|
if(basic_path != NULL) {
|
||||||
//route cache
|
//route cache
|
||||||
UnitPathBasic *basicPath = dynamic_cast<UnitPathBasic *>(path);
|
Vec2i pos= basic_path->pop(frameIndex < 0);
|
||||||
Vec2i pos= basicPath->pop(frameIndex < 0);
|
|
||||||
|
|
||||||
if(map->canMove(unit, unit->getPos(), pos)) {
|
if(map->canMove(unit, unit->getPos(), pos)) {
|
||||||
if(frameIndex < 0) {
|
if(frameIndex < 0) {
|
||||||
|
|
|
@ -318,8 +318,8 @@ string getGameReadWritePath(string lookupKey) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(path == "" && getenv("GLESTHOME") != NULL) {
|
if(path == "") {
|
||||||
path = getenv("GLESTHOME");
|
path = safeCharPtrCopy(getenv("GLESTHOME"),8095);
|
||||||
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) {
|
||||||
path += "/";
|
path += "/";
|
||||||
}
|
}
|
||||||
|
|
|
@ -3987,7 +3987,7 @@ void Renderer::MapRenderer::load(float coordStep) {
|
||||||
//printf("Total # of layers for this map = %d totalCellCount = %d overall render reduction ratio = %d times\n",layers.size(),totalCellCount,(totalCellCount / layers.size()));
|
//printf("Total # of layers for this map = %d totalCellCount = %d overall render reduction ratio = %d times\n",layers.size(),totalCellCount,(totalCellCount / layers.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> void* _bindVBO(GLuint vbo,std::vector<T> buf,int target=GL_ARRAY_BUFFER_ARB) {
|
template<typename T> void* _bindVBO(GLuint vbo,std::vector<T> &buf,int target=GL_ARRAY_BUFFER_ARB) {
|
||||||
void* result = NULL;
|
void* result = NULL;
|
||||||
if(vbo) {
|
if(vbo) {
|
||||||
glBindBuffer(target,vbo);
|
glBindBuffer(target,vbo);
|
||||||
|
@ -4025,25 +4025,6 @@ void Renderer::MapRenderer::Layer::renderVisibleLayer() {
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glClientActiveTexture(Renderer::baseTexUnit);
|
glClientActiveTexture(Renderer::baseTexUnit);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// glVertexPointer(3,GL_FLOAT,0,_bindVBO(vbo_vertices,vertices));
|
|
||||||
// glNormalPointer(GL_FLOAT,0,_bindVBO(vbo_normals,normals));
|
|
||||||
//
|
|
||||||
// glClientActiveTexture(Renderer::fowTexUnit);
|
|
||||||
// glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_fowTexCoords,fowTexCoords));
|
|
||||||
//
|
|
||||||
// glClientActiveTexture(Renderer::baseTexUnit);
|
|
||||||
// glBindTexture(GL_TEXTURE_2D,textureHandle);
|
|
||||||
// glTexCoordPointer(2,GL_FLOAT,0,_bindVBO(vbo_surfTexCoords,surfTexCoords));
|
|
||||||
//
|
|
||||||
// //glDrawElements(GL_TRIANGLES,indexCount,GL_UNSIGNED_INT,_bindVBO(vbo_indices,indices,GL_ELEMENT_ARRAY_BUFFER_ARB));
|
|
||||||
// glDrawArrays(GL_TRIANGLE_STRIP, 0, vertices.size());
|
|
||||||
// //unsigned short faceIndices[4] = {0, 1, 2, 3};
|
|
||||||
// //glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_SHORT, &faceIndices[0]);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) {
|
void Renderer::MapRenderer::Layer::render(VisibleQuadContainerCache &qCache) {
|
||||||
|
|
|
@ -1757,7 +1757,8 @@ void MenuStateCustomGame::PlayNow(bool saveGame) {
|
||||||
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
for(unsigned int j = 0; j < languageList.size(); ++j) {
|
||||||
char szMsg[8096]="";
|
char szMsg[8096]="";
|
||||||
if(lang.hasString("NetworkSlotUnassignedError",languageList[j]) == true) {
|
if(lang.hasString("NetworkSlotUnassignedError",languageList[j]) == true) {
|
||||||
strcpy(szMsg,lang.getString("NetworkSlotUnassignedError").c_str());
|
string msg_string = lang.getString("NetworkSlotUnassignedError");
|
||||||
|
strncpy(szMsg,msg_string.c_str(),std::min((int)msg_string.length(),8095));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
strcpy(szMsg,"Cannot start game, some player(s) are not in a network game slot!");
|
strcpy(szMsg,"Cannot start game, some player(s) are not in a network game slot!");
|
||||||
|
@ -3512,8 +3513,10 @@ void MenuStateCustomGame::loadGameSettings(GameSettings *gameSettings,bool force
|
||||||
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
gameSettings->setTeam(slotIndex, listBoxTeams[i].getSelectedItemIndex());
|
||||||
gameSettings->setStartLocationIndex(slotIndex, i);
|
gameSettings->setStartLocationIndex(slotIndex, i);
|
||||||
|
|
||||||
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork || listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
if(listBoxControls[i].getSelectedItemIndex() == ctNetwork ||
|
||||||
if(serverInterface->getSlot(i) != NULL &&
|
listBoxControls[i].getSelectedItemIndex() == ctNetworkUnassigned) {
|
||||||
|
if(serverInterface != NULL &&
|
||||||
|
serverInterface->getSlot(i) != NULL &&
|
||||||
serverInterface->getSlot(i)->isConnected()) {
|
serverInterface->getSlot(i)->isConnected()) {
|
||||||
|
|
||||||
gameSettings->setNetworkPlayerStatuses(slotIndex,serverInterface->getSlot(i)->getNetworkPlayerStatus());
|
gameSettings->setNetworkPlayerStatuses(slotIndex,serverInterface->getSlot(i)->getNetworkPlayerStatus());
|
||||||
|
|
|
@ -2262,32 +2262,32 @@ bool NetworkMessageSynchNetworkGameDataStatus::receive(Socket* socket) {
|
||||||
if(result == true && data.header.techCRCFileCount > 0) {
|
if(result == true && data.header.techCRCFileCount > 0) {
|
||||||
fromEndianHeader();
|
fromEndianHeader();
|
||||||
// Here we loop possibly multiple times
|
// Here we loop possibly multiple times
|
||||||
int packetLoopCount = 1;
|
uint32 packetLoopCount = 1;
|
||||||
if(data.header.techCRCFileCount > (uint32)NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount) {
|
if(data.header.techCRCFileCount > (uint32)NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount) {
|
||||||
packetLoopCount = (data.header.techCRCFileCount / NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount);
|
packetLoopCount = (data.header.techCRCFileCount / (uint32)NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount);
|
||||||
if(data.header.techCRCFileCount % NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount > 0) {
|
if(data.header.techCRCFileCount % (uint32)NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount > 0) {
|
||||||
packetLoopCount++;
|
packetLoopCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] packetLoopCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,packetLoopCount);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] packetLoopCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,packetLoopCount);
|
||||||
|
|
||||||
for(int iPacketLoop = 0; iPacketLoop < packetLoopCount; ++iPacketLoop) {
|
for(uint32 iPacketLoop = 0; iPacketLoop < packetLoopCount; ++iPacketLoop) {
|
||||||
|
|
||||||
int packetIndex = iPacketLoop * NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount;
|
uint32 packetIndex = iPacketLoop * (uint32)NetworkMessageSynchNetworkGameDataStatus::maxFileCRCPacketCount;
|
||||||
int maxFileCountPerPacket = maxFileCRCPacketCount;
|
uint32 maxFileCountPerPacket = (uint32)maxFileCRCPacketCount;
|
||||||
int packetFileCount = min((uint32)maxFileCountPerPacket,data.header.techCRCFileCount - packetIndex);
|
uint32 packetFileCount = min((uint32)maxFileCountPerPacket,data.header.techCRCFileCount - packetIndex);
|
||||||
|
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] iPacketLoop = %d, packetIndex = %d, packetFileCount = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,iPacketLoop,packetIndex,packetFileCount);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] iPacketLoop = %u, packetIndex = %u, packetFileCount = %u\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,iPacketLoop,packetIndex,packetFileCount);
|
||||||
|
|
||||||
result = NetworkMessage::receive(socket, &data.detail.techCRCFileList[packetIndex], (DetailSize1 * packetFileCount),true);
|
result = NetworkMessage::receive(socket, &data.detail.techCRCFileList[packetIndex], ((uint32)DetailSize1 * packetFileCount),true);
|
||||||
if(result == true) {
|
if(result == true) {
|
||||||
for(int i = 0; i < (int)data.header.techCRCFileCount; ++i) {
|
for(int i = 0; i < (int)data.header.techCRCFileCount; ++i) {
|
||||||
data.detail.techCRCFileList[i].nullTerminate();
|
data.detail.techCRCFileList[i].nullTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait a max of x seconds for this message
|
// Wait a max of x seconds for this message
|
||||||
result = NetworkMessage::receive(socket, &data.detail.techCRCFileCRCList[packetIndex], (DetailSize2 * packetFileCount),true);
|
result = NetworkMessage::receive(socket, &data.detail.techCRCFileCRCList[packetIndex], ((uint32)DetailSize2 * packetFileCount),true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fromEndianDetail();
|
fromEndianDetail();
|
||||||
|
|
|
@ -450,6 +450,9 @@ std::vector<std::string> FactionType::validateFactionType() {
|
||||||
// exist in this faction
|
// exist in this faction
|
||||||
if(cmdType->getClass() == ccBuild) {
|
if(cmdType->getClass() == ccBuild) {
|
||||||
const BuildCommandType *build = dynamic_cast<const BuildCommandType *>(cmdType);
|
const BuildCommandType *build = dynamic_cast<const BuildCommandType *>(cmdType);
|
||||||
|
if(build == NULL) {
|
||||||
|
throw megaglest_runtime_error("build == NULL");
|
||||||
|
}
|
||||||
for(int k = 0; k < build->getBuildingCount(); ++k) {
|
for(int k = 0; k < build->getBuildingCount(); ++k) {
|
||||||
const UnitType *buildUnit = build->getBuilding(k);
|
const UnitType *buildUnit = build->getBuilding(k);
|
||||||
|
|
||||||
|
|
|
@ -81,6 +81,26 @@ protected:
|
||||||
std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
std::map<string,int> prodSpeedMorphIsMultiplierValueList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
UpgradeTypeBase() {
|
||||||
|
maxHp = 0;;
|
||||||
|
maxHpIsMultiplier = false;
|
||||||
|
maxHpRegeneration = 0;
|
||||||
|
sight = 0;
|
||||||
|
sightIsMultiplier = false;
|
||||||
|
maxEp = 0;;
|
||||||
|
maxEpIsMultiplier = false;
|
||||||
|
maxEpRegeneration = 0;
|
||||||
|
armor = 0;
|
||||||
|
armorIsMultiplier = false;
|
||||||
|
attackStrength = 0;
|
||||||
|
attackStrengthIsMultiplier = false;
|
||||||
|
attackRange = 0;
|
||||||
|
attackRangeIsMultiplier = false;
|
||||||
|
moveSpeed = 0;
|
||||||
|
moveSpeedIsMultiplier = false;
|
||||||
|
prodSpeed = 0;
|
||||||
|
prodSpeedIsMultiplier = false;
|
||||||
|
}
|
||||||
virtual ~UpgradeTypeBase() {}
|
virtual ~UpgradeTypeBase() {}
|
||||||
|
|
||||||
int getMaxHp() const {return maxHp;}
|
int getMaxHp() const {return maxHp;}
|
||||||
|
|
|
@ -71,19 +71,19 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
||||||
|
|
||||||
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__);
|
||||||
|
|
||||||
fowPixmap0->setPixels(&f);
|
fowPixmap0->setPixels(&f,1);
|
||||||
if((this->gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources) {
|
if((this->gameSettings->getFlagTypes1() & ft1_show_map_resources) == ft1_show_map_resources) {
|
||||||
f = 0.f;
|
f = 0.f;
|
||||||
fowPixmap1->setPixels(&f);
|
fowPixmap1->setPixels(&f,1);
|
||||||
f = 0.5f;
|
f = 0.5f;
|
||||||
for (int y=1; y < scaledH - 1; ++y) {
|
for (int y=1; y < scaledH - 1; ++y) {
|
||||||
for (int x=1; x < scaledW - 1; ++x) {
|
for (int x=1; x < scaledW - 1; ++x) {
|
||||||
fowPixmap1->setPixel(x, y, &f);
|
fowPixmap1->setPixel(x, y, &f,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fowPixmap1->setPixels(&f);
|
fowPixmap1->setPixels(&f,1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,8 +99,7 @@ void Minimap::init(int w, int h, const World *world, bool fogOfWar) {
|
||||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scaledW = %d, scaledH = %d, potW = %d, potH = %d\n",__FILE__,__FUNCTION__,__LINE__,scaledW,scaledH,potW,potH);
|
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] scaledW = %d, scaledH = %d, potW = %d, potH = %d\n",__FILE__,__FUNCTION__,__LINE__,scaledW,scaledH,potW,potH);
|
||||||
|
|
||||||
fowTex->getPixmap()->init(potW, potH, 1);
|
fowTex->getPixmap()->init(potW, potH, 1);
|
||||||
const float *fPtr = &f;
|
fowTex->getPixmap()->setPixels(&f,1);
|
||||||
fowTex->getPixmap()->setPixels(fPtr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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__);
|
||||||
|
@ -269,7 +268,7 @@ void Minimap::computeTexture(const World *world) {
|
||||||
const Map *map= world->getMap();
|
const Map *map= world->getMap();
|
||||||
|
|
||||||
if(tex) {
|
if(tex) {
|
||||||
tex->getPixmap()->setPixels(Vec4f(1.f, 1.f, 1.f, 0.1f).ptr());
|
tex->getPixmap()->setPixels(Vec4f(1.f, 1.f, 1.f, 0.1f).ptr(),tex->getPixmap()->getComponents());
|
||||||
|
|
||||||
for(int j=0; j<tex->getPixmap()->getH(); ++j){
|
for(int j=0; j<tex->getPixmap()->getH(); ++j){
|
||||||
for(int i=0; i<tex->getPixmap()->getW(); ++i){
|
for(int i=0; i<tex->getPixmap()->getW(); ++i){
|
||||||
|
|
|
@ -272,8 +272,8 @@ public:
|
||||||
float getComponentf(int x, int y, int component) const;
|
float getComponentf(int x, int y, int component) const;
|
||||||
|
|
||||||
//set data
|
//set data
|
||||||
void setPixel(int x, int y, const uint8 *value);
|
void setPixel(int x, int y, const uint8 *value, int arraySize);
|
||||||
void setPixel(int x, int y, const float32 *value);
|
void setPixel(int x, int y, const float32 *value, int arraySize);
|
||||||
void setComponent(int x, int y, int component, uint8 value);
|
void setComponent(int x, int y, int component, uint8 value);
|
||||||
void setComponent(int x, int y, int component, float32 value);
|
void setComponent(int x, int y, int component, float32 value);
|
||||||
|
|
||||||
|
@ -283,8 +283,8 @@ public:
|
||||||
void setPixel(int x, int y, float p);
|
void setPixel(int x, int y, float p);
|
||||||
|
|
||||||
//mass set
|
//mass set
|
||||||
void setPixels(const uint8 *value);
|
void setPixels(const uint8 *value, int arraySize);
|
||||||
void setPixels(const float32 *value);
|
void setPixels(const float32 *value, int arraySize);
|
||||||
void setComponents(int component, uint8 value);
|
void setComponents(int component, uint8 value);
|
||||||
void setComponents(int component, float32 value);
|
void setComponents(int component, float32 value);
|
||||||
|
|
||||||
|
|
|
@ -303,6 +303,8 @@ bool valid_utf8_file(const char* file_name);
|
||||||
|
|
||||||
string getFileTextContents(string path);
|
string getFileTextContents(string path);
|
||||||
|
|
||||||
|
string safeCharPtrCopy(const char *ptr, int maxLength=-1);
|
||||||
|
|
||||||
class ValueCheckerVault {
|
class ValueCheckerVault {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -205,6 +205,7 @@ int zipfile_tool(int argc, const char *argv[]) {
|
||||||
|
|
||||||
if (inflateInit(&stream)) {
|
if (inflateInit(&stream)) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflateInit() failed!\n");
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflateInit() failed!\n");
|
||||||
|
if(pInfile) fclose(pInfile);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -243,6 +244,7 @@ int zipfile_tool(int argc, const char *argv[]) {
|
||||||
}
|
}
|
||||||
else if (status != Z_OK) {
|
else if (status != Z_OK) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflate() failed with status %i!\n", status);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("inflate() failed with status %i!\n", status);
|
||||||
|
if(pOutfile) fclose(pOutfile);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,9 +35,9 @@
|
||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char name[MAXLEN_USERNAME]; ///< user name
|
char name[MAXLEN_USERNAME+1]; ///< user name
|
||||||
char passw[MAXLEN_PASSWORD]; ///< password of the account
|
char passw[MAXLEN_PASSWORD+1]; ///< password of the account
|
||||||
char ftpRoot[MAX_PATH_LEN]; ///< root path of the user account on the server
|
char ftpRoot[MAX_PATH_LEN+1]; ///< root path of the user account on the server
|
||||||
int ftpRootLen; ///< length of ftpRoot
|
int ftpRootLen; ///< length of ftpRoot
|
||||||
int accRights; ///< access rights of a account
|
int accRights; ///< access rights of a account
|
||||||
|
|
||||||
|
|
|
@ -257,7 +257,8 @@ const char* ftpGetRealPath(int id, const char* path, int normalize)
|
||||||
int ftpRootLen;
|
int ftpRootLen;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
strcpy(ftpRoot,ftpGetRoot(sessions[id].userId, &len));
|
const char *ftp_rootget = ftpGetRoot(sessions[id].userId, &len);
|
||||||
|
snprintf(ftpRoot,2047,"%s",ftp_rootget);
|
||||||
ftpRootLen = strlen(ftpRoot);
|
ftpRootLen = strlen(ftpRoot);
|
||||||
if(ftpRootLen > 0 && ftpRoot[ftpRootLen-1] != '/') {
|
if(ftpRootLen > 0 && ftpRoot[ftpRootLen-1] != '/') {
|
||||||
strcat(ftpRoot,"/");
|
strcat(ftpRoot,"/");
|
||||||
|
@ -313,7 +314,7 @@ if(VERBOSE_MODE_ENABLED) printf("ftpChangeDir path [%s] realPath [%s] sessions[i
|
||||||
if(ftpStat(realPath, &fileInfo) || (fileInfo.type != TYPE_DIR)) // directory accessible?
|
if(ftpStat(realPath, &fileInfo) || (fileInfo.type != TYPE_DIR)) // directory accessible?
|
||||||
return -2;
|
return -2;
|
||||||
|
|
||||||
strncpy(sessions[id].workingDir, &realPath[len], MAX_PATH_LEN); // apply path
|
strncpy(sessions[id].workingDir, &realPath[len], MAX_PATH_LEN-1); // apply path
|
||||||
if(sessions[id].workingDir[0] == '\0')
|
if(sessions[id].workingDir[0] == '\0')
|
||||||
strcpy(sessions[id].workingDir, "/");
|
strcpy(sessions[id].workingDir, "/");
|
||||||
|
|
||||||
|
|
|
@ -97,7 +97,7 @@ void* ftpOpenDir(const char* path)
|
||||||
if(p)
|
if(p)
|
||||||
{
|
{
|
||||||
p->findHandle = INVALID_HANDLE_VALUE;
|
p->findHandle = INVALID_HANDLE_VALUE;
|
||||||
strcpy(p->path, path);
|
strncpy(p->path, path,strlen(path));
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port, int ses
|
||||||
BOOL on = 1;
|
BOOL on = 1;
|
||||||
unsigned len;
|
unsigned len;
|
||||||
dataSocket = socket(AF_INET, SOCK_STREAM, 0);
|
dataSocket = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(dataSocket < 0)
|
if(dataSocket == INVALID_SOCKET)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if(!passive)
|
if(!passive)
|
||||||
|
@ -308,6 +308,8 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port, int ses
|
||||||
clientAddr.sin_family = AF_INET;
|
clientAddr.sin_family = AF_INET;
|
||||||
clientAddr.sin_addr.s_addr = htonl(*ip);
|
clientAddr.sin_addr.s_addr = htonl(*ip);
|
||||||
clientAddr.sin_port = htons(*port);
|
clientAddr.sin_port = htons(*port);
|
||||||
|
clientAddr.sin_zero[0] = 0;
|
||||||
|
|
||||||
if(connect(dataSocket, (struct sockaddr *)&clientAddr, sizeof(clientAddr)))
|
if(connect(dataSocket, (struct sockaddr *)&clientAddr, sizeof(clientAddr)))
|
||||||
{
|
{
|
||||||
if(VERBOSE_MODE_ENABLED) printf("In ftpEstablishDataConnection #3 about to Close socket = %d, for sessionId = %d\n",dataSocket, sessionId);
|
if(VERBOSE_MODE_ENABLED) printf("In ftpEstablishDataConnection #3 about to Close socket = %d, for sessionId = %d\n",dataSocket, sessionId);
|
||||||
|
@ -325,6 +327,7 @@ socket_t ftpEstablishDataConnection(int passive, ip_t *ip, port_t *port, int ses
|
||||||
myAddr.sin_family = AF_INET;
|
myAddr.sin_family = AF_INET;
|
||||||
myAddr.sin_addr.s_addr = INADDR_ANY;
|
myAddr.sin_addr.s_addr = INADDR_ANY;
|
||||||
myAddr.sin_port = htons(passivePort);
|
myAddr.sin_port = htons(passivePort);
|
||||||
|
myAddr.sin_zero[0] = 0;
|
||||||
//myAddr.sin_port = htons(ftpGetPassivePort() + sessionId);
|
//myAddr.sin_port = htons(ftpGetPassivePort() + sessionId);
|
||||||
|
|
||||||
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)))
|
if(setsockopt(dataSocket, SOL_SOCKET, SO_REUSEADDR, (const char *)&on, sizeof(on)))
|
||||||
|
@ -388,10 +391,10 @@ socket_t ftpAcceptDataConnection(socket_t listner)
|
||||||
len = sizeof(clientinfo);
|
len = sizeof(clientinfo);
|
||||||
|
|
||||||
dataSocket = accept(listner, (struct sockaddr *)&clientinfo, &len);
|
dataSocket = accept(listner, (struct sockaddr *)&clientinfo, &len);
|
||||||
if(dataSocket < 0)
|
if(dataSocket == INVALID_SOCKET)
|
||||||
{
|
{
|
||||||
if(VERBOSE_MODE_ENABLED) printf("ERROR In ftpAcceptDataConnection accept failed, dataSocket = %d, listner = %d\n", dataSocket,listner);
|
if(VERBOSE_MODE_ENABLED) printf("ERROR In ftpAcceptDataConnection accept failed, dataSocket = %d, listner = %d\n", dataSocket,listner);
|
||||||
dataSocket = -1;
|
//dataSocket = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -410,7 +413,7 @@ socket_t ftpAcceptDataConnection(socket_t listner)
|
||||||
|
|
||||||
ftpUntrackSocket(dataSocket);
|
ftpUntrackSocket(dataSocket);
|
||||||
ftpCloseSocket(&dataSocket);
|
ftpCloseSocket(&dataSocket);
|
||||||
dataSocket = -1;
|
dataSocket = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (socket_t)dataSocket;
|
return (socket_t)dataSocket;
|
||||||
|
@ -424,28 +427,27 @@ socket_t ftpCreateServerSocket(int portNumber)
|
||||||
int val = 1;
|
int val = 1;
|
||||||
|
|
||||||
theServer = socket(AF_INET, SOCK_STREAM, 0);
|
theServer = socket(AF_INET, SOCK_STREAM, 0);
|
||||||
if(theServer < 0)
|
if(theServer == INVALID_SOCKET)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
serverinfo.sin_family = AF_INET;
|
serverinfo.sin_family = AF_INET;
|
||||||
serverinfo.sin_addr.s_addr = INADDR_ANY;
|
serverinfo.sin_addr.s_addr = INADDR_ANY;
|
||||||
serverinfo.sin_port = htons(portNumber);
|
serverinfo.sin_port = htons(portNumber);
|
||||||
|
serverinfo.sin_zero[0] = 0;
|
||||||
len = sizeof(serverinfo);
|
len = sizeof(serverinfo);
|
||||||
|
|
||||||
setsockopt(theServer, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
|
int opt_result = setsockopt(theServer, SOL_SOCKET, SO_REUSEADDR, (char *)&val, sizeof(val));
|
||||||
|
|
||||||
if(bind(theServer, (struct sockaddr *)&serverinfo, len))
|
if(bind(theServer, (struct sockaddr *)&serverinfo, len)) {
|
||||||
{
|
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d opt_result = %d\n",theServer,opt_result);
|
||||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket bind FAILED about to close listener socket = %d\n",theServer);
|
|
||||||
|
|
||||||
ftpUntrackSocket(theServer);
|
ftpUntrackSocket(theServer);
|
||||||
ftpCloseSocket(&theServer);
|
ftpCloseSocket(&theServer);
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listen(theServer, 100))
|
if(listen(theServer, 100)) {
|
||||||
{
|
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d opt_result = %d\n",theServer,opt_result);
|
||||||
if(VERBOSE_MODE_ENABLED) printf("\nERROR In ftpCreateServerSocket listen FAILED about to close listener socket = %d\n",theServer);
|
|
||||||
|
|
||||||
ftpUntrackSocket(theServer);
|
ftpUntrackSocket(theServer);
|
||||||
ftpCloseSocket(&theServer);
|
ftpCloseSocket(&theServer);
|
||||||
|
|
|
@ -639,14 +639,14 @@ void CHECK_FONT_PATH(const char *filename,const char *fontFamily,const char **fo
|
||||||
}
|
}
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",(*path != NULL ? *path : "null"),(*font != NULL ? *font : "null"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",(*path != NULL ? *path : "null"),(*font != NULL ? *font : "null"));
|
||||||
if( *font == NULL && fontFamily != NULL && strlen(fontFamily) > 0) {
|
if( *font == NULL && fontFamily != NULL && strlen(fontFamily) > 0) {
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font [%s] family [%s]\n",(*font != NULL ? *font : "null"),(fontFamily != NULL ? fontFamily : "null"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font [%s] family [%s]\n",(*font != NULL ? *font : "null"),fontFamily);
|
||||||
string fileFound = findFontFamily(*font, fontFamily);
|
string fileFound = findFontFamily(*font, fontFamily);
|
||||||
if(fileFound != "") {
|
if(fileFound != "") {
|
||||||
*path = fileFound.c_str();
|
//*path = fileFound.c_str();
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file found [%s]\n",fileFound.c_str());
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file found [%s]\n",fileFound.c_str());
|
||||||
if( *path != NULL && strlen(*path) > 0 && fileExists(*path) == true ) {
|
if( fileFound.length() > 0 && fileExists(fileFound) == true ) {
|
||||||
if(*font) free((void*)*font);
|
if(*font) free((void*)*font);
|
||||||
*font = strdup(*path);
|
*font = strdup(fileFound.c_str());
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file has been set[%s]\n",(*font != NULL ? *font : "null"));
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file has been set[%s]\n",(*font != NULL ? *font : "null"));
|
||||||
}
|
}
|
||||||
*path = NULL;
|
*path = NULL;
|
||||||
|
@ -677,10 +677,11 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get user-specified font path
|
// Get user-specified font path
|
||||||
if(getenv("MEGAGLEST_FONT") != NULL || getenv("MEGAGLEST_FONT_FAMILY") != NULL) {
|
string megaglest_font = safeCharPtrCopy(getenv("MEGAGLEST_FONT"),8095);
|
||||||
|
string megaglest_font_family = safeCharPtrCopy(getenv("MEGAGLEST_FONT_FAMILY"),8095);
|
||||||
if(getenv("MEGAGLEST_FONT") != NULL) {
|
if(megaglest_font != "" || megaglest_font_family != "") {
|
||||||
tryFont = getenv("MEGAGLEST_FONT");
|
if(megaglest_font != "") {
|
||||||
|
tryFont = megaglest_font;
|
||||||
|
|
||||||
if(Text::DEFAULT_FONT_PATH_ABSOLUTE != "") {
|
if(Text::DEFAULT_FONT_PATH_ABSOLUTE != "") {
|
||||||
tryFont = Text::DEFAULT_FONT_PATH_ABSOLUTE + "/" + extractFileFromDirectoryPath(tryFont);
|
tryFont = Text::DEFAULT_FONT_PATH_ABSOLUTE + "/" + extractFileFromDirectoryPath(tryFont);
|
||||||
|
@ -689,10 +690,10 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry
|
||||||
replaceAll(tryFont, "/", "\\");
|
replaceAll(tryFont, "/", "\\");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
CHECK_FONT_PATH(tryFont.c_str(),getenv("MEGAGLEST_FONT_FAMILY"),&font,&path);
|
CHECK_FONT_PATH(tryFont.c_str(),megaglest_font_family.c_str(),&font,&path);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CHECK_FONT_PATH(NULL,getenv("MEGAGLEST_FONT_FAMILY"),&font,&path);
|
CHECK_FONT_PATH(NULL,megaglest_font_family.c_str(),&font,&path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1216,7 +1216,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
|
||||||
f = NULL;
|
f = NULL;
|
||||||
char fileType[4]="";
|
char fileType[4]="";
|
||||||
memset(&fileType[0],0,4);
|
memset(&fileType[0],0,4);
|
||||||
memcpy(&fileType[0],fileHeader.id,4);
|
memcpy(&fileType[0],fileHeader.id,3);
|
||||||
printf("In [%s::%s] file = [%s] fileheader.id = [%s][%c]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,path.c_str(),fileType,fileHeader.id[0]);
|
printf("In [%s::%s] file = [%s] fileheader.id = [%s][%c]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,path.c_str(),fileType,fileHeader.id[0]);
|
||||||
throw megaglest_runtime_error("Not a valid G3D model",true);
|
throw megaglest_runtime_error("Not a valid G3D model",true);
|
||||||
}
|
}
|
||||||
|
@ -1270,7 +1270,7 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
|
||||||
}
|
}
|
||||||
meshCount = Shared::PlatformByteOrder::fromCommonEndian(meshCount);
|
meshCount = Shared::PlatformByteOrder::fromCommonEndian(meshCount);
|
||||||
|
|
||||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("meshCount = %d\n",meshCount);
|
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("meshCount = %u\n",meshCount);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
meshes= new Mesh[meshCount];
|
meshes= new Mesh[meshCount];
|
||||||
|
|
|
@ -1154,9 +1154,14 @@ float Pixmap2D::getComponentf(int x, int y, int component) const {
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pixmap2D::setPixel(int x, int y, const uint8 *value) {
|
void Pixmap2D::setPixel(int x, int y, const uint8 *value, int arraySize) {
|
||||||
for(int i=0; i<components; ++i) {
|
if(arraySize > components) {
|
||||||
int index = (w*y+x)*components+i;
|
char szBuf[8096];
|
||||||
|
snprintf(szBuf,8096,"Invalid pixmap arraySize: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",arraySize,path.c_str(),h,w,components,x,y);
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
for(int i = 0; i < components; ++i) {
|
||||||
|
int index = (w * y + x) * components + i;
|
||||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||||
char szBuf[8096];
|
char szBuf[8096];
|
||||||
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
snprintf(szBuf,8096,"Invalid pixmap index: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",index,path.c_str(),h,w,components,x,y);
|
||||||
|
@ -1168,8 +1173,14 @@ void Pixmap2D::setPixel(int x, int y, const uint8 *value) {
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pixmap2D::setPixel(int x, int y, const float32 *value) {
|
void Pixmap2D::setPixel(int x, int y, const float32 *value, int arraySize) {
|
||||||
for(int i=0; i<components; ++i) {
|
if(arraySize > components) {
|
||||||
|
char szBuf[8096];
|
||||||
|
snprintf(szBuf,8096,"Invalid pixmap arraySize: %d for [%s], h = %d, w = %d, components = %d x = %d y = %d\n",arraySize,path.c_str(),h,w,components,x,y);
|
||||||
|
throw megaglest_runtime_error(szBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
for(int i = 0; i < components; ++i) {
|
||||||
int index = (w*y+x)*components+i;
|
int index = (w*y+x)*components+i;
|
||||||
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
if(index < 0 || (unsigned int)index >= getPixelByteCount()) {
|
||||||
char szBuf[8096];
|
char szBuf[8096];
|
||||||
|
@ -1244,19 +1255,19 @@ void Pixmap2D::setPixel(int x, int y, float p) {
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pixmap2D::setPixels(const uint8 *value){
|
void Pixmap2D::setPixels(const uint8 *value, int arraySize) {
|
||||||
for(int i=0; i<w; ++i){
|
for(int i = 0; i < w; ++i) {
|
||||||
for(int j=0; j<h; ++j){
|
for(int j = 0; j < h; ++j) {
|
||||||
setPixel(i, j, value);
|
setPixel(i, j, value, arraySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pixmap2D::setPixels(const float32 *value){
|
void Pixmap2D::setPixels(const float32 *value, int arraySize) {
|
||||||
for(int i=0; i<w; ++i){
|
for(int i = 0; i < w; ++i) {
|
||||||
for(int j=0; j<h; ++j){
|
for(int j = 0; j < h; ++j) {
|
||||||
setPixel(i, j, value);
|
setPixel(i, j, value, arraySize);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
|
@ -1372,10 +1383,10 @@ void Pixmap2D::subCopy(int x, int y, const Pixmap2D *sourcePixmap){
|
||||||
|
|
||||||
uint8 *pixel= new uint8[components];
|
uint8 *pixel= new uint8[components];
|
||||||
|
|
||||||
for(int i=0; i<sourcePixmap->getW(); ++i){
|
for(int i = 0; i < sourcePixmap->getW(); ++i) {
|
||||||
for(int j=0; j<sourcePixmap->getH(); ++j){
|
for(int j = 0; j < sourcePixmap->getH(); ++j) {
|
||||||
sourcePixmap->getPixel(i, j, pixel);
|
sourcePixmap->getPixel(i, j, pixel);
|
||||||
setPixel(i+x, j+y, pixel);
|
setPixel(i+x, j+y, pixel, components);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
|
@ -1393,10 +1404,10 @@ void Pixmap2D::copyImagePart(int x, int y, const Pixmap2D *sourcePixmap){
|
||||||
|
|
||||||
uint8 *pixel= new uint8[components];
|
uint8 *pixel= new uint8[components];
|
||||||
|
|
||||||
for(int i=x; i<x+w; ++i){
|
for(int i = x; i < x + w; ++i) {
|
||||||
for(int j=y; j<y+h; ++j){
|
for(int j = y; j < y + h; ++j) {
|
||||||
sourcePixmap->getPixel(i, j, pixel);
|
sourcePixmap->getPixel(i, j, pixel);
|
||||||
setPixel(i-x, j-y, pixel);
|
setPixel(i-x, j-y, pixel, components);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
CalculatePixelsCRC(pixels,getPixelByteCount(), crc);
|
||||||
|
|
|
@ -922,6 +922,7 @@ void MapPreview::saveToFile(const string &path) {
|
||||||
strncpy(header.title, title.c_str(), MAX_TITLE_LENGTH);
|
strncpy(header.title, title.c_str(), MAX_TITLE_LENGTH);
|
||||||
strncpy(header.author, author.c_str(), MAX_AUTHOR_LENGTH);
|
strncpy(header.author, author.c_str(), MAX_AUTHOR_LENGTH);
|
||||||
strncpy(header.version2.short_desc, desc.c_str(), MAX_DESCRIPTION_LENGTH_VERSION2);
|
strncpy(header.version2.short_desc, desc.c_str(), MAX_DESCRIPTION_LENGTH_VERSION2);
|
||||||
|
header.version2.short_desc[MAX_DESCRIPTION_LENGTH_VERSION2] = 0;
|
||||||
header.version2.magic= 0x01020304;
|
header.version2.magic= 0x01020304;
|
||||||
header.version2.cliffLevel= cliffLevel;
|
header.version2.cliffLevel= cliffLevel;
|
||||||
header.version2.cameraHeight= cameraHeight;
|
header.version2.cameraHeight= cameraHeight;
|
||||||
|
|
|
@ -348,8 +348,8 @@ void findAll(const string &path, vector<string> &results, bool cutExtension, boo
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
* specified as wildcard
|
* specified as wildcard
|
||||||
*/
|
*/
|
||||||
if(mypath.size() >= 2 && mypath.compare(max((size_t)0,mypath.size() - 2), 2, "*.") == 0) {
|
if((int)mypath.size() >= 2 && mypath.compare(max((int)0,(int)mypath.size() - 2), 2, "*.") == 0) {
|
||||||
mypath = mypath.substr(0, max((size_t)0,mypath.size() - 2));
|
mypath = mypath.substr(0, max((int)0,(int)mypath.size() - 2));
|
||||||
mypath += "*";
|
mypath += "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,7 +525,7 @@ bool EndsWith(const string &str, const string& key)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (str.length() >= key.length()) {
|
if (str.length() >= key.length()) {
|
||||||
result = (0 == str.compare(max((size_t)0,str.length() - key.length()), key.length(), key));
|
result = (0 == str.compare(max((int)0,(int)str.length() - (int)key.length()), key.length(), key));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1017,8 +1017,8 @@ uint32 getFolderTreeContentsCheckSumRecursively(const string &path, const string
|
||||||
// Stupid win32 is searching for all files without extension when *. is
|
// Stupid win32 is searching for all files without extension when *. is
|
||||||
// specified as wildcard
|
// specified as wildcard
|
||||||
//
|
//
|
||||||
if(mypath.size() >= 2 && mypath.compare(max((size_t)0,mypath.size() - 2), 2, "*.") == 0) {
|
if((int)mypath.size() >= 2 && mypath.compare(max((int)0,(int)mypath.size() - 2), 2, "*.") == 0) {
|
||||||
mypath = mypath.substr(0, max((size_t)0,mypath.size() - 2));
|
mypath = mypath.substr(0, max((int)0,(int)mypath.size() - 2));
|
||||||
mypath += "*";
|
mypath += "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1187,8 +1187,8 @@ vector<string> getFolderTreeContentsListRecursively(const string &path, const st
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
* specified as wildcard
|
* specified as wildcard
|
||||||
*/
|
*/
|
||||||
if(mypath.size() >= 2 && mypath.compare(max((size_t)0,mypath.size() - 2), 2, "*.") == 0) {
|
if((int)mypath.size() >= 2 && mypath.compare(max((int)0,(int)mypath.size() - 2), 2, "*.") == 0) {
|
||||||
mypath = mypath.substr(0, max((size_t)0,mypath.size() - 2));
|
mypath = mypath.substr(0, max((int)0,(int)mypath.size() - 2));
|
||||||
mypath += "*";
|
mypath += "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1338,8 +1338,8 @@ vector<std::pair<string,uint32> > getFolderTreeContentsCheckSumListRecursively(c
|
||||||
/** Stupid win32 is searching for all files without extension when *. is
|
/** Stupid win32 is searching for all files without extension when *. is
|
||||||
* specified as wildcard
|
* specified as wildcard
|
||||||
*/
|
*/
|
||||||
if(mypath.size() >= 2 && mypath.compare(max((size_t)0,mypath.size() - 2), 2, "*.") == 0) {
|
if((int)mypath.size() >= 2 && mypath.compare(max((int)0,(int)mypath.size() - 2), 2, "*.") == 0) {
|
||||||
mypath = mypath.substr(0, max((size_t)0,mypath.size() - 2));
|
mypath = mypath.substr(0, max((int)0,(int)mypath.size() - 2));
|
||||||
mypath += "*";
|
mypath += "*";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2424,17 +2424,29 @@ void ValueCheckerVault::checkItemInVault(const void *ptr,int value) const {
|
||||||
|
|
||||||
string getUserHome() {
|
string getUserHome() {
|
||||||
string home_folder = "";
|
string home_folder = "";
|
||||||
const char *homedir = getenv("HOME");
|
home_folder = safeCharPtrCopy(getenv("HOME"),8095);
|
||||||
if (!homedir) {
|
if(home_folder == "") {
|
||||||
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
#if _BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
|
||||||
struct passwd *pw = getpwuid(getuid());
|
struct passwd *pw = getpwuid(getuid());
|
||||||
homedir = pw->pw_dir;
|
home_folder = safeCharPtrCopy(pw->pw_dir,8095);
|
||||||
#else
|
|
||||||
homedir = "";
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
home_folder = homedir;
|
|
||||||
return home_folder;
|
return home_folder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string safeCharPtrCopy(const char *ptr,int maxLength) {
|
||||||
|
if(ptr == NULL) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
if(maxLength <= 0) {
|
||||||
|
maxLength = 8096;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *pBuffer = new char[maxLength+1];
|
||||||
|
memset(pBuffer,0,maxLength+1);
|
||||||
|
memcpy(pBuffer,ptr,std::min((int)strlen(ptr),maxLength));
|
||||||
|
return pBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}}//end namespace
|
}}//end namespace
|
||||||
|
|
|
@ -75,7 +75,7 @@ void dump_event (irc_session_t * session, const char * event, const char * origi
|
||||||
if ( cnt ) {
|
if ( cnt ) {
|
||||||
strcat (buf, "|");
|
strcat (buf, "|");
|
||||||
}
|
}
|
||||||
strcat (buf, params[cnt]);
|
strncat (buf, params[cnt],std::min((int)strlen(params[cnt]),511));
|
||||||
}
|
}
|
||||||
|
|
||||||
addlog ("Event \"%s\", origin: \"%s\", params: %d [%s]", event, origin ? origin : "NULL", cnt, buf);
|
addlog ("Event \"%s\", origin: \"%s\", params: %d [%s]", event, origin ? origin : "NULL", cnt, buf);
|
||||||
|
|
|
@ -549,17 +549,16 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
MIB_IPADDRTABLE * ipTable = NULL;
|
MIB_IPADDRTABLE * ipTable = NULL;
|
||||||
{
|
{
|
||||||
ULONG bufLen = 0;
|
ULONG bufLen = 0;
|
||||||
for (int i=0; i<5; i++)
|
for (int i = 0; i < 5; i++) {
|
||||||
{
|
|
||||||
DWORD ipRet = GetIpAddrTable(ipTable, &bufLen, false);
|
DWORD ipRet = GetIpAddrTable(ipTable, &bufLen, false);
|
||||||
if (ipRet == ERROR_INSUFFICIENT_BUFFER)
|
if (ipRet == ERROR_INSUFFICIENT_BUFFER) {
|
||||||
{
|
|
||||||
free(ipTable); // in case we had previously allocated it
|
free(ipTable); // in case we had previously allocated it
|
||||||
ipTable = (MIB_IPADDRTABLE *) malloc(bufLen);
|
ipTable = (MIB_IPADDRTABLE *) malloc(bufLen);
|
||||||
}
|
}
|
||||||
else if (ipRet == NO_ERROR) break;
|
else if(ipRet == NO_ERROR) {
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
|
else {
|
||||||
free(ipTable);
|
free(ipTable);
|
||||||
ipTable = NULL;
|
ipTable = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -567,8 +566,7 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ipTable)
|
if (ipTable) {
|
||||||
{
|
|
||||||
// Try to get the Adapters-info table, so we can given useful names to the IP
|
// Try to get the Adapters-info table, so we can given useful names to the IP
|
||||||
// addresses we are returning. Gotta call GetAdaptersInfo() up to 5 times to handle
|
// addresses we are returning. Gotta call GetAdaptersInfo() up to 5 times to handle
|
||||||
// the potential race condition between the size-query call and the get-data call.
|
// the potential race condition between the size-query call and the get-data call.
|
||||||
|
@ -576,17 +574,16 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
IP_ADAPTER_INFO * pAdapterInfo = NULL;
|
IP_ADAPTER_INFO * pAdapterInfo = NULL;
|
||||||
{
|
{
|
||||||
ULONG bufLen = 0;
|
ULONG bufLen = 0;
|
||||||
for (int i=0; i<5; i++)
|
for (int i = 0; i < 5; i++) {
|
||||||
{
|
|
||||||
DWORD apRet = GetAdaptersInfo(pAdapterInfo, &bufLen);
|
DWORD apRet = GetAdaptersInfo(pAdapterInfo, &bufLen);
|
||||||
if (apRet == ERROR_BUFFER_OVERFLOW)
|
if (apRet == ERROR_BUFFER_OVERFLOW) {
|
||||||
{
|
|
||||||
free(pAdapterInfo); // in case we had previously allocated it
|
free(pAdapterInfo); // in case we had previously allocated it
|
||||||
pAdapterInfo = (IP_ADAPTER_INFO *) malloc(bufLen);
|
pAdapterInfo = (IP_ADAPTER_INFO *) malloc(bufLen);
|
||||||
}
|
}
|
||||||
else if (apRet == ERROR_SUCCESS) break;
|
else if(apRet == ERROR_SUCCESS) {
|
||||||
else
|
break;
|
||||||
{
|
}
|
||||||
|
else {
|
||||||
free(pAdapterInfo);
|
free(pAdapterInfo);
|
||||||
pAdapterInfo = NULL;
|
pAdapterInfo = NULL;
|
||||||
break;
|
break;
|
||||||
|
@ -594,23 +591,18 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (DWORD i=0; i<ipTable->dwNumEntries; i++)
|
for (DWORD i = 0; i < ipTable->dwNumEntries; i++) {
|
||||||
{
|
|
||||||
const MIB_IPADDRROW & row = ipTable->table[i];
|
const MIB_IPADDRROW & row = ipTable->table[i];
|
||||||
|
|
||||||
// Now lookup the appropriate adaptor-name in the pAdaptorInfos, if we can find it
|
// Now lookup the appropriate adaptor-name in the pAdaptorInfos, if we can find it
|
||||||
const char * name = NULL;
|
const char * name = NULL;
|
||||||
//const char * desc = NULL;
|
//const char * desc = NULL;
|
||||||
if (pAdapterInfo)
|
if (pAdapterInfo) {
|
||||||
{
|
|
||||||
IP_ADAPTER_INFO * next = pAdapterInfo;
|
IP_ADAPTER_INFO * next = pAdapterInfo;
|
||||||
while((next)&&(name==NULL))
|
while((next)&&(name==NULL)) {
|
||||||
{
|
|
||||||
IP_ADDR_STRING * ipAddr = &next->IpAddressList;
|
IP_ADDR_STRING * ipAddr = &next->IpAddressList;
|
||||||
while(ipAddr)
|
while(ipAddr) {
|
||||||
{
|
if (Inet_AtoN(ipAddr->IpAddress.String) == ntohl(row.dwAddr)) {
|
||||||
if (Inet_AtoN(ipAddr->IpAddress.String) == ntohl(row.dwAddr))
|
|
||||||
{
|
|
||||||
name = next->AdapterName;
|
name = next->AdapterName;
|
||||||
//desc = next->Description;
|
//desc = next->Description;
|
||||||
break;
|
break;
|
||||||
|
@ -620,19 +612,23 @@ string getNetworkInterfaceBroadcastAddress(string ipAddress)
|
||||||
next = next->Next;
|
next = next->Next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (name == NULL)
|
if (name == NULL) {
|
||||||
{
|
|
||||||
name = "";
|
name = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 ipAddr = ntohl(row.dwAddr);
|
uint32 ipAddr = ntohl(row.dwAddr);
|
||||||
uint32 netmask = ntohl(row.dwMask);
|
uint32 netmask = ntohl(row.dwMask);
|
||||||
uint32 baddr = ipAddr & netmask;
|
uint32 baddr = ipAddr & netmask;
|
||||||
if (row.dwBCastAddr) baddr |= ~netmask;
|
if (row.dwBCastAddr) {
|
||||||
|
baddr |= ~netmask;
|
||||||
|
}
|
||||||
|
|
||||||
char ifaAddrStr[32]; Ip::Inet_NtoA(ipAddr, ifaAddrStr);
|
char ifaAddrStr[32];
|
||||||
char maskAddrStr[32]; Ip::Inet_NtoA(netmask, maskAddrStr);
|
Ip::Inet_NtoA(ipAddr, ifaAddrStr);
|
||||||
char dstAddrStr[32]; Ip::Inet_NtoA(baddr, dstAddrStr);
|
char maskAddrStr[32];
|
||||||
|
Ip::Inet_NtoA(netmask, maskAddrStr);
|
||||||
|
char dstAddrStr[32];
|
||||||
|
Ip::Inet_NtoA(baddr, dstAddrStr);
|
||||||
//printf(" Found interface: name=[%s] desc=[%s] address=[%s] netmask=[%s] broadcastAddr=[%s]\n", name, desc?desc:"unavailable", ifaAddrStr, maskAddrStr, dstAddrStr);
|
//printf(" Found interface: name=[%s] desc=[%s] address=[%s] netmask=[%s] broadcastAddr=[%s]\n", name, desc?desc:"unavailable", ifaAddrStr, maskAddrStr, dstAddrStr);
|
||||||
if(strcmp(ifaAddrStr,ipAddress.c_str()) == 0) {
|
if(strcmp(ifaAddrStr,ipAddress.c_str()) == 0) {
|
||||||
broadCastAddress = dstAddrStr;
|
broadCastAddress = dstAddrStr;
|
||||||
|
@ -2434,6 +2430,9 @@ Socket *ServerSocket::accept(bool errorOnFail) {
|
||||||
throwException(szBuf);
|
throwException(szBuf);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
::close(newSock);
|
||||||
|
newSock = INVALID_SOCKET;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2925,7 +2924,8 @@ void BroadCastSocketThread::execute() {
|
||||||
strcat(buff,":");
|
strcat(buff,":");
|
||||||
strcat(buff,ipList[idx1].c_str());
|
strcat(buff,ipList[idx1].c_str());
|
||||||
strcat(buff,":");
|
strcat(buff,":");
|
||||||
strcat(buff,intToStr(this->boundPort).c_str());
|
string port_string = intToStr(this->boundPort);
|
||||||
|
strncat(buff,port_string.c_str(),std::min((int)port_string.length(),100));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(difftime((long int)time(NULL),elapsed) >= 1 && getQuitStatus() == false) {
|
if(difftime((long int)time(NULL),elapsed) >= 1 && getQuitStatus() == false) {
|
||||||
|
|
|
@ -260,6 +260,10 @@ string PlatformExceptionHandler::getStackTrace() {
|
||||||
SymCleanup(hProcess);
|
SymCleanup(hProcess);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __MINGW32__
|
||||||
|
delete [] pSym;
|
||||||
|
#endif
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -130,7 +130,7 @@ int g3d2xml(FILE *infile, FILE *outfile)
|
||||||
struct ModelHeader modelHeader;
|
struct ModelHeader modelHeader;
|
||||||
struct MeshHeader meshHeader;
|
struct MeshHeader meshHeader;
|
||||||
size_t nBytes;
|
size_t nBytes;
|
||||||
uint8 textureName[NAMESIZE];
|
uint8 textureName[NAMESIZE+1];
|
||||||
float32 *fdata;
|
float32 *fdata;
|
||||||
uint32 *idata;
|
uint32 *idata;
|
||||||
unsigned int ii, jj, kk;
|
unsigned int ii, jj, kk;
|
||||||
|
@ -226,7 +226,8 @@ int g3d2xml(FILE *infile, FILE *outfile)
|
||||||
/* read / write the texture name if present */
|
/* read / write the texture name if present */
|
||||||
if (meshHeader.textures)
|
if (meshHeader.textures)
|
||||||
{
|
{
|
||||||
nBytes = sizeof(textureName);
|
memset(&textureName[0],0,NAMESIZE+1);
|
||||||
|
nBytes = NAMESIZE;
|
||||||
if (fread(&textureName, nBytes, 1, infile) != 1)
|
if (fread(&textureName, nBytes, 1, infile) != 1)
|
||||||
{
|
{
|
||||||
printf("Could not read texture name!\n");
|
printf("Could not read texture name!\n");
|
||||||
|
|
|
@ -245,7 +245,7 @@ int processMesh(xmlNode *n, FILE *outfile)
|
||||||
float32 color[3];
|
float32 color[3];
|
||||||
|
|
||||||
struct MeshHeader mh;
|
struct MeshHeader mh;
|
||||||
uint8 texname[NAMESIZE];
|
uint8 texname[NAMESIZE+1];
|
||||||
|
|
||||||
int foundFlag = FALSE;
|
int foundFlag = FALSE;
|
||||||
xmlNode *texn = NULL;
|
xmlNode *texn = NULL;
|
||||||
|
@ -304,7 +304,7 @@ int processMesh(xmlNode *n, FILE *outfile)
|
||||||
printf("Could not find <Texture> element!\n");
|
printf("Could not find <Texture> element!\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
memset(texname, 0, NAMESIZE);
|
memset(texname, 0, NAMESIZE+1);
|
||||||
strncpy((char*)texname,
|
strncpy((char*)texname,
|
||||||
(char*)xmlGetProp(texn, (xmlChar*)"name"), NAMESIZE);
|
(char*)xmlGetProp(texn, (xmlChar*)"name"), NAMESIZE);
|
||||||
fwrite(texname, NAMESIZE, 1, outfile);
|
fwrite(texname, NAMESIZE, 1, outfile);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user