Even more const and fix compiler warnings

This commit is contained in:
UnknownShadow200 2019-08-25 19:56:17 +10:00
parent 8b48a3381c
commit 72fb33f9b6
8 changed files with 20 additions and 20 deletions

View File

@ -11,7 +11,7 @@
struct _BlockLists Blocks; struct _BlockLists Blocks;
const char* Sound_Names[SOUND_COUNT] = { const char* const Sound_Names[SOUND_COUNT] = {
"none", "wood", "gravel", "grass", "stone", "none", "wood", "gravel", "grass", "stone",
"metal", "glass", "cloth", "sand", "snow", "metal", "glass", "cloth", "sand", "snow",
}; };

View File

@ -16,7 +16,7 @@ enum SoundType {
SOUND_STONE, SOUND_METAL, SOUND_GLASS, SOUND_CLOTH, SOUND_STONE, SOUND_METAL, SOUND_GLASS, SOUND_CLOTH,
SOUND_SAND, SOUND_SNOW, SOUND_COUNT SOUND_SAND, SOUND_SNOW, SOUND_COUNT
}; };
extern const char* Sound_Names[SOUND_COUNT]; extern const char* const Sound_Names[SOUND_COUNT];
/* Describes how a block is rendered in the world. */ /* Describes how a block is rendered in the world. */
enum DrawType { enum DrawType {

View File

@ -63,7 +63,7 @@ String Game_Username = String_FromArray(Game_UsernameBuffer);
String Game_Mppass = String_FromArray(Game_MppassBuffer); String Game_Mppass = String_FromArray(Game_MppassBuffer);
String Game_Hash = String_FromArray(Game_HashBuffer); String Game_Hash = String_FromArray(Game_HashBuffer);
const char* FpsLimit_Names[FPS_LIMIT_COUNT] = { const char* const FpsLimit_Names[FPS_LIMIT_COUNT] = {
"LimitVSync", "Limit30FPS", "Limit60FPS", "Limit120FPS", "Limit144FPS", "LimitNone", "LimitVSync", "Limit30FPS", "Limit60FPS", "Limit120FPS", "Limit144FPS", "LimitNone",
}; };

View File

@ -51,7 +51,7 @@ extern bool Game_HideGui;
enum FpsLimitMethod { enum FpsLimitMethod {
FPS_LIMIT_VSYNC, FPS_LIMIT_30, FPS_LIMIT_60, FPS_LIMIT_120, FPS_LIMIT_144, FPS_LIMIT_NONE, FPS_LIMIT_COUNT FPS_LIMIT_VSYNC, FPS_LIMIT_30, FPS_LIMIT_60, FPS_LIMIT_120, FPS_LIMIT_144, FPS_LIMIT_NONE, FPS_LIMIT_COUNT
}; };
extern const char* FpsLimit_Names[FPS_LIMIT_COUNT]; extern const char* const FpsLimit_Names[FPS_LIMIT_COUNT];
extern float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale; extern float Game_RawHotbarScale, Game_RawChatScale, Game_RawInventoryScale;
float Game_Scale(float value); float Game_Scale(float value);

View File

@ -11,7 +11,7 @@
/*########################################################################################################################* /*########################################################################################################################*
*----------------------------------------------------------Misc-----------------------------------------------------------* *----------------------------------------------------------Misc-----------------------------------------------------------*
*#########################################################################################################################*/ *#########################################################################################################################*/
int Utils_ParseEnum(const String* text, int defValue, const char** names, int namesCount) { int Utils_ParseEnum(const String* text, int defValue, const char* const* names, int namesCount) {
int i; int i;
for (i = 0; i < namesCount; i++) { for (i = 0; i < namesCount; i++) {
if (String_CaselessEqualsConst(text, names[i])) return i; if (String_CaselessEqualsConst(text, names[i])) return i;

View File

@ -27,7 +27,7 @@ struct DateTime {
#define HOURS_PER_DAY 24 #define HOURS_PER_DAY 24
#define MILLIS_PER_DAY (1000 * 60 * 60 * 24) #define MILLIS_PER_DAY (1000 * 60 * 60 * 24)
CC_NOINLINE int Utils_ParseEnum(const String* text, int defValue, const char** names, int namesCount); CC_NOINLINE int Utils_ParseEnum(const String* text, int defValue, const char* const* names, int namesCount);
/* Returns whether value starts with http:// or https:// */ /* Returns whether value starts with http:// or https:// */
bool Utils_IsUrlPrefix(const String* value); bool Utils_IsUrlPrefix(const String* value);

View File

@ -1250,7 +1250,7 @@ static void Hex_Default(struct MenuInputDesc* d, String* value) {
PackedCol_ToHex(value, d->meta.h.Default); PackedCol_ToHex(value, d->meta.h.Default);
} }
struct MenuInputVTABLE HexValidator_VTABLE = { const struct MenuInputVTABLE HexValidator_VTABLE = {
Hex_Range, Hex_ValidChar, Hex_ValidString, Hex_ValidValue, Hex_Default Hex_Range, Hex_ValidChar, Hex_ValidString, Hex_ValidValue, Hex_Default
}; };
@ -1277,7 +1277,7 @@ static void Int_Default(struct MenuInputDesc* d, String* value) {
String_AppendInt(value, d->meta.i.Default); String_AppendInt(value, d->meta.i.Default);
} }
struct MenuInputVTABLE IntValidator_VTABLE = { const struct MenuInputVTABLE IntValidator_VTABLE = {
Int_Range, Int_ValidChar, Int_ValidString, Int_ValidValue, Int_Default Int_Range, Int_ValidChar, Int_ValidString, Int_ValidValue, Int_Default
}; };
@ -1286,7 +1286,7 @@ static void Seed_Range(struct MenuInputDesc* d, String* range) {
} }
static void Seed_NoDefault(struct MenuInputDesc* d, String* value) { } static void Seed_NoDefault(struct MenuInputDesc* d, String* value) { }
struct MenuInputVTABLE SeedValidator_VTABLE = { const struct MenuInputVTABLE SeedValidator_VTABLE = {
Seed_Range, Int_ValidChar, Int_ValidString, Int_ValidValue, Seed_NoDefault Seed_Range, Int_ValidChar, Int_ValidString, Int_ValidValue, Seed_NoDefault
}; };
@ -1313,7 +1313,7 @@ static void Float_Default(struct MenuInputDesc* d, String* value) {
String_AppendFloat(value, d->meta.f.Default, 3); String_AppendFloat(value, d->meta.f.Default, 3);
} }
struct MenuInputVTABLE FloatValidator_VTABLE = { const struct MenuInputVTABLE FloatValidator_VTABLE = {
Float_Range, Float_ValidChar, Float_ValidString, Float_ValidValue, Float_Default Float_Range, Float_ValidChar, Float_ValidString, Float_ValidValue, Float_Default
}; };
@ -1327,7 +1327,7 @@ static bool Path_ValidChar(struct MenuInputDesc* d, char c) {
} }
static bool Path_ValidString(struct MenuInputDesc* d, const String* s) { return true; } static bool Path_ValidString(struct MenuInputDesc* d, const String* s) { return true; }
struct MenuInputVTABLE PathValidator_VTABLE = { const struct MenuInputVTABLE PathValidator_VTABLE = {
Path_Range, Path_ValidChar, Path_ValidString, Path_ValidString, Seed_NoDefault Path_Range, Path_ValidChar, Path_ValidString, Path_ValidString, Seed_NoDefault
}; };
@ -1343,7 +1343,7 @@ static bool String_ValidString(struct MenuInputDesc* d, const String* s) {
return s->length <= STRING_SIZE; return s->length <= STRING_SIZE;
} }
struct MenuInputVTABLE StringValidator_VTABLE = { const struct MenuInputVTABLE StringValidator_VTABLE = {
String_Range, String_ValidChar, String_ValidString, String_ValidString, Seed_NoDefault String_Range, String_ValidChar, String_ValidString, String_ValidString, Seed_NoDefault
}; };

View File

@ -148,21 +148,21 @@ struct MenuInputVTABLE {
}; };
struct MenuInputDesc { struct MenuInputDesc {
struct MenuInputVTABLE* VTABLE; const struct MenuInputVTABLE* VTABLE;
union { union {
struct { const char** Names; int Count; } e; struct { const char* const* Names; int Count; } e;
struct { int Min, Max, Default; } i; struct { int Min, Max, Default; } i;
struct { float Min, Max, Default; } f; struct { float Min, Max, Default; } f;
struct { PackedCol Default; } h; struct { PackedCol Default; } h;
} meta; } meta;
}; };
extern struct MenuInputVTABLE HexValidator_VTABLE; extern const struct MenuInputVTABLE HexValidator_VTABLE;
extern struct MenuInputVTABLE IntValidator_VTABLE; extern const struct MenuInputVTABLE IntValidator_VTABLE;
extern struct MenuInputVTABLE SeedValidator_VTABLE; extern const struct MenuInputVTABLE SeedValidator_VTABLE;
extern struct MenuInputVTABLE FloatValidator_VTABLE; extern const struct MenuInputVTABLE FloatValidator_VTABLE;
extern struct MenuInputVTABLE PathValidator_VTABLE; extern const struct MenuInputVTABLE PathValidator_VTABLE;
extern struct MenuInputVTABLE StringValidator_VTABLE; extern const struct MenuInputVTABLE StringValidator_VTABLE;
#define MenuInput_Hex(v, def) v.VTABLE = &HexValidator_VTABLE; v.meta.h.Default = def; #define MenuInput_Hex(v, def) v.VTABLE = &HexValidator_VTABLE; v.meta.h.Default = def;
#define MenuInput_Int(v, lo, hi, def) v.VTABLE = &IntValidator_VTABLE; v.meta.i.Min = lo; v.meta.i.Max = hi; v.meta.i.Default = def; #define MenuInput_Int(v, lo, hi, def) v.VTABLE = &IntValidator_VTABLE; v.meta.i.Min = lo; v.meta.i.Max = hi; v.meta.i.Default = def;