diff --git a/Engine/source/T3D/gameBase/gameConnection.cpp b/Engine/source/T3D/gameBase/gameConnection.cpp index ccc31ff71..4357ced06 100644 --- a/Engine/source/T3D/gameBase/gameConnection.cpp +++ b/Engine/source/T3D/gameBase/gameConnection.cpp @@ -208,6 +208,8 @@ GameConnection::GameConnection() mAIControlled = false; + mLastPacketTime = 0; + mDisconnectReason[0] = 0; //blackout vars diff --git a/Engine/source/T3D/shapeImage.cpp b/Engine/source/T3D/shapeImage.cpp index 34485bb02..e4752019c 100644 --- a/Engine/source/T3D/shapeImage.cpp +++ b/Engine/source/T3D/shapeImage.cpp @@ -3339,6 +3339,6 @@ void ShapeBase::ejectShellCasing( U32 imageSlot ) if (!casing->registerObject()) delete casing; - - casing->init( shellPos, shellVel ); + else + casing->init( shellPos, shellVel ); } diff --git a/Engine/source/console/compiler.cpp b/Engine/source/console/compiler.cpp index 49125389f..fd871c036 100644 --- a/Engine/source/console/compiler.cpp +++ b/Engine/source/console/compiler.cpp @@ -400,7 +400,7 @@ void CodeStream::reset() { CodeData *next = itr->next; dFree(itr->data); - dFree(itr); + delete(itr); itr = next; } diff --git a/Engine/source/console/consoleInternal.cpp b/Engine/source/console/consoleInternal.cpp index e1fbce1ec..62c354dcb 100644 --- a/Engine/source/console/consoleInternal.cpp +++ b/Engine/source/console/consoleInternal.cpp @@ -882,7 +882,7 @@ void Namespace::Entry::clear() // Clean up usage strings generated for script functions. if( ( mType == Namespace::Entry::ConsoleFunctionType ) && mUsage ) { - delete mUsage; + dFree(mUsage); mUsage = NULL; } } @@ -908,7 +908,7 @@ Namespace::~Namespace() clearEntries(); if( mUsage && mCleanUpUsage ) { - delete mUsage; + dFree(mUsage); mUsage = NULL; mCleanUpUsage = false; } diff --git a/Engine/source/core/dnet.cpp b/Engine/source/core/dnet.cpp index ea32c4cb5..a5fe53f6c 100644 --- a/Engine/source/core/dnet.cpp +++ b/Engine/source/core/dnet.cpp @@ -66,6 +66,7 @@ ConnectionProtocol::ConnectionProtocol() mLastSendSeq = 0; // start sending at 1 mAckMask = 0; mLastRecvAckAck = 0; + mConnectionEstablished = false; } void ConnectionProtocol::buildSendPacketHeader(BitStream *stream, S32 packetType) { diff --git a/Engine/source/core/strings/unicode.cpp b/Engine/source/core/strings/unicode.cpp index b6c915e05..0dee6f3ef 100644 --- a/Engine/source/core/strings/unicode.cpp +++ b/Engine/source/core/strings/unicode.cpp @@ -601,10 +601,13 @@ bool chompUTF8BOM( const char *inString, char **outStringPtr ) { *outStringPtr = const_cast( inString ); - U8 bom[4]; - dMemcpy( bom, inString, 4 ); - - bool valid = isValidUTF8BOM( bom ); + bool valid = false; + if (inString[0] && inString[1] && inString[2]) + { + U8 bom[4]; + dMemcpy(bom, inString, 4); + valid = isValidUTF8BOM(bom); + } // This is hackey, but I am not sure the best way to do it at the present. // The only valid BOM is a UTF8 BOM, which is 3 bytes, even though we read diff --git a/Engine/source/core/util/str.cpp b/Engine/source/core/util/str.cpp index 62a819812..3f4f3d8f9 100644 --- a/Engine/source/core/util/str.cpp +++ b/Engine/source/core/util/str.cpp @@ -495,7 +495,7 @@ DefineConsoleFunction( dumpStringMemStats, void, (), , "()" void* String::StringData::operator new( size_t size, U32 len ) { AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" ); - StringData *str = reinterpret_cast( dMalloc( size + len * sizeof(StringChar) ) ); + StringData *str = static_cast( dMalloc( size + len * sizeof(StringChar) ) ); str->mLength = len; @@ -523,7 +523,7 @@ void String::StringData::operator delete(void *ptr) void* String::StringData::operator new( size_t size, U32 len, DataChunker& chunker ) { AssertFatal( len != 0, "String::StringData::operator new() - string must not be empty" ); - StringData *str = reinterpret_cast( chunker.alloc( size + len * sizeof(StringChar) ) ); + StringData *str = static_cast( chunker.alloc( size + len * sizeof(StringChar) ) ); str->mLength = len; diff --git a/Engine/source/environment/decalRoad.cpp b/Engine/source/environment/decalRoad.cpp index 7bd240095..3cde83149 100644 --- a/Engine/source/environment/decalRoad.cpp +++ b/Engine/source/environment/decalRoad.cpp @@ -155,8 +155,8 @@ void DecalRoadNodeEvent::padListToSize() newlist->mPositions.merge(list->mPositions); newlist->mWidths.merge(list->mWidths); - mNodeList = newlist; delete list; + mNodeList = list = newlist; } // Pad our list end? @@ -1726,4 +1726,4 @@ DefineEngineMethod( DecalRoad, postApply, void, (),, ) { object->inspectPostApply(); -} \ No newline at end of file +} diff --git a/Engine/source/environment/meshRoad.cpp b/Engine/source/environment/meshRoad.cpp index eaa627093..e395458f1 100644 --- a/Engine/source/environment/meshRoad.cpp +++ b/Engine/source/environment/meshRoad.cpp @@ -203,8 +203,8 @@ void MeshRoadNodeEvent::padListToSize() newlist->mDepths.merge(list->mDepths); newlist->mNormals.merge(list->mNormals); - mNodeList = newlist; delete list; + mNodeList = list = newlist; } // Pad our list end? diff --git a/Engine/source/environment/river.cpp b/Engine/source/environment/river.cpp index 59a16230f..bf9b9671f 100644 --- a/Engine/source/environment/river.cpp +++ b/Engine/source/environment/river.cpp @@ -227,8 +227,8 @@ void RiverNodeEvent::padListToSize() newlist->mDepths.merge(list->mDepths); newlist->mNormals.merge(list->mNormals); - mNodeList = newlist; delete list; + mNodeList = list = newlist; } // Pad our list end? diff --git a/Engine/source/gfx/gfxDevice.cpp b/Engine/source/gfx/gfxDevice.cpp index 47f528d94..35d86d827 100644 --- a/Engine/source/gfx/gfxDevice.cpp +++ b/Engine/source/gfx/gfxDevice.cpp @@ -279,6 +279,7 @@ GFXDevice::~GFXDevice() #endif SAFE_DELETE( mTextureManager ); + SAFE_DELETE( mFrameTime ); // Clear out our state block references mCurrentStateBlocks.clear(); diff --git a/Engine/source/gui/containers/guiRolloutCtrl.cpp b/Engine/source/gui/containers/guiRolloutCtrl.cpp index 9044a1aaf..919846b66 100644 --- a/Engine/source/gui/containers/guiRolloutCtrl.cpp +++ b/Engine/source/gui/containers/guiRolloutCtrl.cpp @@ -56,6 +56,10 @@ IMPLEMENT_CALLBACK( GuiRolloutCtrl, onCollapsed, void, (), (), //----------------------------------------------------------------------------- GuiRolloutCtrl::GuiRolloutCtrl() + : mHeader(0,0,0,0), + mExpanded(0,0,0,0), + mChildRect(0,0,0,0), + mMargin(0,0,0,0) { mExpanded.set(0,0,200,60); mCaption = StringTable->EmptyString(); @@ -70,6 +74,7 @@ GuiRolloutCtrl::GuiRolloutCtrl() mIsContainer = true; mCanCollapse = true; mAutoCollapseSiblings = false; + mHasTexture = false; // Make sure we receive our ticks. setProcessTicks(); } diff --git a/Engine/source/gui/containers/guiScrollCtrl.cpp b/Engine/source/gui/containers/guiScrollCtrl.cpp index c32e9e2a6..91e86a770 100644 --- a/Engine/source/gui/containers/guiScrollCtrl.cpp +++ b/Engine/source/gui/containers/guiScrollCtrl.cpp @@ -72,8 +72,9 @@ GuiScrollCtrl::GuiScrollCtrl() mAnimating( false ), mScrollAnimSpeed( -1 ), mScrollTargetPos( -1, -1 ), - mChildExt(0, 0), - mChildPos(0, 0) + mChildExt(0, 0), + mChildPos(0, 0), + mBaseThumbSize(0) { mIsContainer = true; setExtent(200,200); diff --git a/Engine/source/gui/containers/guiWindowCtrl.cpp b/Engine/source/gui/containers/guiWindowCtrl.cpp index 0132a75d6..e98c07652 100644 --- a/Engine/source/gui/containers/guiWindowCtrl.cpp +++ b/Engine/source/gui/containers/guiWindowCtrl.cpp @@ -98,10 +98,10 @@ GuiWindowCtrl::GuiWindowCtrl() mMouseMovingWin = false; mMouseResizeWidth = false; mMouseResizeHeight = false; - setExtent(100, 200); mMinimizeIndex = -1; mTabIndex = -1; mBitmapBounds = NULL; + setExtent(100, 200); RectI closeRect(80, 2, 16, 16); mCloseButton = closeRect; diff --git a/Engine/source/gui/core/guiCanvas.cpp b/Engine/source/gui/core/guiCanvas.cpp index bae2126c9..4dba87310 100644 --- a/Engine/source/gui/core/guiCanvas.cpp +++ b/Engine/source/gui/core/guiCanvas.cpp @@ -95,9 +95,11 @@ extern InputModifiers convertModifierBits(const U32 in); //----------------------------------------------------------------------------- GuiCanvas::GuiCanvas(): GuiControl(), + mCurUpdateRect(0, 0, 0, 0), mCursorEnabled(true), mForceMouseToGUI(false), mAlwaysHandleMouseButtons(false), + mCursorChanged(0), mClampTorqueCursor(true), mShowCursor(true), mLastCursorEnabled(false), @@ -121,6 +123,7 @@ GuiCanvas::GuiCanvas(): GuiControl(), mLeftMouseLast(false), mMiddleMouseLast(false), mRightMouseLast(false), + mMouseDownPoint(0.0f,0.0f), mPlatformWindow(NULL), mLastRenderMs(0), mDisplayWindow(true) diff --git a/Engine/source/main/main.cpp b/Engine/source/main/main.cpp index 9728f37ec..56bed4ceb 100644 --- a/Engine/source/main/main.cpp +++ b/Engine/source/main/main.cpp @@ -49,7 +49,7 @@ bool getDllName(std::wstring& dllName, const std::wstring suffix) return true; } -int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow) +int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCommandShow) { // Try to find the game DLL, which may have one of several file names. HMODULE hGame = NULL; @@ -75,10 +75,11 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL return -1; } + enum { errorSize = 4096 }; if (!hGame) { - wchar_t error[4096]; - _swprintf_l(error, sizeof(error), L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); + wchar_t error[errorSize]; + _swprintf_l(error, errorSize, L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING); return -1; } @@ -86,8 +87,8 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdL torque_winmain = (int (*)(HINSTANCE hInstance, HINSTANCE h, LPSTR lpszCmdLine, int nShow))GetProcAddress(hGame, "torque_winmain"); if (!torque_winmain) { - wchar_t error[4096]; - _swprintf_l(error, sizeof(error), L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); + wchar_t error[errorSize]; + _swprintf_l(error, errorSize, L"Missing torque_winmain export in game library: %s. Please make sure that it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str()); MessageBoxW(NULL, error, L"Error", MB_OK|MB_ICONWARNING); return -1; } diff --git a/Engine/source/materials/materialList.cpp b/Engine/source/materials/materialList.cpp index fbeab64f3..afdba4f54 100644 --- a/Engine/source/materials/materialList.cpp +++ b/Engine/source/materials/materialList.cpp @@ -263,8 +263,6 @@ void MaterialList::clearMatInstList() if (mMatInstList[i]) { BaseMatInstance* current = mMatInstList[i]; - delete current; - mMatInstList[i] = NULL; // ok, since ts material lists can remap difference indexes to the same object // we need to make sure that we don't delete the same memory twice. walk the @@ -272,6 +270,9 @@ void MaterialList::clearMatInstList() for (U32 j=0; jmMenu = mIsPopup ? CreatePopupMenu() : CreateMenu(); AssertFatal(mData->mMenu, "Unable to create menu"); - MENUINFO mi; + MENUINFO mi = { 0 }; mi.cbSize = sizeof(mi); mi.fMask = MIM_MENUDATA; mi.dwMenuData = (ULONG_PTR)this; @@ -178,7 +178,7 @@ S32 PopupMenu::insertItem(S32 pos, const char *title, const char* accelerator, c if(isAttached && pWindow == NULL) return -1; - MENUITEMINFOA mi; + MENUITEMINFOA mi = { 0 }; mi.cbSize = sizeof(mi); mi.fMask = MIIM_ID|MIIM_TYPE; mi.wID = (mData->mMenuID * PlatformPopupMenuData::PopupMenuIDRange) + mData->mLastID + 1; diff --git a/Engine/source/platformWin32/winWindow.cpp b/Engine/source/platformWin32/winWindow.cpp index b23bad41b..45119dbb4 100644 --- a/Engine/source/platformWin32/winWindow.cpp +++ b/Engine/source/platformWin32/winWindow.cpp @@ -352,19 +352,20 @@ S32 main(S32 argc, const char **argv) #include "app/mainLoop.h" -S32 PASCAL WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32) +S32 WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32) { Vector argv( __FILE__, __LINE__ ); - char moduleName[256]; + enum { moduleNameSize = 256 }; + char moduleName[moduleNameSize]; #ifdef TORQUE_UNICODE { - TCHAR buf[ 256 ]; - GetModuleFileNameW( NULL, buf, sizeof( buf ) ); - convertUTF16toUTF8( buf, moduleName, sizeof( moduleName ) ); + TCHAR buf[ moduleNameSize ]; + GetModuleFileNameW( NULL, buf, moduleNameSize ); + convertUTF16toUTF8( buf, moduleName, moduleNameSize ); } #else - GetModuleFileNameA(NULL, moduleName, sizeof(moduleName)); + GetModuleFileNameA(NULL, moduleName, moduleNameSize); #endif argv.push_back(moduleName); @@ -433,15 +434,16 @@ S32 torque_winmain( HINSTANCE hInstance, HINSTANCE, LPSTR lpszCmdLine, S32) { Vector argv( __FILE__, __LINE__ ); - char moduleName[256]; + enum { moduleNameSize = 256 }; + char moduleName[moduleNameSize]; #ifdef TORQUE_UNICODE - { - TCHAR buf[ 256 ]; - GetModuleFileNameW( NULL, buf, sizeof( buf ) ); - convertUTF16toUTF8( buf, moduleName, sizeof( moduleName ) ); -} + { + TCHAR buf[ moduleNameSize ]; + GetModuleFileNameW( NULL, buf, moduleNameSize ); + convertUTF16toUTF8( buf, moduleName, moduleNameSize ); + } #else - GetModuleFileNameA(NULL, moduleName, sizeof(moduleName)); + GetModuleFileNameA(NULL, moduleName, moduleNameSize); #endif argv.push_back(moduleName); @@ -657,4 +659,4 @@ DefineConsoleFunction( isKoreanBuild, bool, ( ), , "isKoreanBuild()") } return( result ); -} \ No newline at end of file +} diff --git a/Engine/source/scene/reflectionManager.cpp b/Engine/source/scene/reflectionManager.cpp index 2c86a700f..057c72c0a 100644 --- a/Engine/source/scene/reflectionManager.cpp +++ b/Engine/source/scene/reflectionManager.cpp @@ -83,7 +83,8 @@ F32 ReflectionManager::smRefractTexScale = 0.5f; ReflectionManager::ReflectionManager() : mUpdateRefract( true ), - mReflectFormat( GFXFormatR8G8B8A8 ) + mReflectFormat( GFXFormatR8G8B8A8 ), + mLastUpdateMs( 0 ) { mTimer = PlatformTimer::create(); diff --git a/Engine/source/scene/reflector.cpp b/Engine/source/scene/reflector.cpp index ab53c2bdd..a992456e2 100644 --- a/Engine/source/scene/reflector.cpp +++ b/Engine/source/scene/reflector.cpp @@ -179,6 +179,8 @@ ReflectorBase::ReflectorBase() mObject = NULL; mOcclusionQuery = GFX->createOcclusionQuery(); mQueryPending = false; + score = 0.0f; + lastUpdateMs = 0; } ReflectorBase::~ReflectorBase() diff --git a/Engine/source/sfx/openal/sfxALDevice.cpp b/Engine/source/sfx/openal/sfxALDevice.cpp index de065fa06..a620878a6 100644 --- a/Engine/source/sfx/openal/sfxALDevice.cpp +++ b/Engine/source/sfx/openal/sfxALDevice.cpp @@ -35,7 +35,8 @@ SFXALDevice::SFXALDevice( SFXProvider *provider, : Parent( name, provider, useHardware, maxBuffers ), mOpenAL( openal ), mDevice( NULL ), - mContext( NULL ) + mContext( NULL ), + mRolloffFactor( 1.0f ) { mMaxBuffers = getMax( maxBuffers, 8 ); diff --git a/Engine/source/sim/netConnection.cpp b/Engine/source/sim/netConnection.cpp index a34265e48..e882ef869 100644 --- a/Engine/source/sim/netConnection.cpp +++ b/Engine/source/sim/netConnection.cpp @@ -351,6 +351,7 @@ void NetConnection::setNetClassGroup(U32 grp) } NetConnection::NetConnection() + : mNetAddress() { mTranslateStrings = false; mConnectSequence = 0; diff --git a/Engine/source/ts/collada/colladaLights.cpp b/Engine/source/ts/collada/colladaLights.cpp index ff491d341..bed659285 100644 --- a/Engine/source/ts/collada/colladaLights.cpp +++ b/Engine/source/ts/collada/colladaLights.cpp @@ -129,8 +129,7 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup* Con::errorf(ConsoleLogEntry::General, "Failed to register light for \"%s\"", lightName.c_str()); delete pLight; } - - if (group) + else if (group) group->addObject(pLight); } diff --git a/Engine/source/util/settings.h b/Engine/source/util/settings.h index 2438504ac..10fe2305c 100644 --- a/Engine/source/util/settings.h +++ b/Engine/source/util/settings.h @@ -78,7 +78,10 @@ public: String mValue; bool mIsGroup; - SettingSaveNode(){}; + SettingSaveNode() + { + mIsGroup = false; + } SettingSaveNode(const String &name, bool isGroup = false) { mName = name; diff --git a/Engine/source/windowManager/platformWindow.h b/Engine/source/windowManager/platformWindow.h index ed4fbe27c..6db7ce423 100644 --- a/Engine/source/windowManager/platformWindow.h +++ b/Engine/source/windowManager/platformWindow.h @@ -98,17 +98,17 @@ protected: { mIsBackground = false; // This could be toggled to true to prefer performance. mMinimumSize.set(0,0); - mLockedSize.set(0,0); - mResizeLocked = false; + mLockedSize.set(0,0); + mResizeLocked = false; mEnableKeyboardTranslation = false; mEnableAccelerators = true; mCursorController = NULL; - // This controller maps window input (Mouse/Keyboard) to a generic input consumer - mWindowInputGenerator = new WindowInputGenerator( this ); mSuppressReset = false; - mOffscreenRender = false; mDisplayWindow = false; + + // This controller maps window input (Mouse/Keyboard) to a generic input consumer + mWindowInputGenerator = new WindowInputGenerator( this ); } public: @@ -509,4 +509,4 @@ protected: virtual void _setFullscreen(const bool fullScreen) {}; }; -#endif \ No newline at end of file +#endif