Fix most (according to warnings) remaining 64bit issues in tool code

rvGEWindowWrapper is still TODO - it's not as straightforward, because
it insists on storing a pointer in an idWinVar (using idWinInt), but there
is no idWinVar type for pointers
This commit is contained in:
Daniel Gibson 2021-05-08 05:43:52 +02:00
parent bd37c3f91a
commit 5dc9b69374
9 changed files with 47 additions and 27 deletions

View file

@ -569,10 +569,18 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
return typeSize; return typeSize;
} }
#if D3_SIZEOFPTR == 4
const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdUL;
#elif D3_SIZEOFPTR == 8
const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdcdcdcdcdULL;
#else
#error "Unexpected pointer size"
#endif
// if this is a pointer // if this is a pointer
isPointer = 0; isPointer = 0;
for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) {
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { if ( varPtr == (void*)uninitPtr || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) {
common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" );
return typeSize; return typeSize;
} }

View file

@ -570,9 +570,18 @@ int idTypeInfoTools::WriteVariable_r( const void *varPtr, const char *varName, c
} }
// if this is a pointer // if this is a pointer
#if D3_SIZEOFPTR == 4
const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdUL;
#elif D3_SIZEOFPTR == 8
const uintptr_t uninitPtr = (uintptr_t)0xcdcdcdcdcdcdcdcdULL;
#else
#error "Unexpected pointer size"
#endif
isPointer = 0; isPointer = 0;
for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) { for ( i = typeString.Length(); i > 0 && typeString[i - 1] == '*'; i -= 2 ) {
if ( varPtr == (void *)0xcdcdcdcd || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) { if ( varPtr == (void*)uninitPtr || ( varPtr != NULL && *((unsigned int *)varPtr) == 0xcdcdcdcd ) ) {
common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" ); common->Warning( "%s%s::%s%s references uninitialized memory", prefix, scope, varName, "" );
return typeSize; return typeSize;
} }

View file

@ -75,7 +75,8 @@ bool rvPropertyGrid::Create ( HWND parent, int id, int style )
mStyle = style; mStyle = style;
// Create the List view // Create the List view
mWindow = CreateWindowEx ( 0, "LISTBOX", "", WS_VSCROLL|WS_CHILD|WS_VISIBLE|LBS_OWNERDRAWFIXED|LBS_NOINTEGRALHEIGHT|LBS_NOTIFY, 0, 0, 0, 0, parent, (HMENU)id, win32.hInstance, 0 ); const HMENU hmenuID = (HMENU)(intptr_t)id; // DG: apparently an int ID (instead of a handle/pointer) can be valid here, depending on window style
mWindow = CreateWindowEx ( 0, "LISTBOX", "", WS_VSCROLL|WS_CHILD|WS_VISIBLE|LBS_OWNERDRAWFIXED|LBS_NOINTEGRALHEIGHT|LBS_NOTIFY, 0, 0, 0, 0, parent, hmenuID, win32.hInstance, 0 );
mListWndProc = (WNDPROC)GetWindowLongPtr ( mWindow, GWLP_WNDPROC ); mListWndProc = (WNDPROC)GetWindowLongPtr ( mWindow, GWLP_WNDPROC );
SetWindowLongPtr ( mWindow, GWLP_USERDATA, (LONG_PTR)this ); SetWindowLongPtr ( mWindow, GWLP_USERDATA, (LONG_PTR)this );
SetWindowLongPtr ( mWindow, GWLP_WNDPROC, (LONG_PTR)WndProc ); SetWindowLongPtr ( mWindow, GWLP_WNDPROC, (LONG_PTR)WndProc );
@ -198,7 +199,7 @@ void rvPropertyGrid::FinishEdit ( void )
nmpg.mName = item->mName; nmpg.mName = item->mName;
nmpg.mValue = value; nmpg.mValue = value;
if ( !SendMessage ( GetParent ( mWindow ), WM_NOTIFY, 0, (LONG)&nmpg ) ) if ( !SendMessage ( GetParent ( mWindow ), WM_NOTIFY, 0, (LPARAM)&nmpg ) )
{ {
mState = STATE_EDIT; mState = STATE_EDIT;
SetFocus ( mEdit ); SetFocus ( mEdit );
@ -281,7 +282,7 @@ int rvPropertyGrid::AddItem ( const char* name, const char* value, EItemType typ
insert = SendMessage(mWindow,LB_GETCOUNT,0,0) - ((mStyle&PGS_ALLOWINSERT)?1:0); insert = SendMessage(mWindow,LB_GETCOUNT,0,0) - ((mStyle&PGS_ALLOWINSERT)?1:0);
return SendMessage ( mWindow, LB_INSERTSTRING, insert, (LONG)item ); return SendMessage ( mWindow, LB_INSERTSTRING, insert, (LPARAM)item );
} }
/* /*
@ -330,7 +331,7 @@ void rvPropertyGrid::RemoveAllItems ( void )
item = new rvPropertyGridItem; item = new rvPropertyGridItem;
item->mName = ""; item->mName = "";
item->mValue = ""; item->mValue = "";
SendMessage ( mWindow, LB_ADDSTRING, 0, (LONG)item ); SendMessage ( mWindow, LB_ADDSTRING, 0, (LPARAM)item );
} }
} }
@ -462,7 +463,7 @@ LRESULT CALLBACK rvPropertyGrid::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, L
} }
case WM_COMMAND: case WM_COMMAND:
if ( lParam == (long)grid->mEdit ) if ( lParam == (LPARAM)grid->mEdit )
{ {
if ( HIWORD(wParam) == EN_KILLFOCUS ) if ( HIWORD(wParam) == EN_KILLFOCUS )
{ {
@ -545,7 +546,7 @@ LRESULT CALLBACK rvPropertyGrid::WndProc ( HWND hWnd, UINT msg, WPARAM wParam, L
ScreenToClient ( hWnd, &point ); ScreenToClient ( hWnd, &point );
if ( point.x >= grid->mSplitter - 2 && point.x <= grid->mSplitter + 2 ) if ( point.x >= grid->mSplitter - 2 && point.x <= grid->mSplitter + 2 )
{ {
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZEWE))); SetCursor ( LoadCursor ( NULL, IDC_SIZEWE));
return TRUE; return TRUE;
} }
break; break;

View file

@ -572,10 +572,10 @@ int rvGEApp::HandleCommand ( WPARAM wParam, LPARAM lParam )
break; break;
case ID_GUIED_TOOLS_RELOADMATERIALS: case ID_GUIED_TOOLS_RELOADMATERIALS:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT) ) ); SetCursor ( LoadCursor ( NULL, IDC_WAIT ) );
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadImages\n" ); cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadImages\n" );
cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadMaterials\n" ); cmdSystem->BufferCommandText( CMD_EXEC_NOW, "reloadMaterials\n" );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
break; break;
case ID_GUIED_EDIT_COPY: case ID_GUIED_EDIT_COPY:
@ -1191,7 +1191,7 @@ bool rvGEApp::OpenFile ( const char* filename )
} }
} }
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT ) ) ); SetCursor ( LoadCursor ( NULL, IDC_WAIT ) );
// Setup the default error. // Setup the default error.
error = va("Failed to parse '%s'", filename ); error = va("Failed to parse '%s'", filename );
@ -1224,7 +1224,7 @@ bool rvGEApp::OpenFile ( const char* filename )
MessageBox ( error, MB_OK|MB_ICONERROR ); MessageBox ( error, MB_OK|MB_ICONERROR );
} }
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
return result;; return result;;
} }

View file

@ -69,6 +69,7 @@ rvGEWindowWrapper::rvGEWindowWrapper( idWindow *window,EWindowType type ) {
// Attach the wrapper to the window by adding a defined variable // Attach the wrapper to the window by adding a defined variable
// with the wrappers pointer stuffed into an integer // with the wrappers pointer stuffed into an integer
// FIXME: WTF is this about?!
idWinInt *var = new idWinInt(); idWinInt *var = new idWinInt();
int x = (int)this; int x = (int)this;
*var = x; *var = x;
@ -90,6 +91,7 @@ rvGEWindowWrapper * rvGEWindowWrapper::GetWrapper( idWindow *window ) {
idWinInt *var; idWinInt *var;
var = dynamic_cast< idWinInt*>(window->GetWinVarByName("guied_wrapper")); var = dynamic_cast< idWinInt*>(window->GetWinVarByName("guied_wrapper"));
return var ? ((rvGEWindowWrapper *) (int) (*var)) : NULL; return var ? ((rvGEWindowWrapper *) (int) (*var)) : NULL;
// FIXME: this won't work!
} }
/* /*

View file

@ -580,31 +580,31 @@ void rvGEWorkspace::UpdateCursor ( rvGESelectionMgr::EHitTest type )
switch ( type ) switch ( type )
{ {
case rvGESelectionMgr::HT_SELECT: case rvGESelectionMgr::HT_SELECT:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
break; break;
case rvGESelectionMgr::HT_MOVE: case rvGESelectionMgr::HT_MOVE:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZEALL) ) ); SetCursor ( LoadCursor ( NULL, IDC_SIZEALL ) );
break; break;
case rvGESelectionMgr::HT_SIZE_LEFT: case rvGESelectionMgr::HT_SIZE_LEFT:
case rvGESelectionMgr::HT_SIZE_RIGHT: case rvGESelectionMgr::HT_SIZE_RIGHT:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZEWE ) ) ); SetCursor ( LoadCursor ( NULL, IDC_SIZEWE ) );
break; break;
case rvGESelectionMgr::HT_SIZE_TOP: case rvGESelectionMgr::HT_SIZE_TOP:
case rvGESelectionMgr::HT_SIZE_BOTTOM: case rvGESelectionMgr::HT_SIZE_BOTTOM:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENS ) ) ); SetCursor ( LoadCursor ( NULL, IDC_SIZENS ) );
break; break;
case rvGESelectionMgr::HT_SIZE_TOPRIGHT: case rvGESelectionMgr::HT_SIZE_TOPRIGHT:
case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT: case rvGESelectionMgr::HT_SIZE_BOTTOMLEFT:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENESW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_SIZENESW ) );
break; break;
case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT: case rvGESelectionMgr::HT_SIZE_BOTTOMRIGHT:
case rvGESelectionMgr::HT_SIZE_TOPLEFT: case rvGESelectionMgr::HT_SIZE_TOPLEFT:
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_SIZENWSE ) ) ); SetCursor ( LoadCursor ( NULL, IDC_SIZENWSE ) );
break; break;
} }
} }
@ -627,7 +627,7 @@ void rvGEWorkspace::UpdateCursor ( float x, float y )
} }
else else
{ {
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
} }
} }

View file

@ -45,7 +45,7 @@ bool rvGEWorkspace::SaveFile ( const char* filename )
idFile* file; idFile* file;
idWindow* window; idWindow* window;
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_WAIT ) ) ); SetCursor ( LoadCursor ( NULL, IDC_WAIT ) );
mFilename = filename; mFilename = filename;
@ -61,7 +61,7 @@ bool rvGEWorkspace::SaveFile ( const char* filename )
file = fileSystem->OpenFileWrite(tempfile); file = fileSystem->OpenFileWrite(tempfile);
if ( !file ) if ( !file )
{ {
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
return false; return false;
} }
@ -74,7 +74,7 @@ bool rvGEWorkspace::SaveFile ( const char* filename )
if ( !CopyFile ( ospath, filename, FALSE ) ) if ( !CopyFile ( ospath, filename, FALSE ) )
{ {
DeleteFile ( ospath ); DeleteFile ( ospath );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
return false; return false;
} }
@ -85,7 +85,7 @@ bool rvGEWorkspace::SaveFile ( const char* filename )
mNew = false; mNew = false;
UpdateTitle ( ); UpdateTitle ( );
SetCursor ( LoadCursor ( NULL, MAKEINTRESOURCE(IDC_ARROW ) ) ); SetCursor ( LoadCursor ( NULL, IDC_ARROW ) );
return true; return true;
} }

View file

@ -146,7 +146,7 @@ void CEntityListDlg::OnLbnSelchangeListEntities()
int count = pEntity->epairs.GetNumKeyVals(); int count = pEntity->epairs.GetNumKeyVals();
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int nParent = m_lstEntity.InsertItem(0, pEntity->epairs.GetKeyVal(i)->GetKey()); int nParent = m_lstEntity.InsertItem(0, pEntity->epairs.GetKeyVal(i)->GetKey());
m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEntity->epairs.GetKeyVal(i)->GetValue(), 0, 0, 0, reinterpret_cast<DWORD>(pEntity)); m_lstEntity.SetItem(nParent, 1, LVIF_TEXT, pEntity->epairs.GetKeyVal(i)->GetValue(), 0, 0, 0, (LPARAM)(pEntity));
} }
} }
} }

View file

@ -91,9 +91,9 @@ BOOL CMapInfo::OnInitDialog()
CMapStringToPtr mapEntity; CMapStringToPtr mapEntity;
int nValue = 0; intptr_t nValue = 0;
for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next) for (entity_t* pEntity=entities.next ; pEntity != &entities ; pEntity=pEntity->next)
{ {
m_nTotalEntities++; m_nTotalEntities++;
nValue = 0; nValue = 0;
mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(nValue)); mapEntity.Lookup(pEntity->eclass->name, reinterpret_cast<void*&>(nValue));