From 7b2879029087bb7bafc3880550caf0fd3319a0d7 Mon Sep 17 00:00:00 2001 From: Alessio Tosto Date: Fri, 1 May 2026 23:20:21 +0200 Subject: Force type correctness when calculating collision hashes (#696) * Force type correctness when calculating collision hashes * Fix more incorrect hash calculations. * fix an error --------- Co-authored-by: coco875 <59367621+coco875@users.noreply.github.com> --- src/engine/editor/Collision.cpp | 4 ++-- src/racing/collision.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/engine/editor/Collision.cpp b/src/engine/editor/Collision.cpp index d872963d1..9ded514d6 100644 --- a/src/engine/editor/Collision.cpp +++ b/src/engine/editor/Collision.cpp @@ -37,7 +37,7 @@ namespace TrackEditor { break; case G_DL_OTR_HASH: ptr++; - GenerateCollisionMesh(object, (Gfx*)ResourceGetDataByCrc(((uint64_t)(ptr->words.w0 << 32)) + ptr->words.w1), scale); + GenerateCollisionMesh(object, (Gfx*)ResourceGetDataByCrc(((uint64_t)(ptr->words.w0) << 32) + ptr->words.w1), scale); break; case G_DL_OTR_FILEPATH: // printf("otr filepath: %s\n", (const char*)hi); @@ -48,7 +48,7 @@ namespace TrackEditor { break; case G_VTX_OTR_HASH: { ptr++; - vtx = (Vtx*)ResourceGetDataByCrc(((uint64_t)(ptr->words.w0 << 32)) + ptr->words.w1); + vtx = (Vtx*)ResourceGetDataByCrc(((uint64_t)(ptr->words.w0) << 32) + ptr->words.w1); break; } case G_VTX_OTR_FILEPATH: { diff --git a/src/racing/collision.c b/src/racing/collision.c index 76b639f86..8805ec080 100644 --- a/src/racing/collision.c +++ b/src/racing/collision.c @@ -2044,7 +2044,7 @@ void generate_collision_mesh(Gfx* addr, s8 surfaceType, u16 sectionId) { break; case G_DL_OTR_HASH: gfx++; - uint64_t hash = gfx->words.w0 << 32 | gfx->words.w1; + uint64_t hash = ((uint64_t)gfx->words.w0) << 32 | gfx->words.w1; generate_collision_mesh(ResourceGetDataByCrc(hash), surfaceType, sectionId); break; case G_DL_OTR_FILEPATH: @@ -2073,7 +2073,7 @@ void generate_collision_mesh(Gfx* addr, s8 surfaceType, u16 sectionId) { } case G_VTX_OTR_HASH: gfx++; - hash = gfx->words.w0 << 32 | gfx->words.w1; + hash = ((uint64_t)gfx->words.w0) << 32 | gfx->words.w1; int numVerts = (lo >> 12) & ((1<<8)-1); int bufferIndex = ((lo >> 1) & ((1<<7)-1)); bufferIndex = numVerts - bufferIndex; @@ -2193,7 +2193,7 @@ void find_vtx_and_set_colours(Gfx* displayList, s8 alpha, u8 red, u8 green, u8 b find_vtx_and_set_colours((Gfx*) hi, alpha, red, green, blue); } else if (opcode == (G_DL_OTR_HASH << 24)) { gfx++; - uint64_t hash = gfx->words.w0 << 32 | gfx->words.w1; + uint64_t hash = ((uint64_t)gfx->words.w0) << 32 | gfx->words.w1; find_vtx_and_set_colours(ResourceGetDataByCrc(hash), alpha, red, green, blue); } else if (opcode == (G_DL_OTR_FILEPATH << 24)) { find_vtx_and_set_colours(ResourceGetDataByName((const char*)hi), alpha, red, green, blue); @@ -2216,7 +2216,7 @@ void find_vtx_and_set_colours(Gfx* displayList, s8 alpha, u8 red, u8 green, u8 b set_vertex_colours((uintptr_t)vtx, count, index, alpha, red, green, blue); } else if (opcode == (G_VTX_OTR_HASH << 24)) { gfx++; - uint64_t hash = gfx->words.w0 << 32 | gfx->words.w1; + uint64_t hash = ((uint64_t)gfx->words.w0) << 32 | gfx->words.w1; int numVerts = (lo >> 12) & ((1<<8)-1); int bufferIndex = ((lo >> 1) & ((1<<7)-1)); bufferIndex = numVerts - bufferIndex; -- cgit v1.2.3