From 0553c950fd262a256b143dedf346a873acf8d67c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 20 Mar 2020 21:51:34 +1100 Subject: [PATCH] Make entity vtable and Updater_XYZ const --- src/Entity.c | 4 ++-- src/Entity.h | 2 +- src/HeldBlockRenderer.c | 2 +- src/Platform.c | 30 +++++++++++++++--------------- src/Platform.h | 4 ++-- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Entity.c b/src/Entity.c index b816f5e71..1608bc77a 100644 --- a/src/Entity.c +++ b/src/Entity.c @@ -870,7 +870,7 @@ static void LocalPlayer_CheckJumpVelocity(void* obj) { } } -static struct EntityVTABLE localPlayer_VTABLE = { +const static struct EntityVTABLE localPlayer_VTABLE = { LocalPlayer_Tick, Player_Despawn, LocalPlayer_SetLocation, Entity_GetCol, LocalPlayer_RenderModel, LocalPlayer_RenderName }; @@ -1098,7 +1098,7 @@ static void NetPlayer_RenderName(struct Entity* e) { if (distance <= (float)threshold) DrawName(e); } -struct EntityVTABLE netPlayer_VTABLE = { +const struct EntityVTABLE netPlayer_VTABLE = { NetPlayer_Tick, Player_Despawn, NetPlayer_SetLocation, Entity_GetCol, NetPlayer_RenderModel, NetPlayer_RenderName }; diff --git a/src/Entity.h b/src/Entity.h index 6f91f6277..b358fd501 100644 --- a/src/Entity.h +++ b/src/Entity.h @@ -69,7 +69,7 @@ struct EntityVTABLE { /* Contains a model, along with position, velocity, and rotation. May also contain other fields and properties. */ struct Entity { - struct EntityVTABLE* VTABLE; + const struct EntityVTABLE* VTABLE; Vec3 Position; float Pitch, Yaw, RotX, RotY, RotZ; Vec3 Velocity; diff --git a/src/HeldBlockRenderer.c b/src/HeldBlockRenderer.c index 088c13f2b..683a3dbb5 100644 --- a/src/HeldBlockRenderer.c +++ b/src/HeldBlockRenderer.c @@ -229,7 +229,7 @@ void HeldBlockRenderer_Render(double delta) { Gfx_LoadMatrix(MATRIX_PROJECTION, &Gfx.Projection); } -static struct EntityVTABLE heldEntity_VTABLE = { +const static struct EntityVTABLE heldEntity_VTABLE = { NULL, NULL, NULL, HeldBlockRenderer_GetCol, NULL, NULL }; diff --git a/src/Platform.c b/src/Platform.c index a60e1eb50..36b9f1f3f 100644 --- a/src/Platform.c +++ b/src/Platform.c @@ -1232,11 +1232,11 @@ static cc_result Process_RawGetExePath(char* path, int* len) { #define UPDATE_SRC TEXT(UPDATE_FILE) #if _WIN64 -const char* Updater_D3D9 = "ClassiCube.64.exe"; -const char* Updater_OGL = "ClassiCube.64-opengl.exe"; +const char* const Updater_D3D9 = "ClassiCube.64.exe"; +const char* const Updater_OGL = "ClassiCube.64-opengl.exe"; #else -const char* Updater_D3D9 = "ClassiCube.exe"; -const char* Updater_OGL = "ClassiCube.opengl.exe"; +const char* const Updater_D3D9 = "ClassiCube.exe"; +const char* const Updater_OGL = "ClassiCube.opengl.exe"; #endif cc_bool Updater_Clean(void) { @@ -1286,8 +1286,8 @@ cc_result Updater_GetBuildTime(TimeMS* ms) { /* Don't need special execute permission on windows */ cc_result Updater_MarkExecutable(void) { return 0; } #elif defined CC_BUILD_WEB || defined CC_BUILD_ANDROID -const char* Updater_D3D9 = NULL; -const char* Updater_OGL = NULL; +const char* const Updater_D3D9 = NULL; +const char* const Updater_OGL = NULL; cc_bool Updater_Clean(void) { return true; } cc_result Updater_Start(void) { return ERR_NOT_SUPPORTED; } @@ -1296,27 +1296,27 @@ cc_result Updater_MarkExecutable(void) { return 0; } #elif defined CC_BUILD_POSIX cc_bool Updater_Clean(void) { return true; } -const char* Updater_D3D9 = NULL; +const char* const Updater_D3D9 = NULL; #if defined CC_BUILD_LINUX #if __x86_64__ -const char* Updater_OGL = "ClassiCube"; +const char* const Updater_OGL = "ClassiCube"; #elif __i386__ -const char* Updater_OGL = "ClassiCube.32"; +const char* const Updater_OGL = "ClassiCube.32"; #elif CC_BUILD_RPI -const char* Updater_OGL = "ClassiCube.rpi"; +const char* const Updater_OGL = "ClassiCube.rpi"; #else -const char* Updater_OGL = NULL; +const char* const Updater_OGL = NULL; #endif #elif defined CC_BUILD_OSX #if __x86_64__ -const char* Updater_OGL = "ClassiCube.64.osx"; +const char* const Updater_OGL = "ClassiCube.64.osx"; #elif __i386__ -const char* Updater_OGL = "ClassiCube.osx"; +const char* const Updater_OGL = "ClassiCube.osx"; #else -const char* Updater_OGL = NULL; +const char* const Updater_OGL = NULL; #endif #else -const char* Updater_OGL = NULL; +const char* const Updater_OGL = NULL; #endif cc_result Updater_Start(void) { diff --git a/src/Platform.h b/src/Platform.h index 69688fa28..54b11927a 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -63,8 +63,8 @@ CC_API void Process_Exit(cc_result code); /* For example, provide a http:// url to open a website in the user's web browser. */ CC_API void Process_StartOpen(const String* args); -extern const char* Updater_D3D9; -extern const char* Updater_OGL; +extern const char* const Updater_D3D9; +extern const char* const Updater_OGL; /* Attempts to clean up any leftover files from an update */ cc_bool Updater_Clean(void); /* Starts the platform-specific method to update then start the game using the UPDATE_FILE file. */