[Scummvm-git-logs] scummvm master -> 86e2f8ab0fafc7d9d41c280aea0cb1bc2117e820
Strangerke
noreply at scummvm.org
Thu May 9 07:35:20 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
f48e3002d4 BAGEL: Remove return value from MACROREPLACE
699f234b0e BAGEL: initialize booleans to true instead of 1, add safeguard on fileLength() results (CID 1544832, 1544874,
86e2f8ab0f BAGEL: Remove an non-implement function in misc, rename parameters so that definition and declaration match, move a coup
Commit: f48e3002d470b4f41ec6a5649e0b0133add7b137
https://github.com/scummvm/scummvm/commit/f48e3002d470b4f41ec6a5649e0b0133add7b137
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-09T08:34:59+01:00
Commit Message:
BAGEL: Remove return value from MACROREPLACE
Changed paths:
engines/bagel/baglib/bagel.cpp
engines/bagel/baglib/bagel.h
diff --git a/engines/bagel/baglib/bagel.cpp b/engines/bagel/baglib/bagel.cpp
index be7b8bcdd9f..6e76db43371 100644
--- a/engines/bagel/baglib/bagel.cpp
+++ b/engines/bagel/baglib/bagel.cpp
@@ -240,7 +240,7 @@ ErrorCode CBagel::verifyRequirements() {
return _errCode;
}
-bool MACROREPLACE(CBofString &s) {
+void MACROREPLACE(CBofString &s) {
// Remove any homedir prefix. In ScummVM, all paths are relative
// to the game folder automatically
char *p = strstr(s.getBuffer(), HOMEDIR_TOKEN);
@@ -250,8 +250,6 @@ bool MACROREPLACE(CBofString &s) {
// Replace any backslashes with forward slashes
while ((p = strchr(s.getBuffer(), '\\')) != nullptr)
*p = '/';
-
- return true;
}
diff --git a/engines/bagel/baglib/bagel.h b/engines/bagel/baglib/bagel.h
index 75ca1d94918..608516b6e1d 100644
--- a/engines/bagel/baglib/bagel.h
+++ b/engines/bagel/baglib/bagel.h
@@ -51,7 +51,7 @@ namespace Bagel {
// Defines default chroma color to be palette index 1
#define DEFAULT_CHROMA_COLOR 1
-extern bool MACROREPLACE(CBofString &s);
+extern void MACROREPLACE(CBofString &s);
class CBagMasterWin;
Commit: 699f234b0ed4cb5a5ff8b2893b680308d781ac67
https://github.com/scummvm/scummvm/commit/699f234b0ed4cb5a5ff8b2893b680308d781ac67
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-09T08:34:59+01:00
Commit Message:
BAGEL: initialize booleans to true instead of 1, add safeguard on fileLength() results (CID 1544832, 1544874,
Changed paths:
engines/bagel/baglib/storage_dev_win.cpp
engines/bagel/baglib/storage_dev_win.h
diff --git a/engines/bagel/baglib/storage_dev_win.cpp b/engines/bagel/baglib/storage_dev_win.cpp
index 04704163b7d..f4a9ee77fed 100644
--- a/engines/bagel/baglib/storage_dev_win.cpp
+++ b/engines/bagel/baglib/storage_dev_win.cpp
@@ -108,7 +108,7 @@ CBagStorageDev::CBagStorageDev() {
_pAssociateWnd = nullptr; // The associate window for attaching sounds
- _bForiegnList = false;
+ _bForeignList = false;
_pObjectList = new CBofList<CBagObject *>;
_pExpressionList = nullptr;
_nDiskID = 1;
@@ -117,11 +117,8 @@ CBagStorageDev::CBagStorageDev() {
// run object stuff
_bFirstPaint = true;
-
_nFloatPages = 0;
-
_xSDevType = SDEV_UNDEF;
-
_pBitmapFilter = nullptr;
setCloseOnOpen(false);
@@ -142,7 +139,7 @@ CBagStorageDev::CBagStorageDev() {
}
CBagStorageDev::~CBagStorageDev() {
- if (!_bForiegnList) {
+ if (!_bForeignList) {
if (_pObjectList != nullptr) {
// Delete all master sprite objects
@@ -206,7 +203,7 @@ ErrorCode CBagStorageDev::addObject(CBagObject *pObj, int /*nPos*/) {
ErrorCode CBagStorageDev::removeObject(CBagObject *pRObj) {
ErrorCode errCode = ERR_NONE;
- if (!_bForiegnList) {
+ if (!_bForeignList) {
int nCount = getObjectCount();
for (int i = 0; i < nCount; ++i) {
if (pRObj == getObjectByPos(i)) {
@@ -395,7 +392,7 @@ ErrorCode CBagStorageDev::releaseObjects() {
ErrorCode errCode = ERR_NONE;
int nCount = getObjectCount();
- if (!_bForiegnList) {
+ if (!_bForeignList) {
if (nCount) {
for (int i = 0; i < nCount; ++i) {
CBagObject *pObj = _pObjectList->removeHead();
@@ -412,7 +409,7 @@ ErrorCode CBagStorageDev::releaseObjects() {
void CBagStorageDev::setObjectList(CBofList<CBagObject *> *pOList, CBofList<CBagExpression *> *pEList) {
delete _pObjectList;
- _bForiegnList = true;
+ _bForeignList = true;
_pObjectList = pOList;
_pExpressionList = pEList;
}
@@ -575,6 +572,9 @@ ErrorCode CBagStorageDev::loadFile(const CBofString &sWldName) {
// Force buffer to be big enough so that the entire script
// is pre-loaded
int nLength = fileLength(sWldFileName);
+ if (nLength <= 0)
+ error("Unable to open or read %s", sWldFileName.getBuffer());
+
char *pBuf = (char *)bofAlloc(nLength);
if (pBuf != nullptr) {
CBagIfstream fpInput(pBuf, nLength);
@@ -588,7 +588,6 @@ ErrorCode CBagStorageDev::loadFile(const CBofString &sWldName) {
bofFree(pBuf);
}
-
// Add everything to the window
return ERR_NONE;
}
@@ -1440,26 +1439,30 @@ ErrorCode CBagStorageDevWnd::loadFile(const CBofString &sFile) {
// Force buffer to be big enough so that the entire script
// is pre-loaded
int nLength = fileLength(sWldFile);
- char *pBuf = (char *)bofAlloc(nLength);
- if (pBuf != nullptr) {
- CBagIfstream fpInput(pBuf, nLength);
+ if (nLength <= 0)
+ reportError(ERR_FOPEN);
+ else {
+ char *pBuf = (char *)bofAlloc(nLength);
+ if (pBuf != nullptr) {
+ CBagIfstream fpInput(pBuf, nLength);
- CBofFile cFile;
- cFile.open(sWldFile);
- cFile.read(pBuf, nLength);
- cFile.close();
+ CBofFile cFile;
+ cFile.open(sWldFile);
+ cFile.read(pBuf, nLength);
+ cFile.close();
- CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
+ CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
- // If the window.isCreated()
- //
- if (isCreated())
- invalidateRect(nullptr);
+ // If the window.isCreated()
+ //
+ if (isCreated())
+ invalidateRect(nullptr);
- bofFree(pBuf);
+ bofFree(pBuf);
- } else {
- reportError(ERR_MEMORY);
+ } else {
+ reportError(ERR_MEMORY);
+ }
}
// Add everything to the window
@@ -1470,7 +1473,8 @@ ErrorCode CBagStorageDevWnd::loadFile(const CBofString &sFile) {
void CBagStorageDevWnd::onClose() {
CBofWindow::onClose();
- destroyWindow(); // destruct the main window
+ // destruct the main window
+ destroyWindow();
}
void CBagStorageDevWnd::onMouseMove(uint32 n, CBofPoint *pPoint, void *) {
@@ -1716,23 +1720,26 @@ ErrorCode CBagStorageDevDlg::loadFile(const CBofString &sFile) {
// Force buffer to be big enough so that the entire script is pre-loaded
int nLength = fileLength(sWldFile);
- char *pBuf = (char *)bofAlloc(nLength);
- if (pBuf != nullptr) {
- CBagIfstream fpInput(pBuf, nLength);
+ if (nLength <= 0)
+ reportError(ERR_FOPEN);
+ else {
+ char *pBuf = (char *)bofAlloc(nLength);
+ if (pBuf != nullptr) {
+ CBagIfstream fpInput(pBuf, nLength);
- CBofFile cFile;
- cFile.open(sWldFile);
- cFile.read(pBuf, nLength);
- cFile.close();
+ CBofFile cFile;
+ cFile.open(sWldFile);
+ cFile.read(pBuf, nLength);
+ cFile.close();
- CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
+ CBagStorageDev::loadFileFromStream(fpInput, sWldFile);
- bofFree(pBuf);
+ bofFree(pBuf);
- if (isCreated())
- invalidateRect(nullptr);
+ if (isCreated())
+ invalidateRect(nullptr);
+ }
}
-
// Add everything to the window
return _errCode;
}
diff --git a/engines/bagel/baglib/storage_dev_win.h b/engines/bagel/baglib/storage_dev_win.h
index 30f1747fefd..ae192306807 100644
--- a/engines/bagel/baglib/storage_dev_win.h
+++ b/engines/bagel/baglib/storage_dev_win.h
@@ -111,13 +111,13 @@ protected:
static bool _hidePdaFl;
FilterFunction _pBitmapFilter; // Pointer to the bitmap filter.
- bool _bForiegnList : 1; // True if setObjectList has been called
- bool _bCloseOnOpen : 1; // True if other SDev should be closed when this is opened
- bool _bContainsModal : 1; // True if SDev contains a modal object
- bool _bCloseup : 1; // true if is a closeup (includes CIC, or CHAT)
- bool _bCIC : 1; // true if is a CIC
- bool _bCustom : 1; // true if is a hand coded closeup
- bool _bFirstPaint : 1; // run object stuff
+ bool _bForeignList : true; // True if setObjectList has been called
+ bool _bCloseOnOpen : true; // True if other SDev should be closed when this is opened
+ bool _bContainsModal : true; // True if SDev contains a modal object
+ bool _bCloseup : true; // true if is a closeup (includes CIC, or CHAT)
+ bool _bCIC : true; // true if is a CIC
+ bool _bCustom : true; // true if is a hand coded closeup
+ bool _bFirstPaint : true; // run object stuff
static bool _bPanPreFiltered; // Let pda know if screens been prefiltered
static bool _bDirtyAllObjects; // Dirty all objects in prefilter?
Commit: 86e2f8ab0fafc7d9d41c280aea0cb1bc2117e820
https://github.com/scummvm/scummvm/commit/86e2f8ab0fafc7d9d41c280aea0cb1bc2117e820
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2024-05-09T08:34:59+01:00
Commit Message:
BAGEL: Remove an non-implement function in misc, rename parameters so that definition and declaration match, move a couple of assignment out of if statements
Changed paths:
engines/bagel/boflib/error.cpp
engines/bagel/boflib/misc.cpp
engines/bagel/boflib/misc.h
engines/bagel/dialogs/credits_dialog.cpp
diff --git a/engines/bagel/boflib/error.cpp b/engines/bagel/boflib/error.cpp
index 816b6f0a327..2049441fc80 100644
--- a/engines/bagel/boflib/error.cpp
+++ b/engines/bagel/boflib/error.cpp
@@ -63,7 +63,8 @@ void CBofError::initialize() {
}
void CBofError::reportError(ErrorCode errCode, const char *format, ...) {
- if ((_errCode = errCode) != ERR_NONE) {
+ _errCode = errCode;
+ if (_errCode != ERR_NONE) {
Common::String buf;
// Set global last error
@@ -85,7 +86,7 @@ void CBofError::reportError(ErrorCode errCode, const char *format, ...) {
if (_nErrorCount < MAX_ERRORS)
bofMessageBox(buf, g_errList[errCode]);
- auto *console = g_engine->getDebugger();
+ GUI::Debugger *console = g_engine->getDebugger();
if (console->isActive())
console->debugPrintf("%s\n", buf.c_str());
}
diff --git a/engines/bagel/boflib/misc.cpp b/engines/bagel/boflib/misc.cpp
index fde27746392..a41a685059c 100644
--- a/engines/bagel/boflib/misc.cpp
+++ b/engines/bagel/boflib/misc.cpp
@@ -51,10 +51,10 @@ void bofSleep(uint32 milli) {
#define ALLOC_FAIL_RETRIES 2
-void *bofMemAlloc(uint32 lSize, const char *pszFile, int nLine, bool bClear) {
- // For now, until I fix it, pszFile MUST be valid.
- assert(pszFile != nullptr);
- assert(lSize != 0);
+void *bofMemAlloc(uint32 nSize, const char *pFile, int nLine, bool bClear) {
+ // For now, until I fix it, pFile MUST be valid.
+ assert(pFile != nullptr);
+ assert(nSize != 0);
// Assume failure
void *pNewBlock = nullptr;
@@ -62,29 +62,29 @@ void *bofMemAlloc(uint32 lSize, const char *pszFile, int nLine, bool bClear) {
// Try a few times to allocate the desired amount of memory.
// Flush objects from Cache is necessary.
for (int nRetries = 0; nRetries < ALLOC_FAIL_RETRIES; nRetries++) {
- pNewBlock = (void *)malloc(lSize);
+ pNewBlock = (void *)malloc(nSize);
// If allocation was successful, then we're outta here
if (pNewBlock != nullptr) {
if (bClear)
- bofMemSet((byte *)pNewBlock, 0, lSize);
+ bofMemSet((byte *)pNewBlock, 0, nSize);
break;
}
// Otherwise, we need to free up some memory by flushing old
// objects from the Cache.
- CCache::optimize(lSize + 2 * sizeof(uint16) + sizeof(uint32));
+ CCache::optimize(nSize + 2 * sizeof(uint16) + sizeof(uint32));
}
if (pNewBlock == nullptr) {
- logError(buildString("Could not allocate %ld bytes, file %s, line %d", lSize, pszFile, nLine));
+ logError(buildString("Could not allocate %ld bytes, file %s, line %d", nSize, pFile, nLine));
}
return pNewBlock;
}
-void bofMemFree(void *pBuf, const char *pszFile, int nLine) {
- assert(pszFile != nullptr);
+void bofMemFree(void *pBuf, const char *pFile, int nLine) {
+ assert(pFile != nullptr);
free(pBuf);
}
diff --git a/engines/bagel/boflib/misc.h b/engines/bagel/boflib/misc.h
index b360068c6fe..bf6988e1a57 100644
--- a/engines/bagel/boflib/misc.h
+++ b/engines/bagel/boflib/misc.h
@@ -74,27 +74,16 @@ extern Fixed fixedMultiply(Fixed Multiplicand, Fixed Multiplier);
*/
extern void *bofMemAlloc(uint32 nSize, const char *pFile, int nLine, bool bClear);
-/**
- * Re-Allocates a memory block to the specified size
- * @param pOldPointer Old memory pointer
- * @param nNewSize New buffer size
- * @param pFile Source file name
- * @param nLine Source file line number
- * @return Pointer to new buffer
- */
-extern void *bofMemReAlloc(void *pOldPtr, uint32 nNewSize, const char *pFile, int nLine);
-
/**
* Frees specified memory block
* @param pBuf Buffer to de-allocate
* @param pFile Source file name
* @param nLine Source file line number
**/
-extern void bofMemFree(void *pBuf, const char *pszFile, int nLine);
+extern void bofMemFree(void *pBuf, const char *pFile, int nLine);
#define bofAlloc(n) bofMemAlloc((n), __FILE__, __LINE__, false)
#define bofCAlloc(n, m) bofMemAlloc((uint32)(n) * (m), __FILE__, __LINE__, true)
-#define bofReAlloc(p, n) bofMemReAlloc((p), (n), __FILE__, __LINE__)
#define bofFree(p) bofMemFree((p), __FILE__, __LINE__)
#define bofMemSet memset
diff --git a/engines/bagel/dialogs/credits_dialog.cpp b/engines/bagel/dialogs/credits_dialog.cpp
index ed1c03035bf..636ff7e57ef 100644
--- a/engines/bagel/dialogs/credits_dialog.cpp
+++ b/engines/bagel/dialogs/credits_dialog.cpp
@@ -154,7 +154,8 @@ ErrorCode CBagCreditsDialog::loadNextTextFile() {
// Read in text file
lSize = cFile.getLength();
- if ((_pszText = (char *)bofCAlloc(lSize + 1, 1)) != nullptr) {
+ _pszText = (char *)bofCAlloc(lSize + 1, 1);
+ if (_pszText != nullptr) {
cFile.read(_pszText, lSize);
More information about the Scummvm-git-logs
mailing list