diff options
| -rw-r--r-- | games/just_do/screens/screen_level06.c | 2 | ||||
| -rw-r--r-- | games/koala_seasons/screens/screen_gameplay.c | 2 | ||||
| -rw-r--r-- | games/transmission/screens/screen_ending.c | 10 | ||||
| -rw-r--r-- | src/core.c | 3 | ||||
| -rw-r--r-- | src/physac.h | 4 | ||||
| -rw-r--r-- | src/rlgl.h | 14 | ||||
| -rw-r--r-- | src/textures.c | 2 |
7 files changed, 19 insertions, 18 deletions
diff --git a/games/just_do/screens/screen_level06.c b/games/just_do/screens/screen_level06.c index a5536aa4..ec72d70c 100644 --- a/games/just_do/screens/screen_level06.c +++ b/games/just_do/screens/screen_level06.c @@ -132,7 +132,7 @@ void DrawLevel06Screen(void) DrawRectangleRec(movingRecs[i], GRAY); } - if (!done & (mouseOverNum >= 0)) DrawRectangleLines(movingRecs[mouseOverNum].x - 5, movingRecs[mouseOverNum].y - 5, movingRecs[mouseOverNum].width + 10, movingRecs[mouseOverNum].height + 10, Fade(LIGHTGRAY, 0.8f)); + if (!done && (mouseOverNum >= 0)) DrawRectangleLines(movingRecs[mouseOverNum].x - 5, movingRecs[mouseOverNum].y - 5, movingRecs[mouseOverNum].width + 10, movingRecs[mouseOverNum].height + 10, Fade(LIGHTGRAY, 0.8f)); if (levelFinished) { diff --git a/games/koala_seasons/screens/screen_gameplay.c b/games/koala_seasons/screens/screen_gameplay.c index 6bbcfaaf..4d8ff04d 100644 --- a/games/koala_seasons/screens/screen_gameplay.c +++ b/games/koala_seasons/screens/screen_gameplay.c @@ -954,7 +954,7 @@ void UpdateGameplayScreen(void) playerActive = false; killer = 5; } - else if (CheckCollisionRecs(bee, player) && (state == FINALFORM) && (state != KICK)) + else if (CheckCollisionRecs(bee, player) && (state == FINALFORM)) { isHitBee = true; beeVelocity = 8; diff --git a/games/transmission/screens/screen_ending.c b/games/transmission/screens/screen_ending.c index 0aba5f01..d0cf7d89 100644 --- a/games/transmission/screens/screen_ending.c +++ b/games/transmission/screens/screen_ending.c @@ -110,10 +110,12 @@ void InitEndingScreen(void) { // WARNING: It fails if the last sentence word has a '.' after space char *title = StringReplace(headline, messageWords[i].text, codingWords[messageWords[i].id]); - - strcpy(headline, title); // Base headline updated - - if (title != NULL) free(title); + + if (title != NULL) + { + strcpy(headline, title); // Base headline updated + free(title); + } } } @@ -1569,8 +1569,9 @@ const char *GetDirectoryPath(const char *fileName) lastSlash = strprbrk(fileName, "\\/"); if (!lastSlash) return NULL; + // NOTE: Be careful, strncpy() is not safe, it does not care about '\0' strncpy(filePath, fileName, strlen(fileName) - (strlen(lastSlash) - 1)); - filePath[strlen(fileName) - strlen(lastSlash)] = '\0'; + filePath[strlen(fileName) - strlen(lastSlash)] = '\0'; // Add '\0' manually return filePath; } diff --git a/src/physac.h b/src/physac.h index ab975e28..038361a4 100644 --- a/src/physac.h +++ b/src/physac.h @@ -606,7 +606,7 @@ PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force) { int count = vertexData.vertexCount; Vector2 bodyPos = body->position; - Vector2 vertices[count]; + Vector2 *vertices = (Vector2*)malloc(sizeof(Vector2) * count); Mat2 trans = body->shape.transform; for (int i = 0; i < count; i++) vertices[i] = vertexData.positions[i]; @@ -698,6 +698,8 @@ PHYSACDEF void PhysicsShatter(PhysicsBody body, Vector2 position, float force) // Apply force to new physics body PhysicsAddForce(newBody, forceDirection); } + + free(vertices); } } } @@ -1631,17 +1631,13 @@ void rlglInit(int width, int height) #elif defined(GRAPHICS_API_OPENGL_ES2) char *extensions = (char *)glGetString(GL_EXTENSIONS); // One big const string - // NOTE: We have to duplicate string because glGetString() returns a const value - // If not duplicated, it fails in some systems (Raspberry Pi) - // Equivalent to function: char *strdup(const char *str) - char *extensionsDup; - size_t len = strlen(extensions) + 1; - void *newstr = malloc(len); - if (newstr == NULL) extensionsDup = NULL; - extensionsDup = (char *)memcpy(newstr, extensions, len); + // NOTE: We have to duplicate string because glGetString() returns a const string + int len = strlen(extensions) + 1; + char *extensionsDup = (char *)malloc(len); + strcpy(extensionsDup, extensions); // NOTE: String could be splitted using strtok() function (string.h) - // NOTE: strtok() modifies the received string, it can not be const + // NOTE: strtok() modifies the passed string, it can not be const char *extList[512]; // Allocate 512 strings pointers (2 KB) diff --git a/src/textures.c b/src/textures.c index 7ee07d12..4c276324 100644 --- a/src/textures.c +++ b/src/textures.c @@ -323,7 +323,7 @@ Image LoadImageRaw(const char *fileName, int width, int height, int format, int // NOTE: fread() returns num read elements instead of bytes, // to get bytes we need to read (1 byte size, elements) instead of (x byte size, 1 element) - size_t bytes = fread(image.data, 1, size, rawFile); + int bytes = fread(image.data, 1, size, rawFile); // Check if data has been read successfully if (bytes < size) |
