Minor tweaks to raylib events automation system

This commit is contained in:
Ray
2023-03-22 19:47:42 +01:00
parent 0d4db7ad7f
commit 770e239f73

View File

@@ -595,11 +595,11 @@ static const char *autoEventTypeName[] = {
"ACTION_SETTARGETFPS" "ACTION_SETTARGETFPS"
}; };
// Automation Event (20 bytes) // Automation Event (24 bytes)
typedef struct AutomationEvent { typedef struct AutomationEvent {
unsigned int frame; // Event frame unsigned int frame; // Event frame
unsigned int type; // Event type (AutoEventType) unsigned int type; // Event type (AutomationEventType)
int params[3]; // Event parameters (if required) int params[4]; // Event parameters (if required)
} AutomationEvent; } AutomationEvent;
static AutomationEvent *events = NULL; // Events array static AutomationEvent *events = NULL; // Events array
@@ -925,7 +925,7 @@ void InitWindow(int width, int height, const char *title)
#endif #endif
#if defined(SUPPORT_EVENTS_AUTOMATION) #if defined(SUPPORT_EVENTS_AUTOMATION)
events = (AutomationEvent *)malloc(MAX_CODE_AUTOMATION_EVENTS*sizeof(AutomationEvent)); events = (AutomationEvent *)RL_CALLOC(MAX_CODE_AUTOMATION_EVENTS, sizeof(AutomationEvent));
CORE.Time.frameCounter = 0; CORE.Time.frameCounter = 0;
#endif #endif
@@ -1073,7 +1073,7 @@ void CloseWindow(void)
#endif #endif
#if defined(SUPPORT_EVENTS_AUTOMATION) #if defined(SUPPORT_EVENTS_AUTOMATION)
free(events); RL_FREE(events);
#endif #endif
CORE.Window.ready = false; CORE.Window.ready = false;
@@ -6945,11 +6945,11 @@ static int FindNearestConnectorMode(const drmModeConnector *connector, uint widt
// TODO: This system should probably be redesigned // TODO: This system should probably be redesigned
static void LoadAutomationEvents(const char *fileName) static void LoadAutomationEvents(const char *fileName)
{ {
//unsigned char fileId[4] = { 0 }; // Load events file (binary)
// Load binary
/* /*
FILE *repFile = fopen(fileName, "rb"); FILE *repFile = fopen(fileName, "rb");
unsigned char fileId[4] = { 0 };
fread(fileId, 1, 4, repFile); fread(fileId, 1, 4, repFile);
if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' ')) if ((fileId[0] == 'r') && (fileId[1] == 'E') && (fileId[2] == 'P') && (fileId[1] == ' '))
@@ -6962,7 +6962,7 @@ static void LoadAutomationEvents(const char *fileName)
fclose(repFile); fclose(repFile);
*/ */
// Load events (text file) // Load events file (text)
FILE *repFile = fopen(fileName, "rt"); FILE *repFile = fopen(fileName, "rt");
if (repFile != NULL) if (repFile != NULL)