- bugfixes found from cppcheck
This commit is contained in:
parent
f542ce36e4
commit
3af608151e
|
@ -720,7 +720,7 @@ Command* Commander::buildCommand(const NetworkCommand* networkCommand) const {
|
|||
gameNetworkInterface->sendTextMessage(szMsg,-1, true, "");
|
||||
|
||||
}
|
||||
else {
|
||||
else if(gameNetworkInterface != NULL) {
|
||||
char szMsg[1024]="";
|
||||
sprintf(szMsg,"Player detected an error: Connection lost, possible Unit / Faction mismatch for unitId: %d",networkCommand->getUnitId());
|
||||
gameNetworkInterface->sendTextMessage(szMsg,-1, true,"");
|
||||
|
|
|
@ -404,49 +404,50 @@ string Game::findFactionLogoFile(const GameSettings *settings, Logger *logger,
|
|||
if(settings == NULL) {
|
||||
result = "";
|
||||
}
|
||||
string mapName = settings->getMap();
|
||||
string tilesetName = settings->getTileset();
|
||||
string techName = settings->getTech();
|
||||
string scenarioName = settings->getScenario();
|
||||
bool loadingImageUsed = false;
|
||||
else {
|
||||
string mapName = settings->getMap();
|
||||
string tilesetName = settings->getTileset();
|
||||
string techName = settings->getTech();
|
||||
string scenarioName = settings->getScenario();
|
||||
bool loadingImageUsed = false;
|
||||
|
||||
if(logger != NULL) {
|
||||
logger->setState(Lang::getInstance().get("Loading"));
|
||||
if(logger != NULL) {
|
||||
logger->setState(Lang::getInstance().get("Loading"));
|
||||
|
||||
if(scenarioName.empty()) {
|
||||
logger->setSubtitle(formatString(mapName) + " - " +
|
||||
formatString(tilesetName) + " - " + formatString(techName));
|
||||
}
|
||||
else {
|
||||
logger->setSubtitle(formatString(scenarioName));
|
||||
}
|
||||
}
|
||||
|
||||
string scenarioDir = "";
|
||||
bool skipCustomLoadScreen = false;
|
||||
if(skipCustomLoadScreen == false) {
|
||||
scenarioDir = extractScenarioLogoFile(settings, result, loadingImageUsed,
|
||||
logger, factionLogoFilter);
|
||||
}
|
||||
// try to use a faction related loading screen
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false) {
|
||||
for(int i=0; i < settings->getFactionCount(); ++i ) {
|
||||
if( settings->getFactionControl(i) == ctHuman ||
|
||||
(settings->getFactionControl(i) == ctNetwork && settings->getThisFactionIndex() == i)) {
|
||||
|
||||
result = extractFactionLogoFile(loadingImageUsed, settings->getFactionTypeName(i),
|
||||
scenarioDir, techName, logger, factionLogoFilter);
|
||||
break;
|
||||
if(scenarioName.empty()) {
|
||||
logger->setSubtitle(formatString(mapName) + " - " +
|
||||
formatString(tilesetName) + " - " + formatString(techName));
|
||||
}
|
||||
else {
|
||||
logger->setSubtitle(formatString(scenarioName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to use a tech related loading screen
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false){
|
||||
result = extractTechLogoFile(scenarioDir, techName,
|
||||
loadingImageUsed, logger, factionLogoFilter);
|
||||
}
|
||||
string scenarioDir = "";
|
||||
bool skipCustomLoadScreen = false;
|
||||
if(skipCustomLoadScreen == false) {
|
||||
scenarioDir = extractScenarioLogoFile(settings, result, loadingImageUsed,
|
||||
logger, factionLogoFilter);
|
||||
}
|
||||
// try to use a faction related loading screen
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false) {
|
||||
for(int i=0; i < settings->getFactionCount(); ++i ) {
|
||||
if( settings->getFactionControl(i) == ctHuman ||
|
||||
(settings->getFactionControl(i) == ctNetwork && settings->getThisFactionIndex() == i)) {
|
||||
|
||||
result = extractFactionLogoFile(loadingImageUsed, settings->getFactionTypeName(i),
|
||||
scenarioDir, techName, logger, factionLogoFilter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// try to use a tech related loading screen
|
||||
if(skipCustomLoadScreen == false && loadingImageUsed == false){
|
||||
result = extractTechLogoFile(scenarioDir, techName,
|
||||
loadingImageUsed, logger, factionLogoFilter);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -6133,25 +6133,27 @@ void Renderer::renderUnitTitles(Font2D *font, Vec3f color) {
|
|||
|
||||
for(int idx = 0; idx < visibleFrameUnitList.size(); idx++) {
|
||||
const Unit *unit = visibleFrameUnitList[idx];
|
||||
if(unit != NULL && unit->getCurrentUnitTitle() != "") {
|
||||
//get the screen coordinates
|
||||
Vec3f screenPos = unit->getScreenPos();
|
||||
if(unit != NULL) {
|
||||
if(unit->getCurrentUnitTitle() != "") {
|
||||
//get the screen coordinates
|
||||
Vec3f screenPos = unit->getScreenPos();
|
||||
#ifdef USE_STREFLOP
|
||||
renderText(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
|
||||
renderText(unit->getCurrentUnitTitle(), font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
|
||||
#else
|
||||
renderText(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
renderText(unit->getCurrentUnitTitle(), font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
#endif
|
||||
|
||||
unitRenderedList[unit->getId()] = true;
|
||||
}
|
||||
else {
|
||||
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
|
||||
Vec3f screenPos = unit->getScreenPos();
|
||||
unitRenderedList[unit->getId()] = true;
|
||||
}
|
||||
else {
|
||||
string str = unit->getFullName() + " - " + intToStr(unit->getId()) + " [" + unit->getPos().getString() + "]";
|
||||
Vec3f screenPos = unit->getScreenPos();
|
||||
#ifdef USE_STREFLOP
|
||||
renderText(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
|
||||
renderText(str, font, color, streflop::fabs(screenPos.x) + 5, streflop::fabs(screenPos.y) + 5, false);
|
||||
#else
|
||||
renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
renderText(str, font, color, fabs(screenPos.x) + 5, fabs(screenPos.y) + 5, false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
visibleFrameUnitList.clear();
|
||||
|
|
|
@ -1800,34 +1800,31 @@ void MenuStateConnectedGame::update() {
|
|||
labelPlayerStatus[i].setText("");
|
||||
}
|
||||
|
||||
if(hasFactions == true) {
|
||||
for(int i=0; i<gameSettings->getFactionCount(); ++i){
|
||||
if(hasFactions == true && gameSettings != NULL) {
|
||||
for(int i=0; i < gameSettings->getFactionCount(); ++i){
|
||||
int slot = gameSettings->getStartLocationIndex(i);
|
||||
|
||||
if(gameSettings != NULL) {
|
||||
if( gameSettings->getFactionControl(i) == ctNetwork ||
|
||||
gameSettings->getFactionControl(i) == ctHuman) {
|
||||
switch(gameSettings->getNetworkPlayerStatuses(i)) {
|
||||
case npst_BeRightBack:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusBeRightBack"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.8f, 0.f));
|
||||
break;
|
||||
case npst_Ready:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusReady"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(0.f, 1.f, 0.f));
|
||||
break;
|
||||
case npst_PickSettings:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||
break;
|
||||
default:
|
||||
labelPlayerStatus[slot].setText("");
|
||||
break;
|
||||
}
|
||||
if( gameSettings->getFactionControl(i) == ctNetwork ||
|
||||
gameSettings->getFactionControl(i) == ctHuman) {
|
||||
switch(gameSettings->getNetworkPlayerStatuses(i)) {
|
||||
case npst_BeRightBack:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusBeRightBack"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.8f, 0.f));
|
||||
break;
|
||||
case npst_Ready:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusReady"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(0.f, 1.f, 0.f));
|
||||
break;
|
||||
case npst_PickSettings:
|
||||
labelPlayerStatus[slot].setText(lang.get("PlayerStatusSetup"));
|
||||
labelPlayerStatus[slot].setTextColor(Vec3f(1.f, 0.f, 0.f));
|
||||
break;
|
||||
default:
|
||||
labelPlayerStatus[slot].setText("");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
listBoxControls[slot].setSelectedItemIndex(gameSettings->getFactionControl(i),errorOnMissingData);
|
||||
listBoxRMultiplier[slot].setSelectedItemIndex((gameSettings->getResourceMultiplierIndex(i)));
|
||||
listBoxTeams[slot].setSelectedItemIndex(gameSettings->getTeam(i),errorOnMissingData);
|
||||
|
|
|
@ -456,9 +456,9 @@ bool Map::isResourceNear(const Vec2i &pos, const ResourceType *rt, Vec2i &resour
|
|||
if(resourceNear == false && resourceClickPos != NULL) {
|
||||
std::vector<FindBestPos> bestPosList;
|
||||
|
||||
if(resourceClickPos) {
|
||||
//if(resourceClickPos) {
|
||||
//printf("^^^^^ unit [%s - %d]\n",unit->getFullName().c_str(),unit->getId());
|
||||
}
|
||||
//}
|
||||
|
||||
for(int i = -1; i <= 1; ++i) {
|
||||
for(int j = -1; j <= 1; ++j) {
|
||||
|
|
|
@ -1412,9 +1412,9 @@ void UnitUpdater::updateRepair(Unit *unit, int frameIndex) {
|
|||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit = %p\n",__FILE__,__FUNCTION__,__LINE__,unit);
|
||||
|
||||
if(unit != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit doing the repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName().c_str(),unit->getId());
|
||||
}
|
||||
//if(unit != NULL) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] unit doing the repair [%s] - %d\n",__FILE__,__FUNCTION__,__LINE__,unit->getFullName().c_str(),unit->getId());
|
||||
//}
|
||||
|
||||
Command *command= unit->getCurrCommand();
|
||||
const RepairCommandType *rct= static_cast<const RepairCommandType*>(command->getCommandType());
|
||||
|
|
|
@ -0,0 +1,253 @@
|
|||
#include "shader_d3d9.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "graphics_interface.h"
|
||||
#include "context_d3d9.h"
|
||||
#include "texture_d3d9.h"
|
||||
#include "d3d9_util.h"
|
||||
|
||||
#include "leak_dumper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Shared{ namespace Graphics{ namespace D3d9{
|
||||
|
||||
// ===============================================
|
||||
// class ShaderD3d9
|
||||
// ===============================================
|
||||
|
||||
ShaderProgramD3d9::ShaderProgramD3d9(){
|
||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||
d3dDevice= static_cast<ContextD3d9*>(gi.getCurrentContext())->getD3dDevice();
|
||||
vertexShader= NULL;
|
||||
pixelShader= NULL;
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::attach(VertexShader *vs, FragmentShader *fs){
|
||||
vertexShader= static_cast<VertexShaderD3d9*>(vs);
|
||||
pixelShader= static_cast<PixelShaderD3d9*>(fs);
|
||||
}
|
||||
|
||||
bool ShaderProgramD3d9::link(string &messages){
|
||||
d3dVsConstantTable= vertexShader->getD3dConstantTable();
|
||||
d3dPsConstantTable= pixelShader->getD3dConstantTable();
|
||||
return true;
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::activate(){
|
||||
d3dDevice->SetVertexShader(vertexShader->getD3dVertexShader());
|
||||
d3dDevice->SetPixelShader(pixelShader->getD3dPixelShader());
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, int value){
|
||||
D3DXHANDLE vsHandle= d3dVsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
D3DXHANDLE psHandle= d3dPsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
HRESULT vsResult= d3dVsConstantTable->SetInt(d3dDevice, vsHandle, value);
|
||||
HRESULT psResult= d3dPsConstantTable->SetInt(d3dDevice, psHandle, value);
|
||||
if(vsResult!=D3D_OK && psResult!=D3D_OK){
|
||||
throw runtime_error("Error setting shader uniform: "+string(name));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, float value){
|
||||
D3DXHANDLE vsHandle= d3dVsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
D3DXHANDLE psHandle= d3dPsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
HRESULT vsResult= d3dVsConstantTable->SetFloat(d3dDevice, vsHandle, value);
|
||||
HRESULT psResult= d3dPsConstantTable->SetFloat(d3dDevice, psHandle, value);
|
||||
if(vsResult!=D3D_OK && psResult!=D3D_OK){
|
||||
throw runtime_error("Error setting shader uniform: "+string(name));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, const Vec2f &value){
|
||||
setUniform(name, Vec4f(value.x, value.y, 0.0f, 0.0f));
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, const Vec3f &value){
|
||||
setUniform(name, Vec4f(value.x, value.y, value.z, 0.0f));
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, const Vec4f &value){
|
||||
D3DXVECTOR4 v;
|
||||
memcpy(&v, &value, sizeof(float)*4);
|
||||
|
||||
D3DXHANDLE vsHandle= d3dVsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
D3DXHANDLE psHandle= d3dPsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
HRESULT vsResult= d3dVsConstantTable->SetVector(d3dDevice, vsHandle, &v);
|
||||
HRESULT psResult= d3dPsConstantTable->SetVector(d3dDevice, psHandle, &v);
|
||||
if(vsResult!=D3D_OK && psResult!=D3D_OK){
|
||||
throw runtime_error("Error setting shader uniform: "+string(name));
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, const Matrix3f &value){
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
void ShaderProgramD3d9::setUniform(const string &name, const Matrix4f &value){
|
||||
D3DXMATRIX m;
|
||||
memcpy(&m, &value, sizeof(float)*16);
|
||||
|
||||
D3DXHANDLE vsHandle= d3dVsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
D3DXHANDLE psHandle= d3dPsConstantTable->GetConstantByName(NULL, name.c_str());
|
||||
HRESULT vsResult= d3dVsConstantTable->SetMatrix(d3dDevice, vsHandle, &m);
|
||||
HRESULT psResult= d3dPsConstantTable->SetMatrix(d3dDevice, psHandle, &m);
|
||||
if(vsResult!=D3D_OK && psResult!=D3D_OK){
|
||||
throw runtime_error("Error setting shader uniform: "+string(name));
|
||||
}
|
||||
}
|
||||
|
||||
/*void ShaderD3d9::setUniform(const string &name, const Texture *value){
|
||||
D3DXHANDLE handle= d3dConstantTable->GetConstantByName(NULL, name);
|
||||
D3DXCONSTANT_DESC d3dDesc;
|
||||
UINT i=1;
|
||||
IDirect3DTexture9 *d3dTexture= static_cast<const Texture2DD3d9*>(value)->getD3dTexture();
|
||||
HRESULT result= d3dConstantTable->GetConstantDesc(handle, &d3dDesc, &i);
|
||||
if(result==D3D_OK)
|
||||
d3dDevice->SetTexture(d3dDesc.RegisterIndex, d3dTexture);
|
||||
else
|
||||
throw runtime_error("Error setting shader uniform sampler: "+string(name));
|
||||
}
|
||||
|
||||
bool ShaderD3d9::isUniform(char *name){
|
||||
D3DXCONSTANT_DESC d3dDesc;
|
||||
UINT i=1;
|
||||
D3DXHANDLE handle= d3dConstantTable->GetConstantByName(NULL, name);
|
||||
HRESULT result= d3dConstantTable->GetConstantDesc(handle, &d3dDesc, &i);
|
||||
return result==D3D_OK;
|
||||
}*/
|
||||
|
||||
// ===============================================
|
||||
// class ShaderD3d9
|
||||
// ===============================================
|
||||
|
||||
ShaderD3d9::ShaderD3d9(){
|
||||
GraphicsInterface &gi= GraphicsInterface::getInstance();
|
||||
d3dDevice= static_cast<ContextD3d9*>(gi.getCurrentContext())->getD3dDevice();
|
||||
d3dConstantTable= NULL;
|
||||
}
|
||||
|
||||
void ShaderD3d9::end(){
|
||||
if(d3dConstantTable!=NULL){
|
||||
d3dConstantTable->Release();
|
||||
d3dConstantTable= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void ShaderD3d9::load(const string &path){
|
||||
source.load(path);
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class VertexShaderD3d9
|
||||
// ===============================================
|
||||
|
||||
VertexShaderD3d9::VertexShaderD3d9(){
|
||||
target= "vs_2_0";
|
||||
d3dVertexShader= NULL;
|
||||
}
|
||||
|
||||
void VertexShaderD3d9::end(){
|
||||
ShaderD3d9::end();
|
||||
if(d3dVertexShader!=NULL){
|
||||
d3dVertexShader->Release();
|
||||
d3dVertexShader= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool VertexShaderD3d9::compile(string &messages){
|
||||
//compile shader
|
||||
ID3DXBuffer *code= NULL;
|
||||
ID3DXBuffer *errors= NULL;
|
||||
|
||||
HRESULT result= D3DXCompileShader(
|
||||
source.getCode().c_str(), source.getCode().size(), NULL, NULL,
|
||||
"main", target.c_str(), 0, &code, &errors,
|
||||
&d3dConstantTable);
|
||||
|
||||
if(errors!=NULL){
|
||||
messages+= reinterpret_cast<char*>(errors->GetBufferPointer());
|
||||
}
|
||||
|
||||
if(FAILED(result)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//create shader
|
||||
if(code!=NULL){
|
||||
D3DCALL(d3dDevice->CreateVertexShader((DWORD*) code->GetBufferPointer(), &d3dVertexShader));
|
||||
|
||||
//release
|
||||
code->Release();
|
||||
}
|
||||
if(errors!=NULL){
|
||||
errors->Release();
|
||||
}
|
||||
|
||||
//set defaults
|
||||
if(d3dConstantTable!=NULL){
|
||||
d3dConstantTable->SetDefaults(d3dDevice);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ===============================================
|
||||
// class PixelShaderD3d9
|
||||
// ===============================================
|
||||
|
||||
PixelShaderD3d9::PixelShaderD3d9(){
|
||||
target= "ps_2_0";
|
||||
d3dPixelShader= NULL;
|
||||
}
|
||||
|
||||
void PixelShaderD3d9::end(){
|
||||
ShaderD3d9::end();
|
||||
if(d3dPixelShader!=NULL){
|
||||
d3dPixelShader->Release();
|
||||
d3dPixelShader= NULL;
|
||||
}
|
||||
}
|
||||
|
||||
bool PixelShaderD3d9::compile(string &messages){
|
||||
|
||||
messages+= "Compiling shader: " + source.getPathInfo() + "\n";
|
||||
|
||||
//compile shader
|
||||
ID3DXBuffer *code= NULL;
|
||||
ID3DXBuffer *errors= NULL;
|
||||
|
||||
HRESULT result= D3DXCompileShader(
|
||||
source.getCode().c_str(), source.getCode().size(), NULL, NULL,
|
||||
"main", target.c_str(), 0, &code, &errors,
|
||||
&d3dConstantTable);
|
||||
|
||||
if(errors!=NULL){
|
||||
messages+= reinterpret_cast<char*>(errors->GetBufferPointer());
|
||||
}
|
||||
|
||||
if(FAILED(result)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(code!=NULL) {
|
||||
//create shader
|
||||
D3DCALL(d3dDevice->CreatePixelShader((DWORD*) code->GetBufferPointer(), &d3dPixelShader));
|
||||
|
||||
//release
|
||||
code->Release();
|
||||
}
|
||||
if(errors!=NULL){
|
||||
errors->Release();
|
||||
}
|
||||
|
||||
//set defaults
|
||||
if(d3dConstantTable!=NULL){
|
||||
d3dConstantTable->SetDefaults(d3dDevice);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}}}//end namespace
|
|
@ -823,6 +823,8 @@ void Model::loadG3d(const string &path, bool deletePixMapAfterLoad,
|
|||
FileHeader fileHeader;
|
||||
size_t readBytes = fread(&fileHeader, sizeof(FileHeader), 1, f);
|
||||
if(strncmp(reinterpret_cast<char*>(fileHeader.id), "G3D", 3) != 0) {
|
||||
fclose(f);
|
||||
f = NULL;
|
||||
printf("In [%s::%s] file = [%s] fileheader.id = [%s][%c]\n",__FILE__,__FUNCTION__,path.c_str(),reinterpret_cast<char*>(fileHeader.id),fileHeader.id[0]);
|
||||
throw runtime_error("Not a valid G3D model");
|
||||
}
|
||||
|
|
|
@ -1873,9 +1873,13 @@ bool searchAndReplaceTextInFile(string fileName, string findText, string replace
|
|||
#endif
|
||||
|
||||
if(fp1 == NULL) {
|
||||
if(fp2) fclose(fp2);
|
||||
|
||||
throw runtime_error("cannot open input file [" + fileName + "]");
|
||||
}
|
||||
if(fp2 == NULL) {
|
||||
if(fp1) fclose(fp1);
|
||||
|
||||
throw runtime_error("cannot open output file [" + tempfileName + "]");
|
||||
}
|
||||
|
||||
|
|
|
@ -99,6 +99,13 @@ static size_t my_fwrite(void *buffer, size_t size, size_t nmemb, void *stream) {
|
|||
|
||||
out->isValidXfer = true;
|
||||
}
|
||||
else if(out == NULL) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str());
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"===> #2 FTP Client thread FAILED to open file for writing [%s]\n",fullFilePath.c_str());
|
||||
return -1; /* failure, can't open file to write */
|
||||
}
|
||||
|
||||
size_t result = fwrite(buffer, size, nmemb, out->stream);
|
||||
if(result != nmemb) {
|
||||
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("===> FTP Client thread FAILED to write data chunk to file [%s] nmemb = %lu, result = %lu\n",fullFilePath.c_str(),nmemb,result);
|
||||
|
|
|
@ -2312,7 +2312,8 @@ void BroadCastSocketThread::execute() {
|
|||
PLATFORM_SOCKET bcfd[MAX_NIC_COUNT]; // The socket used for the broadcast.
|
||||
bool one = true; // Parameter for "setscokopt".
|
||||
int pn=0; // The number of the packet broadcasted.
|
||||
char buff[1024]=""; // Buffers the data to be broadcasted.
|
||||
const int buffMaxSize=1024;
|
||||
char buff[buffMaxSize]=""; // Buffers the data to be broadcasted.
|
||||
char myhostname[100]=""; // hostname of local machine
|
||||
//char subnetmask[MAX_NIC_COUNT][100]; // Subnet mask to broadcast to
|
||||
struct hostent* myhostent=NULL;
|
||||
|
@ -2375,14 +2376,16 @@ void BroadCastSocketThread::execute() {
|
|||
// Send this machine's host name and address in hostname:n.n.n.n format
|
||||
sprintf(buff,"%s",myhostname);
|
||||
for(unsigned int idx1 = 0; idx1 < ipList.size(); idx1++) {
|
||||
sprintf(buff,"%s:%s",buff,ipList[idx1].c_str());
|
||||
//sprintf(buff,"%s:%s",buff,ipList[idx1].c_str());
|
||||
strcat(buff,":");
|
||||
strcat(buff,ipList[idx1].c_str());
|
||||
}
|
||||
|
||||
if(difftime(time(NULL),elapsed) >= 1 && getQuitStatus() == false) {
|
||||
elapsed = time(NULL);
|
||||
// Broadcast the packet to the subnet
|
||||
//if( sendto( bcfd, buff, sizeof(buff) + 1, 0 , (struct sockaddr *)&bcaddr, sizeof(struct sockaddr_in) ) != sizeof(buff) + 1 )
|
||||
if( sendto( bcfd[idx], buff, sizeof(buff) + 1, 0 , (struct sockaddr *)&bcLocal[idx], sizeof(struct sockaddr_in) ) != sizeof(buff) + 1 ) {
|
||||
if( sendto( bcfd[idx], buff, buffMaxSize, 0 , (struct sockaddr *)&bcLocal[idx], sizeof(struct sockaddr_in) ) != buffMaxSize ) {
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugNetwork).enabled) SystemFlags::OutputDebug(SystemFlags::debugNetwork,"Sendto error: %s\n", getLastSocketErrorFormattedText().c_str());
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace Shared { namespace Util {
|
|||
wcstombs_s(&i, &b[0], l, v, l);
|
||||
#endif
|
||||
append(b);
|
||||
delete b;
|
||||
delete [] b;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue