Fix build warnings

develop
kaetemi 4 years ago
parent 0367e4f7c3
commit 9896eae64d

@ -1173,7 +1173,7 @@ void D3DWndProc(CDriverD3D *driver, HWND hWnd, UINT message, WPARAM wParam, LPAR
} }
} }
if (driver->_EventEmitter.getNumEmitters() > 0) if (driver && driver->_EventEmitter.getNumEmitters() > 0)
{ {
CWinEventEmitter *we = NLMISC::safe_cast<CWinEventEmitter *>(driver->_EventEmitter.getEmitter(0)); CWinEventEmitter *we = NLMISC::safe_cast<CWinEventEmitter *>(driver->_EventEmitter.getEmitter(0));
// Process the message by the emitter // Process the message by the emitter

@ -1373,10 +1373,11 @@ CVertexBufferHardARB::~CVertexBufferHardARB()
} }
} }
#ifdef NL_DEBUG #ifdef NL_DEBUG
if (_VertexPtr) if (_VertexPtr)
{ {
_VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList); nlassert(_VertexArrayRange);
} _VertexArrayRange->_MappedVBList.erase(_IteratorInMappedVBList);
}
#endif #endif
#ifdef USE_OPENGLES #ifdef USE_OPENGLES

@ -921,7 +921,7 @@ void CRenderTrav::changeVPLightSetupMaterial(const CMaterial &mat, bool exclude
Driver->setUniform4f(IDriver::VertexProgram, program->idxLighted().Diffuse[i], color); Driver->setUniform4f(IDriver::VertexProgram, program->idxLighted().Diffuse[i], color);
} }
nlassert(_VPNumLights < MaxVPLight);
if (i != _VPNumLights) if (i != _VPNumLights)
{ {
color= _VPLightDiffuse[i] * matDiff; color= _VPLightDiffuse[i] * matDiff;

@ -775,9 +775,9 @@ CTransformShape *CScene::createInstance(const string &shapeName)
// Look if this instance get lightmap information // Look if this instance get lightmap information
#if defined(__GNUC__) && __GNUC__ < 3 #if defined(__GNUC__) && __GNUC__ < 3
CMeshBase *pMB = (CMeshBase*)((IShape*)(pTShp->Shape)); CMeshBase *pMB = pTShp ? (CMeshBase*)((IShape*)(pTShp->Shape)) : NULL;
#else // not GNUC #else // not GNUC
CMeshBase *pMB = dynamic_cast<CMeshBase*>((IShape*)(pTShp->Shape)); CMeshBase *pMB = pTShp ? dynamic_cast<CMeshBase*>((IShape*)(pTShp->Shape)) : NULL;
#endif // not GNUC #endif // not GNUC
CMeshBaseInstance *pMBI = dynamic_cast<CMeshBaseInstance*>( pTShp ); CMeshBaseInstance *pMBI = dynamic_cast<CMeshBaseInstance*>( pTShp );
if( ( pMB != NULL ) && ( pMBI != NULL ) ) if( ( pMB != NULL ) && ( pMBI != NULL ) )

@ -256,14 +256,14 @@ void CShadowMapManager::renderGenerate(CScene *scene)
garbageShadowTextures(scene); garbageShadowTextures(scene);
IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver(); IDriver *driverForShadowGeneration= scene->getRenderTrav().getAuxDriver();
nlassert(driverForShadowGeneration);
CSmartPtr<NL3D::ITexture> previousRenderTarget = driverForShadowGeneration->getRenderTarget(); CSmartPtr<NL3D::ITexture> previousRenderTarget = driverForShadowGeneration->getRenderTarget();
// Init // Init
// ******** // ********
uint32 wndW= _BlurTextureW, wndH= _BlurTextureH; uint32 wndW= _BlurTextureW, wndH= _BlurTextureH;
// get some text/screen size. // get some text/screen size.
if(driverForShadowGeneration) driverForShadowGeneration->getWindowSize(wndW, wndH);
driverForShadowGeneration->getWindowSize(wndW, wndH);
uint baseTextureSize= scene->getShadowMapTextureSize(); uint baseTextureSize= scene->getShadowMapTextureSize();
// Minimize the Dest Texture size, so the blurTexture don't get too heavy in VRAM. // Minimize the Dest Texture size, so the blurTexture don't get too heavy in VRAM.
uint32 textDestW= min(wndW, (uint32)NL3D_SMM_MAX_TEXTDEST_SIZE); uint32 textDestW= min(wndW, (uint32)NL3D_SMM_MAX_TEXTDEST_SIZE);

@ -683,8 +683,7 @@ void CShapeBank::reset()
while( scmIt != ShapeCacheNameToShapeCache.end() ) while( scmIt != ShapeCacheNameToShapeCache.end() )
{ {
CShapeCache *pShpCache = getShapeCachePtrFromShapeCacheName( scmIt->first ); CShapeCache *pShpCache = getShapeCachePtrFromShapeCacheName( scmIt->first );
if( pShpCache == NULL ) nlassert(pShpCache);
nlstop; // Should never happen
pShpCache->MaxSize = 0; pShpCache->MaxSize = 0;
checkShapeCache( pShpCache ); checkShapeCache( pShpCache );

@ -121,17 +121,20 @@ void CSurfaceLightGrid::getStaticLightSetup(NLMISC::CRGBA sunAmbient, const CVe
CLightInfluenceInterpolator::CCorner &corner= interp.Corners[y*2 + x]; CLightInfluenceInterpolator::CCorner &corner= interp.Corners[y*2 + x];
// For all lights // For all lights
uint lid; uint lid;
for(lid= 0; lid<CSurfaceLightGrid::NumLightPerCorner; lid++) if (igPointLights)
{ {
// get the id of the light in the ig for (lid = 0; lid < CSurfaceLightGrid::NumLightPerCorner; lid++)
uint igLightId= cellCorner.Light[lid];
// If empty id, stop
if(igLightId==0xFF)
break;
else
{ {
// Set pointer of the light in the corner // get the id of the light in the ig
corner.Lights[lid]= igPointLights + igLightId; uint igLightId = cellCorner.Light[lid];
// If empty id, stop
if (igLightId == 0xFF)
break;
else
{
// Set pointer of the light in the corner
corner.Lights[lid] = igPointLights + igLightId;
}
} }
} }
// Reset Empty slots. // Reset Empty slots.
@ -152,7 +155,7 @@ void CSurfaceLightGrid::getStaticLightSetup(NLMISC::CRGBA sunAmbient, const CVe
// BiLinear Ambient Contribution. // BiLinear Ambient Contribution.
//------------- //-------------
// If FF, then take Sun Ambient => leave color and alpha To 0. // If FF, then take Sun Ambient => leave color and alpha To 0.
if(cellCorner.LocalAmbientId!=0xFF) if(igPointLights && cellCorner.LocalAmbientId!=0xFF)
{ {
CPointLight &pl= igPointLights[cellCorner.LocalAmbientId]; CPointLight &pl= igPointLights[cellCorner.LocalAmbientId];
// take current ambient from pointLight // take current ambient from pointLight

@ -2678,6 +2678,8 @@ void CTessFace::updateBindAndSplit()
} }
else else
{ {
nlassert(f0);
nlassert(f1);
// multipatch face case are detected when face->Patch==NULL !!! // multipatch face case are detected when face->Patch==NULL !!!
if(f0->FLeft && f0->FLeft->Patch==NULL) if(f0->FLeft && f0->FLeft->Patch==NULL)
{ {
@ -2710,6 +2712,8 @@ void CTessFace::updateBindAndSplit()
} }
else else
{ {
nlassert(f0);
nlassert(f1);
if(f0->FLeft) if(f0->FLeft)
{ {
while(f0->FLeft->isLeaf()) while(f0->FLeft->isLeaf())
@ -2781,6 +2785,8 @@ void CTessFace::updateBindAndSplit()
{ {
CTessFace *f; CTessFace *f;
sint i; sint i;
nlassert(f0);
nlassert(f1);
// Same reasoning for rectangular patchs, as above. // Same reasoning for rectangular patchs, as above.
for(i=0;i<2;i++) for(i=0;i<2;i++)

@ -161,8 +161,14 @@ namespace NLGUI
// ... // ...
limitingParent = limitingParent->getParent(); limitingParent = limitingParent->getParent();
} }
if (limitingParent)
getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal()); {
getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal());
}
else
{
nlwarning("No limiting parent for width");
}
} }
// resize H // resize H
@ -178,9 +184,14 @@ namespace NLGUI
CInterfaceGroup *limitingParent = colEnclosing->getParent(); CInterfaceGroup *limitingParent = colEnclosing->getParent();
while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent))) while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent)))
limitingParent = limitingParent->getParent(); limitingParent = limitingParent->getParent();
if (limitingParent)
nlassert(limitingParent); {
getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal()); getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
}
else
{
nlwarning("No limiting parent for height");
}
} }
} }
} }

@ -50,7 +50,7 @@ void xmlCheckNodeName (xmlNodePtr &node, const char *nodeName)
// Make an error message // Make an error message
char tmp[512]; char tmp[512];
smprintf (tmp, 512, "LogicStateMachine STATE_MACHINE XML Syntax error in block line %d, node %s should be %s", smprintf (tmp, 512, "LogicStateMachine STATE_MACHINE XML Syntax error in block line %d, node %s should be %s",
node ? (int)node->line:-1, node->name, nodeName); node ? (int)node->line:-1, node ? (const char *)node->name : "NULL", nodeName);
nlinfo (tmp); nlinfo (tmp);
nlstop; nlstop;

@ -75,7 +75,7 @@ CBigFile::CHandleFile &CBigFile::CThreadFileArray::get(uint32 index)
// if the vector is not allocated, allocate it (empty entries filled with NULL => not opened FILE* in this thread) // if the vector is not allocated, allocate it (empty entries filled with NULL => not opened FILE* in this thread)
if(index>=ptr->size()) if(index>=ptr->size())
{ {
ptr->resize(index+1); ptr->resize((ptrdiff_t)index + 1);
} }
return (*ptr)[index]; return (*ptr)[index];
@ -278,11 +278,13 @@ bool CBigFile::BNP::readHeader(FILE *file)
} }
char sFileName[256]; char sFileName[256];
if (fread (sFileName, 1, nStringSize, file) != nStringSize) if (nStringSize)
{ {
return false; if (fread(sFileName, 1, nStringSize, file) != nStringSize)
{
return false;
}
} }
sFileName[nStringSize] = 0; sFileName[nStringSize] = 0;
uint32 nFileSize2; uint32 nFileSize2;

@ -4325,7 +4325,7 @@ void CBitmap::blend(CBitmap &Bm0, CBitmap &Bm1, uint16 factor, bool inputBitmapI
else else
#endif //#ifdef NL_OS_WINDOWS #endif //#ifdef NL_OS_WINDOWS
{ {
uint8 *endPix = dest + (numPix << 2); uint8 *endPix = dest + ((ptrdiff_t)numPix << 2);
// no mmx version // no mmx version
uint blendFact = (uint) factor; uint blendFact = (uint) factor;
uint invblendFact = 256 - blendFact; uint invblendFact = 256 - blendFact;

@ -215,7 +215,7 @@ void CCDBNodeBranch::init( xmlNodePtr node, IProgressCallback &progressCallBack,
else else
{ {
if (!_Nodes.empty()) if (!_Nodes.empty())
for ( _IdBits=1; _Nodes.size() > unsigned(1<<_IdBits) ; _IdBits++ ) {} for ( _IdBits=1; _Nodes.size() > ((size_t)1 <<_IdBits) ; _IdBits++ ) {}
else else
_IdBits = 0; _IdBits = 0;
} }

@ -807,6 +807,8 @@ public:
DWORD symSize = 10000; DWORD symSize = 10000;
PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize); PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize);
if (!sym) return str;
::ZeroMemory (sym, symSize); ::ZeroMemory (sym, symSize);
sym->SizeOfStruct = symSize; sym->SizeOfStruct = symSize;
sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL); sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL);

@ -773,7 +773,7 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT
case Exponent: case Exponent:
{ {
int exponent; int exponent;
frexp( arg0, &exponent); (void)frexp( arg0, &exponent);
value = (double)exponent; value = (double)exponent;
} }
break; break;
@ -1032,13 +1032,13 @@ CEvalNumExpr::TReturnState CEvalNumExpr::evalExpression (double &finalResult, TT
v0 -= v1; v0 -= v1;
break; break;
case ULeftShift: case ULeftShift:
v0 = (double)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5))); v0 = (double)(uint)(((uint)floor (v0 + 0.5))<<((uint)floor (v1 + 0.5)));
break; break;
case URightShift: case URightShift:
v0 = (double)(((uint)floor (v0 + 0.5))>>((uint)floor (v1 + 0.5))); v0 = (double)(((uint)floor (v0 + 0.5))>>((uint)floor (v1 + 0.5)));
break; break;
case SLeftShift: case SLeftShift:
v0 = (double)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5))); v0 = (double)(sint)(((sint)floor (v0 + 0.5))<<((sint)floor (v1 + 0.5)));
break; break;
case SRightShift: case SRightShift:
v0 = (double)(((sint)floor (v0 + 0.5))>>((sint)floor (v1 + 0.5))); v0 = (double)(((sint)floor (v0 + 0.5))>>((sint)floor (v1 + 0.5)));

@ -339,21 +339,25 @@ std::string CI18N::getSystemLanguageCode ()
typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName); typedef int (WINAPI* GetUserDefaultLocaleNamePtr)(LPWSTR lpLocaleName, int cchLocaleName);
// get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary // get pointer on GetUserDefaultLocaleName, kernel32.dll is always in memory so no need to call LoadLibrary
GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(GetModuleHandleA("kernel32.dll"), "GetUserDefaultLocaleName"); HMODULE hKernel32 = GetModuleHandleA("kernel32.dll");
if (hKernel32)
// only use it if found
if (nlGetUserDefaultLocaleName)
{ {
// get user locale GetUserDefaultLocaleNamePtr nlGetUserDefaultLocaleName = (GetUserDefaultLocaleNamePtr)GetProcAddress(hKernel32, "GetUserDefaultLocaleName");
wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
// convert wide string to std::string // only use it if found
std::string lang = wideToUtf8(buffer); if (nlGetUserDefaultLocaleName)
{
// get user locale
wchar_t buffer[LOCALE_NAME_MAX_LENGTH];
sint res = nlGetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH);
// only keep 2 first characters // convert wide string to std::string
if (lang.size() > 1) std::string lang = wideToUtf8(buffer);
_SystemLanguageCode = lang.substr(0, 2);
// only keep 2 first characters
if (lang.size() > 1)
_SystemLanguageCode = lang.substr(0, 2);
}
} }
} }
#endif #endif

@ -58,6 +58,8 @@ static string getFuncInfo (DWORD_TYPE funcAddr, DWORD_TYPE stackAddr)
DWORD symSize = 10000; DWORD symSize = 10000;
PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize); PIMAGEHLP_SYMBOL sym = (PIMAGEHLP_SYMBOL) GlobalAlloc (GMEM_FIXED, symSize);
if (!sym) return str;
::ZeroMemory (sym, symSize); ::ZeroMemory (sym, symSize);
sym->SizeOfStruct = symSize; sym->SizeOfStruct = symSize;
sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL); sym->MaxNameLength = symSize - sizeof(IMAGEHLP_SYMBOL);

@ -60,22 +60,23 @@ CObjectArenaAllocator::~CObjectArenaAllocator()
void *CObjectArenaAllocator::alloc(uint size) void *CObjectArenaAllocator::alloc(uint size)
{ {
#ifdef NL_DEBUG #ifdef NL_DEBUG
if (_WantBreakOnAlloc) if (_WantBreakOnAlloc)
{
if (_AllocID == _BreakAllocID)
{ {
if (_AllocID == _BreakAllocID) nlassert(0);
{
nlassert(0);
}
} }
}
#endif #endif
if (size >= _MaxAllocSize) if (size >= _MaxAllocSize)
{ {
// use standard allocator // use standard allocator
nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT >= sizeof(uint)); nlctassert(NL_DEFAULT_MEMORY_ALIGNMENT >= sizeof(uint));
uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block uint8 *block = (uint8 *)aligned_malloc(NL_DEFAULT_MEMORY_ALIGNMENT + (ptrdiff_t)size, NL_DEFAULT_MEMORY_ALIGNMENT); //new uint8[size + sizeof(uint)]; // an additionnal uint is needed to store size of block
if (!block) return NULL; if (!block) throw std::bad_alloc();
#ifdef NL_DEBUG #ifdef NL_DEBUG
_MemBlockToAllocID[block] = _AllocID; _MemBlockToAllocID[block] = _AllocID;
++_AllocID;
#endif #endif
*(uint *) block = size; *(uint *) block = size;
return block + NL_DEFAULT_MEMORY_ALIGNMENT; return block + NL_DEFAULT_MEMORY_ALIGNMENT;
@ -87,16 +88,14 @@ void *CObjectArenaAllocator::alloc(uint size)
_ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + NL_DEFAULT_MEMORY_ALIGNMENT, _MaxAllocSize / size); // an additionnal uint is needed to store size of block _ObjectSizeToAllocator[entry] = new CFixedSizeAllocator(entry * _Granularity + NL_DEFAULT_MEMORY_ALIGNMENT, _MaxAllocSize / size); // an additionnal uint is needed to store size of block
} }
void *block = _ObjectSizeToAllocator[entry]->alloc(); void *block = _ObjectSizeToAllocator[entry]->alloc();
if (!block) throw std::bad_alloc();
nlassert(((uintptr_t)block % NL_DEFAULT_MEMORY_ALIGNMENT) == 0); nlassert(((uintptr_t)block % NL_DEFAULT_MEMORY_ALIGNMENT) == 0);
#ifdef NL_DEBUG #ifdef NL_DEBUG
if (block) _MemBlockToAllocID[block] = _AllocID;
{ ++_AllocID;
_MemBlockToAllocID[block] = _AllocID;
}
++_AllocID;
#endif #endif
*(uint *) block = size; *(uint *)block = size;
return (void *) ((uint8 *) block + NL_DEFAULT_MEMORY_ALIGNMENT); return (void *)((uint8 *)block + NL_DEFAULT_MEMORY_ALIGNMENT);
} }
// ***************************************************************************************************************** // *****************************************************************************************************************

@ -1341,10 +1341,13 @@ void CFileContainer::addSearchBigFile (const string &sBigFilename, bool recurse,
fclose(Handle); fclose(Handle);
return; return;
} }
if (fread (FileName, 1, nStringSize, Handle) != nStringSize) if (nStringSize)
{ {
fclose(Handle); if (fread(FileName, 1, nStringSize, Handle) != nStringSize)
return; {
fclose(Handle);
return;
}
} }
FileName[nStringSize] = 0; FileName[nStringSize] = 0;
uint32 nFileSize2; uint32 nFileSize2;

@ -173,23 +173,25 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text)
{ {
// create a lock on this buffer // create a lock on this buffer
void *hLock = GlobalLock(mem); void *hLock = GlobalLock(mem);
if (hLock)
{
// copy text to this buffer
if (isUnicode)
wcscpy((wchar_t *)hLock, (const wchar_t *)text.c_str());
else
strcpy((char *)hLock, text.toString().c_str());
// copy text to this buffer // unlock buffer
if (isUnicode) GlobalUnlock(mem);
wcscpy((wchar_t*)hLock, (const wchar_t*)text.c_str());
else
strcpy((char*)hLock, text.toString().c_str());
// unlock buffer
GlobalUnlock(mem);
// empty clipboard // empty clipboard
EmptyClipboard(); EmptyClipboard();
// set new data to clipboard in the right format // set new data to clipboard in the right format
SetClipboardData(isUnicode ? CF_UNICODETEXT:CF_TEXT, mem); SetClipboardData(isUnicode ? CF_UNICODETEXT : CF_TEXT, mem);
res = true; res = true;
}
} }
CloseClipboard(); CloseClipboard();

@ -209,11 +209,11 @@ void CWinThread::start ()
ThreadHandle = (void *) ::CreateThread (NULL, 0, ProxyFunc, this, 0, (DWORD *)&ThreadId); ThreadHandle = (void *) ::CreateThread (NULL, 0, ProxyFunc, this, 0, (DWORD *)&ThreadId);
// nldebug("NLMISC: thread %x started for runnable '%x'", typeid( Runnable ).name()); // nldebug("NLMISC: thread %x started for runnable '%x'", typeid( Runnable ).name());
// OutputDebugString(toString(NL_LOC_MSG " NLMISC: thread %x started for runnable '%s'\n", ThreadId, typeid( *Runnable ).name()).c_str()); // OutputDebugString(toString(NL_LOC_MSG " NLMISC: thread %x started for runnable '%s'\n", ThreadId, typeid( *Runnable ).name()).c_str());
SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost
if (ThreadHandle == NULL) if (ThreadHandle == NULL)
{ {
throw EThread ( "Cannot create new thread" ); throw EThread ( "Cannot create new thread" );
} }
SetThreadPriorityBoost (ThreadHandle, TRUE); // FALSE == Enable Priority Boost
_SuspendCount = 0; _SuspendCount = 0;
} }

@ -1230,11 +1230,13 @@ class CHandlerEnterTell : public IActionHandler
{ {
CGroupContainer *pGC = pCGW->createFreeTeller(receiver); CGroupContainer *pGC = pCGW->createFreeTeller(receiver);
if (pGC != NULL) if (pGC != NULL)
pGC->setActive(true);
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(pGC->getGroup("eb"));
if (eb)
{ {
CWidgetManager::getInstance()->setCaptureKeyboard(eb); pGC->setActive(true);
CGroupEditBox *eb = dynamic_cast<CGroupEditBox *>(pGC->getGroup("eb"));
if (eb)
{
CWidgetManager::getInstance()->setCaptureKeyboard(eb);
}
} }
} }
} }

@ -956,6 +956,7 @@ void CContinent::unselect()
// Setup the Root scene. // Setup the Root scene.
if (BackgroundIG) if (BackgroundIG)
{ {
nlassert(SceneRoot);
BackgroundIG->removeFromScene (*SceneRoot); BackgroundIG->removeFromScene (*SceneRoot);
SceneRoot->deleteInstanceGroup (BackgroundIG); SceneRoot->deleteInstanceGroup (BackgroundIG);
BackgroundIG = NULL; BackgroundIG = NULL;

@ -101,7 +101,7 @@ bool CForageSourceCL::build( const CEntitySheet *sheet )
const CForageSourceSheet *forageSourceSheet = dynamic_cast<const CForageSourceSheet*>(sheet); const CForageSourceSheet *forageSourceSheet = dynamic_cast<const CForageSourceSheet*>(sheet);
if ( ! forageSourceSheet ) if ( ! forageSourceSheet )
{ {
nlwarning( "Bad sheet %s for forage source", sheet->Id.toString().c_str() ); nlwarning( "Bad sheet %s for forage source", sheet ? sheet->Id.toString().c_str() : "NULL" );
return false; return false;
} }
if ( ! setFx( forageSourceSheet->FxFilename ) ) if ( ! setFx( forageSourceSheet->FxFilename ) )

@ -75,7 +75,7 @@ bool CFxCL::build( const CEntitySheet *sheet )
if ( (! _FXSheet) || (_FXSheet->PSList.empty()) ) if ( (! _FXSheet) || (_FXSheet->PSList.empty()) )
{ {
_BadBuild = true; _BadBuild = true;
nlwarning( "Bad sheet %s for fx", sheet->Id.toString().c_str() ); nlwarning( "Bad sheet %s for fx", sheet ? sheet->Id.toString().c_str() : "NULL" );
return false; return false;
} }

@ -1334,7 +1334,7 @@ class CSelectItemSheet : public IActionHandler
// check if user has the level to use the item (applies to item & plans) // check if user has the level to use the item (applies to item & plans)
if (ctrlSheet->getSheetCategory() == CDBCtrlSheet::Item) if (ctrlSheet->getSheetCategory() == CDBCtrlSheet::Item)
{ {
if (csg->getName() == "buy_selection") if (csg && csg->getName() == "buy_selection")
{ {
const CItemSheet *is = ctrlSheet->asItemSheet(); const CItemSheet *is = ctrlSheet->asItemSheet();
if (is) if (is)

@ -1191,57 +1191,60 @@ public:
if( pPM->avoidCyclicForPhrase(phraseCom) ) if( pPM->avoidCyclicForPhrase(phraseCom) )
cyclic= false; cyclic= false;
// **** Launch the cast if (UserEntity)
// Cast only if their is a target, or if it is not a combat action
CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot());
if(target || !rootBrick->isCombat())
{ {
// combat (may moveTo before) ? // **** Launch the cast
if(rootBrick->isCombat()) // Cast only if their is a target, or if it is not a combat action
CEntityCL *target = EntitiesMngr.entity(UserEntity->targetSlot());
if (target || !rootBrick->isCombat())
{ {
if( !UserEntity->canEngageCombat() ) // combat (may moveTo before) ?
return; if (rootBrick->isCombat())
{
if (!UserEntity->canEngageCombat())
return;
UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic); UserEntity->executeCombatWithPhrase(target, memoryLine, memoryIndex, cyclic);
} }
// else can cast soon! // else can cast soon!
else if ( rootBrick->isForageExtraction() && (! UserEntity->isRiding()) ) // if mounted, send directly to server (without moving) to receive the error message else if (rootBrick->isForageExtraction() && (!UserEntity->isRiding())) // if mounted, send directly to server (without moving) to receive the error message
{ {
// Yoyo: TEMP if a target selected, must be a forage source // Yoyo: TEMP if a target selected, must be a forage source
if(!target || target->isForageSource()) if (!target || target->isForageSource())
{
// Cancel any follow
UserEntity->disableFollow();
// reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called)
// VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
UserEntity->resetAnyMoveTo();
// Move to targetted source
if (target)
UserEntity->moveToExtractionPhrase(target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic);
// start client execution
pPM->clientExecute(memoryLine, memoryIndex, cyclic);
if (!target)
{
// inform Server of phrase cast
pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
}
}
}
else
{ {
// Cancel any follow // Cancel any moveTo(), because don't want to continue reaching the prec entity
UserEntity->disableFollow();
// reset any moveTo also (if target==NULL, moveToExtractionPhrase() and therefore resetAnyMoveTo() not called)
// VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called) // VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
UserEntity->resetAnyMoveTo(); UserEntity->resetAnyMoveTo();
// Move to targetted source // start client execution: NB: start client execution even if it
if ( target )
UserEntity->moveToExtractionPhrase( target->slot(), MaxExtractionDistance, memoryLine, memoryIndex, cyclic );
// start client execution
pPM->clientExecute(memoryLine, memoryIndex, cyclic); pPM->clientExecute(memoryLine, memoryIndex, cyclic);
if ( ! target ) // inform Server of phrase cast
{ pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
// inform Server of phrase cast
pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
}
} }
} }
else
{
// Cancel any moveTo(), because don't want to continue reaching the prec entity
// VERY important if previous MoveTo was a SPhrase MoveTo (because cancelClientExecute() must be called)
UserEntity->resetAnyMoveTo();
// start client execution: NB: start client execution even if it
pPM->clientExecute(memoryLine, memoryIndex, cyclic);
// inform Server of phrase cast
pPM->sendExecuteToServer(memoryLine, memoryIndex, cyclic);
}
} }
} }
} }

@ -475,7 +475,7 @@ bool CDBGroupListSheetTrade::CSheetChildTrade::isSheetValid(CDBGroupListSheetTex
if ((pIS != NULL) && (!pIS->DropOrSell)) if ((pIS != NULL) && (!pIS->DropOrSell))
return false; return false;
// test if this whole family of items can be sold // test if this whole family of items can be sold
if( !ITEMFAMILY::isSellableByPlayer(pIS->Family) ) if((pIS != NULL) && !ITEMFAMILY::isSellableByPlayer(pIS->Family) )
return false; return false;
} }

@ -2980,8 +2980,8 @@ void CInterfaceManager::log(const ucstring &str, const std::string &cat)
{ {
const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8(); const string finalString = string(NLMISC::IDisplayer::dateToHumanString()) + " (" + NLMISC::toUpper(cat) + ") * " + str.toUtf8();
fprintf(f, "%s\n", finalString.c_str()); fprintf(f, "%s\n", finalString.c_str());
fclose(f);
} }
fclose(f);
} }
} }

@ -3576,13 +3576,12 @@ void CSPhraseManager::updatePhraseProgressionDB()
break; break;
} }
} }
}
// if show, but only if full learnt, skip it if not fully learnt // if show, but only if full learnt, skip it if not fully learnt
if(phrase->ShowInAPOnlyIfLearnt && !known) if (phrase->ShowInAPOnlyIfLearnt && !known)
{ {
continue; continue;
}
} }

@ -98,7 +98,7 @@ protected:
{ {
CGroupMap *gm = CTool::getWorldMap(); CGroupMap *gm = CTool::getWorldMap();
if (!gm) dest = CVector::Null; if (!gm) dest = CVector::Null;
gm->worldToWindow(dest, src); else gm->worldToWindow(dest, src);
} }
}; };

@ -2227,6 +2227,7 @@ void CClientEditionModule::addToSaveList(const std::string& filename, const std:
if (!ok) if (!ok)
{ {
delete sv; delete sv;
return;
} }
else else
{ {

@ -6302,7 +6302,7 @@ CInstance *CEditor::getInstanceUnderPos(float x, float y, float distSelection, b
objectSelected= precInstanceUnderPos->getDisplayerVisual(); objectSelected= precInstanceUnderPos->getDisplayerVisual();
} }
if (objectSelected->getSelectionType() == ISelectableObject::GroundProjected) if (objectSelected && objectSelected->getSelectionType() == ISelectableObject::GroundProjected)
{ {
if (borderSelected && borderSelected != objectSelected) if (borderSelected && borderSelected != objectSelected)
{ {

@ -202,7 +202,7 @@ CCtrlPolygon *CPrimRender::newCtrlPolygon() const
{ {
CGroupMap *gm = CTool::getWorldMap(); CGroupMap *gm = CTool::getWorldMap();
if (!gm) dest = CVector::Null; if (!gm) dest = CVector::Null;
gm->worldToWindow(dest, src); else gm->worldToWindow(dest, src);
} }
}; };
CViewBase::TCtorParam param; CViewBase::TCtorParam param;

@ -204,7 +204,7 @@ CTimedFXManager::TFXGroupHandle CTimedFXManager::add(const std::vector<CTimedFX>
//sint32 debugDay; //sint32 debugDay;
if (!(fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::AlwaysStarted)) if (!(fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::AlwaysStarted))
{ {
if (fi.FXSheet->Mode == CSeasonFXSheet::Spawn) if (fi.FXSheet && fi.FXSheet->Mode == CSeasonFXSheet::Spawn)
{ {
// compute next spawn date // compute next spawn date
float cycleLength = fi.FXSheet ? fi.FXSheet->CycleDuration : _DayLength; float cycleLength = fi.FXSheet ? fi.FXSheet->CycleDuration : _DayLength;

@ -37,7 +37,7 @@ CWeatherFunction::CWeatherFunction()
void CWeatherFunction::buildFromSheet(const CWeatherFunctionSheet &sheet, const CWeatherManager &wm) void CWeatherFunction::buildFromSheet(const CWeatherFunctionSheet &sheet, const CWeatherManager &wm)
{ {
// copy common part of objects (parameters) // copy common part of objects (parameters)
*static_cast<CWeatherFunctionParameters *>(this) = *static_cast<const CWeatherFunctionParameters *>(&sheet); static_cast<CWeatherFunctionParameters &>(*this) = static_cast<const CWeatherFunctionParameters &>(sheet);
// get pointer on the setup from their names // get pointer on the setup from their names
_WeatherSetups.resize(sheet.SetupNames.size()); _WeatherSetups.resize(sheet.SetupNames.size());
nlassert(sheet.SetupWeights.size() == sheet.SetupNames.size()); nlassert(sheet.SetupWeights.size() == sheet.SetupNames.size());

Loading…
Cancel
Save