|
@@ -80,9 +80,6 @@
|
|
* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
|
|
* provided by stb_image and stb_image_write libraries, so, those libraries must be enabled on textures module
|
|
* for linkage
|
|
* for linkage
|
|
*
|
|
*
|
|
-* #define SUPPORT_DATA_STORAGE
|
|
|
|
-* Support saving binary data automatically to a generated storage.data file. This file is managed internally
|
|
|
|
-*
|
|
|
|
* #define SUPPORT_EVENTS_AUTOMATION
|
|
* #define SUPPORT_EVENTS_AUTOMATION
|
|
* Support automatic generated events, loading and recording of those events when required
|
|
* Support automatic generated events, loading and recording of those events when required
|
|
*
|
|
*
|
|
@@ -332,12 +329,6 @@
|
|
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
|
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-#if defined(SUPPORT_DATA_STORAGE)
|
|
|
|
- #ifndef STORAGE_DATA_FILE
|
|
|
|
- #define STORAGE_DATA_FILE "storage.data" // Automatic storage filename
|
|
|
|
- #endif
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
#ifndef MAX_DECOMPRESSION_SIZE
|
|
#ifndef MAX_DECOMPRESSION_SIZE
|
|
#define MAX_DECOMPRESSION_SIZE 64 // Maximum size allocated for decompression in MB
|
|
#define MAX_DECOMPRESSION_SIZE 64 // Maximum size allocated for decompression in MB
|
|
#endif
|
|
#endif
|
|
@@ -3398,110 +3389,6 @@ unsigned char *DecodeDataBase64(const unsigned char *data, int *outputSize)
|
|
return decodedData;
|
|
return decodedData;
|
|
}
|
|
}
|
|
|
|
|
|
-// Save integer value to storage file (to defined position)
|
|
|
|
-// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
|
|
|
|
-bool SaveStorageValue(unsigned int position, int value)
|
|
|
|
-{
|
|
|
|
- bool success = false;
|
|
|
|
-
|
|
|
|
-#if defined(SUPPORT_DATA_STORAGE)
|
|
|
|
- char path[512] = { 0 };
|
|
|
|
- strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE));
|
|
|
|
-
|
|
|
|
- unsigned int dataSize = 0;
|
|
|
|
- unsigned int newDataSize = 0;
|
|
|
|
- unsigned char *fileData = LoadFileData(path, &dataSize);
|
|
|
|
- unsigned char *newFileData = NULL;
|
|
|
|
-
|
|
|
|
- if (fileData != NULL)
|
|
|
|
- {
|
|
|
|
- if (dataSize <= (position*sizeof(int)))
|
|
|
|
- {
|
|
|
|
- // Increase data size up to position and store value
|
|
|
|
- newDataSize = (position + 1)*sizeof(int);
|
|
|
|
- newFileData = (unsigned char *)RL_REALLOC(fileData, newDataSize);
|
|
|
|
-
|
|
|
|
- if (newFileData != NULL)
|
|
|
|
- {
|
|
|
|
- // RL_REALLOC succeded
|
|
|
|
- int *dataPtr = (int *)newFileData;
|
|
|
|
- dataPtr[position] = value;
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // RL_REALLOC failed
|
|
|
|
- TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to realloc data (%u), position in bytes (%u) bigger than actual file size", path, dataSize, position*sizeof(int));
|
|
|
|
-
|
|
|
|
- // We store the old size of the file
|
|
|
|
- newFileData = fileData;
|
|
|
|
- newDataSize = dataSize;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- // Store the old size of the file
|
|
|
|
- newFileData = fileData;
|
|
|
|
- newDataSize = dataSize;
|
|
|
|
-
|
|
|
|
- // Replace value on selected position
|
|
|
|
- int *dataPtr = (int *)newFileData;
|
|
|
|
- dataPtr[position] = value;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- success = SaveFileData(path, newFileData, newDataSize);
|
|
|
|
- RL_FREE(newFileData);
|
|
|
|
-
|
|
|
|
- TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- TRACELOG(LOG_INFO, "FILEIO: [%s] File created successfully", path);
|
|
|
|
-
|
|
|
|
- dataSize = (position + 1)*sizeof(int);
|
|
|
|
- fileData = (unsigned char *)RL_MALLOC(dataSize);
|
|
|
|
- int *dataPtr = (int *)fileData;
|
|
|
|
- dataPtr[position] = value;
|
|
|
|
-
|
|
|
|
- success = SaveFileData(path, fileData, dataSize);
|
|
|
|
- UnloadFileData(fileData);
|
|
|
|
-
|
|
|
|
- TRACELOG(LOG_INFO, "FILEIO: [%s] Saved storage value: %i", path, value);
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
-
|
|
|
|
- return success;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// Load integer value from storage file (from defined position)
|
|
|
|
-// NOTE: If requested position could not be found, value 0 is returned
|
|
|
|
-int LoadStorageValue(unsigned int position)
|
|
|
|
-{
|
|
|
|
- int value = 0;
|
|
|
|
-
|
|
|
|
-#if defined(SUPPORT_DATA_STORAGE)
|
|
|
|
- char path[512] = { 0 };
|
|
|
|
- strcpy(path, TextFormat("%s/%s", CORE.Storage.basePath, STORAGE_DATA_FILE));
|
|
|
|
-
|
|
|
|
- unsigned int dataSize = 0;
|
|
|
|
- unsigned char *fileData = LoadFileData(path, &dataSize);
|
|
|
|
-
|
|
|
|
- if (fileData != NULL)
|
|
|
|
- {
|
|
|
|
- if (dataSize < (position*4)) TRACELOG(LOG_WARNING, "FILEIO: [%s] Failed to find storage position: %i", path, position);
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- int *dataPtr = (int *)fileData;
|
|
|
|
- value = dataPtr[position];
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- UnloadFileData(fileData);
|
|
|
|
-
|
|
|
|
- TRACELOG(LOG_INFO, "FILEIO: [%s] Loaded storage value: %i", path, value);
|
|
|
|
- }
|
|
|
|
-#endif
|
|
|
|
- return value;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// Open URL with default system browser (if available)
|
|
// Open URL with default system browser (if available)
|
|
// NOTE: This function is only safe to use if you control the URL given.
|
|
// NOTE: This function is only safe to use if you control the URL given.
|
|
// A user could craft a malicious string performing another action.
|
|
// A user could craft a malicious string performing another action.
|