Skip to content

Commit

Permalink
CSFile Windows creation file mode fix (#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideRei authored Jan 31, 2024
1 parent a5d5714 commit 646b9d1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
10 changes: 7 additions & 3 deletions src/common/sphere_library/CSFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,13 +131,17 @@ bool CSFile::_Open( lpctstr ptcFilename, uint uiModeFlags )
dwShareMode = 0;

if ( uiModeFlags & OF_CREATE )
dwCreationDisposition = (OPEN_ALWAYS|CREATE_NEW);
dwCreationDisposition = CREATE_ALWAYS;
else
dwCreationDisposition = OPEN_EXISTING;

_fileDescriptor = CreateFile( ptcFilename, dwDesiredAccess, dwShareMode, nullptr, dwCreationDisposition, FILE_ATTRIBUTE_NORMAL, nullptr );
#else
_fileDescriptor = open( ptcFilename, uiModeFlags );
uint uiFilePermissions = 0;
if (uiModeFlags & OF_CREATE)
uiFilePermissions = (S_IRWXU | S_IRWXG | S_IRWXO); //777

_fileDescriptor = open( ptcFilename, uiModeFlags, uiFilePermissions);
#endif // _WIN32

return (_fileDescriptor != _kInvalidFD);
Expand Down Expand Up @@ -492,4 +496,4 @@ bool CSFile::FileExists(lpctstr ptcFilePath) // static
struct stat fileStat;
return ( stat( ptcFilePath, &fileStat) != -1 );
#endif
}
}
6 changes: 4 additions & 2 deletions src/game/chars/CChar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1558,7 +1558,6 @@ bool CChar::SetDispID(CREID_TYPE id)
return true;
}

// Just set the base id and not the actual display id.
// NOTE: Never return nullptr
void CChar::SetID( CREID_TYPE id )
{
Expand All @@ -1576,7 +1575,10 @@ void CChar::SetID( CREID_TYPE id )

pCharDef = CCharBase::FindCharBase(id);
}


//Update DispId
m_dwDispIndex = id;

ASSERT(pCharDef != nullptr);

CCharBase* pCharOldDef = Char_GetDef();
Expand Down

0 comments on commit 646b9d1

Please sign in to comment.