fix C string typing (#459)

This commit is contained in:
PeachyPeach 2023-08-18 18:31:59 +02:00 committed by GitHub
parent c428612a9e
commit 610bdfcf04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
41 changed files with 71 additions and 71 deletions

View file

@ -17,7 +17,7 @@ s32 dynos_tex_import(void **output, void *ptr, s32 tile, void *grapi, void **h
void dynos_gfx_swap_animations(void *ptr);
// -- warps -- //
LevelScript* dynos_get_level_script(char* scriptEntryName);
LevelScript* dynos_get_level_script(const char* scriptEntryName);
bool dynos_warp_to_warpnode(s32 aLevel, s32 aArea, s32 aAct, s32 aWarpId);
bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct);
bool dynos_warp_restart_level(void);

View file

@ -937,7 +937,7 @@ void DynOS_Tex_ModShutdown();
//
Array<Pair<const char*, GfxData*>> &DynOS_Lvl_GetArray();
LevelScript* DynOS_Lvl_GetScript(char* aScriptEntryName);
LevelScript* DynOS_Lvl_GetScript(const char* aScriptEntryName);
void DynOS_Lvl_Activate(s32 modIndex, const SysPath &aFilePath, const char *aLevelName);
GfxData* DynOS_Lvl_GetActiveGfx(void);
const char* DynOS_Lvl_GetToken(u32 index);

View file

@ -32,7 +32,7 @@ void dynos_gfx_swap_animations(void *ptr) {
// -- warps -- //
LevelScript* dynos_get_level_script(char* scriptEntryName) {
LevelScript* dynos_get_level_script(const char* scriptEntryName) {
return DynOS_Lvl_GetScript(scriptEntryName);
}

View file

@ -21,7 +21,7 @@ Array<Pair<const char*, GfxData*>> &DynOS_Lvl_GetArray() {
return sDynosCustomLevelScripts;
}
LevelScript* DynOS_Lvl_GetScript(char* aScriptEntryName) {
LevelScript* DynOS_Lvl_GetScript(const char* aScriptEntryName) {
auto& _CustomLevelScripts = DynOS_Lvl_GetArray();
for (s32 i = 0; i < _CustomLevelScripts.Count(); ++i) {
auto& pair = _CustomLevelScripts[i];

View file

@ -8690,7 +8690,7 @@
- `string`
### C Prototype
`char* network_get_player_text_color_string(u8 localIndex);`
`const char* network_get_player_text_color_string(u8 localIndex);`
[:arrow_up_small:](#)

View file

@ -7558,7 +7558,7 @@
[CustomLevelInfo](structs.md#CustomLevelInfo)
### C Prototype
`struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(char* shortName);`
`struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(const char* shortName);`
[:arrow_up_small:](#)

View file

@ -904,7 +904,7 @@
- `string`
### C Prototype
`char* get_os_name(void);`
`const char* get_os_name(void);`
[:arrow_up_small:](#)
@ -2413,7 +2413,7 @@
- `string`
### C Prototype
`char* smlua_text_utils_get_language(void);`
`const char* smlua_text_utils_get_language(void);`
[:arrow_up_small:](#)

View file

@ -4,7 +4,7 @@
#include "bass_audio_helpers.h"
HSTREAM bassh_create_fx_stream_from_file(char* data, QWORD length, QWORD offset) {
HSTREAM bassh_create_fx_stream_from_file(const char* data, QWORD length, QWORD offset) {
HSTREAM raw_stream = BASS_StreamCreateFile(TRUE, data, offset, length, BASS_STREAM_PRESCAN | BASS_STREAM_DECODE);
HSTREAM stream = BASS_FX_TempoCreate(raw_stream, BASS_STREAM_PRESCAN);
@ -12,7 +12,7 @@ HSTREAM bassh_create_fx_stream_from_file(char* data, QWORD length, QWORD offset)
return stream;
}
HSAMPLE bassh_create_sample_from_file(char* data, QWORD length, QWORD offset) {
HSAMPLE bassh_create_sample_from_file(const char* data, QWORD length, QWORD offset) {
return BASS_SampleLoad(TRUE, data, offset, length, MAX_SAMPLE_CONCURRENT_PLAYBACKS, BASS_SAMPLE_OVER_POS);
}

View file

@ -2,8 +2,8 @@
#define MAX_SAMPLE_CONCURRENT_PLAYBACKS 32
HSTREAM bassh_create_fx_stream_from_file(char* data, QWORD length, QWORD offset);
HSAMPLE bassh_create_sample_from_file(char* data, QWORD length, QWORD offset);
HSTREAM bassh_create_fx_stream_from_file(const char* data, QWORD length, QWORD offset);
HSAMPLE bassh_create_sample_from_file(const char* data, QWORD length, QWORD offset);
HSTREAM bassh_sample_get_stream(HSAMPLE sample);
void bassh_free_sample(HSAMPLE sample);

View file

@ -280,7 +280,7 @@ static void crash_handler_produce_one_frame() {
gfx_end_frame();
}
static void crash_handler_add_info_str(CrashHandlerText** pTextP, f32 x, f32 y, char* title, char* value) {
static void crash_handler_add_info_str(CrashHandlerText** pTextP, f32 x, f32 y, const char* title, const char* value) {
CrashHandlerText* pText = *pTextP;
crash_handler_set_text(x, y, 0xFF, 0xFF, 0x00, "%s", title);
crash_handler_set_text(-1, y, 0xFF, 0xFF, 0xFF, "%s", ": ");
@ -288,7 +288,7 @@ static void crash_handler_add_info_str(CrashHandlerText** pTextP, f32 x, f32 y,
*pTextP = pText;
}
static void crash_handler_add_info_int(CrashHandlerText** pTextP, f32 x, f32 y, char* title, int value) {
static void crash_handler_add_info_int(CrashHandlerText** pTextP, f32 x, f32 y, const char* title, int value) {
CrashHandlerText* pText = *pTextP;
crash_handler_set_text(x, y, 0xFF, 0xFF, 0x00, "%s", title);
crash_handler_set_text(-1, y, 0xFF, 0xFF, 0xFF, "%s", ": ");

View file

@ -67,7 +67,7 @@ static void strncat_len(char* destination, char* source, size_t destinationLengt
static void discord_populate_details(char* buffer, int bufferLength) {
// get version
char* version = get_version();
const char* version = get_version();
int versionLength = strlen(version);
snprintf(buffer, bufferLength, "%s", version);
buffer += versionLength;

View file

@ -58,7 +58,7 @@ void djui_chat_message_create_from(u8 globalIndex, const char* message) {
return;
}
char* playerColorString = network_get_player_text_color_string(np->localIndex);
const char* playerColorString = network_get_player_text_color_string(np->localIndex);
char chatMsg[256] = { 0 };
snprintf(chatMsg, 256, "%s%s:\\#dcdcdc\\ %s", playerColorString, (np != NULL) ? np->name : "Player", message);

View file

@ -34,7 +34,7 @@ void djui_panel_main_create(struct DjuiBase* caller) {
djui_button_create(body, DLANG(MAIN, QUIT), DJUI_BUTTON_STYLE_BACK, djui_panel_main_quit);
}
char* version = get_version_local();
const char* version = get_version_local();
struct DjuiText* footer = djui_text_create(&panel->base, version);
djui_base_set_size_type(&footer->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE);
djui_base_set_size(&footer->base, 1.0f, 1.0f);

View file

@ -54,7 +54,7 @@ void gfx_cc_get_features(struct ColorCombiner* cc, struct CCFeatures* ccf) {
}
}
void gfx_cc_print(struct ColorCombiner *cc) {
void gfx_cc_print(UNUSED struct ColorCombiner *cc) {
if (!sAllowCCPrint) { return; }
// disabled for now
return;

View file

@ -47,7 +47,7 @@ int smlua_pcall(lua_State* L, int nargs, int nresults, UNUSED int errfunc) {
return rc;
}
void smlua_exec_file(char* path) {
void smlua_exec_file(const char* path) {
lua_State* L = gLuaState;
if (luaL_dofile(L, path) != LUA_OK) {
LOG_LUA("Failed to load lua file '%s'.", path);
@ -56,7 +56,7 @@ void smlua_exec_file(char* path) {
lua_pop(L, lua_gettop(L));
}
void smlua_exec_str(char* str) {
void smlua_exec_str(const char* str) {
lua_State* L = gLuaState;
if (luaL_dostring(L, str) != LUA_OK) {
LOG_LUA("Failed to load lua string.");

View file

@ -41,8 +41,8 @@ extern struct Mod* gLuaLastHookMod;
void smlua_mod_error(void);
int smlua_error_handler(UNUSED lua_State* L);
int smlua_pcall(lua_State* L, int nargs, int nresults, int errfunc);
void smlua_exec_file(char* path);
void smlua_exec_str(char* str);
void smlua_exec_file(const char* path);
void smlua_exec_str(const char* str);
void smlua_init(void);
void smlua_update(void);

View file

@ -643,7 +643,7 @@ void smlua_cobject_init_globals(void) {
}
}
void smlua_cobject_init_per_file_globals(char* path) {
void smlua_cobject_init_per_file_globals(const char* path) {
lua_State* L = gLuaState;
lua_getfield(L, LUA_REGISTRYINDEX, path); // push per-file globals

View file

@ -71,7 +71,7 @@ struct LuaObjectField* smlua_get_object_field_from_ot(struct LuaObjectTable* ot,
struct LuaObjectField* smlua_get_object_field(u16 lot, const char* key);
struct LuaObjectField* smlua_get_custom_field(lua_State* L, u32 lot, int keyIndex);
void smlua_cobject_init_globals(void);
void smlua_cobject_init_per_file_globals(char* path);
void smlua_cobject_init_per_file_globals(const char* path);
void smlua_bind_cobject(void);
#endif

View file

@ -27451,7 +27451,7 @@ int smlua_func_smlua_level_util_get_info_from_short_name(lua_State* L) {
return 0;
}
char* shortName = (char*)smlua_to_cobject(L, 1, LOT_NONE);
const char* shortName = smlua_to_string(L, 1);
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "smlua_level_util_get_info_from_short_name"); return 0; }
smlua_push_object(L, LOT_CUSTOMLEVELINFO, smlua_level_util_get_info_from_short_name(shortName));

View file

@ -429,7 +429,7 @@ void smlua_set_sync_table_field_from_network(u64 seq, u16 modRemoteIndex, u16 ln
LUA_STACK_CHECK_END();
}
void smlua_sync_table_init_globals(char* path, u16 modRemoteIndex) {
void smlua_sync_table_init_globals(const char* path, u16 modRemoteIndex) {
LUA_STACK_CHECK_BEGIN();
lua_State* L = gLuaState;

View file

@ -11,7 +11,7 @@ enum LuaSyncTableType {
struct LSTNetworkType;
void smlua_set_sync_table_field_from_network(u64 seq, u16 modRemoteIndex, u16 lntKeyCount, struct LSTNetworkType* lntKeys, struct LSTNetworkType* lntValue);
void smlua_sync_table_init_globals(char* path, u16 remoteIndex);
void smlua_sync_table_init_globals(const char* path, u16 remoteIndex);
void smlua_bind_sync_table(void);
void smlua_sync_table_send_all(u8 toLocalIndex);

View file

@ -447,27 +447,27 @@ void smlua_push_pointer(lua_State* L, u16 lvt, void* p) {
}
}
void smlua_push_integer_field(int index, char* name, lua_Integer val) {
void smlua_push_integer_field(int index, const char* name, lua_Integer val) {
lua_pushinteger(gLuaState, val);
lua_setfield(gLuaState, index, name);
}
void smlua_push_number_field(int index, char* name, lua_Number val) {
void smlua_push_number_field(int index, const char* name, lua_Number val) {
lua_pushnumber(gLuaState, val);
lua_setfield(gLuaState, index, name);
}
void smlua_push_string_field(int index, char* name, const char* val) {
void smlua_push_string_field(int index, const char* name, const char* val) {
lua_pushstring(gLuaState, val);
lua_setfield(gLuaState, index, name);
}
void smlua_push_nil_field(int index, char* name) {
void smlua_push_nil_field(int index, const char* name) {
lua_pushnil(gLuaState);
lua_setfield(gLuaState, index, name);
}
void smlua_push_table_field(int index, char* name) {
void smlua_push_table_field(int index, const char* name) {
lua_newtable(gLuaState);
lua_setfield(gLuaState, index, name);
}
@ -498,7 +498,7 @@ void smlua_push_lnt(struct LSTNetworkType* lnt) {
///////////////////////////////////////////////////////////////////////////////////////////
lua_Integer smlua_get_integer_field(int index, char* name) {
lua_Integer smlua_get_integer_field(int index, const char* name) {
if (lua_type(gLuaState, index) != LUA_TTABLE) {
LOG_LUA_LINE("smlua_get_integer_field received improper type '%d'", lua_type(gLuaState, index));
gSmLuaConvertSuccess = false;
@ -510,7 +510,7 @@ lua_Integer smlua_get_integer_field(int index, char* name) {
return val;
}
lua_Number smlua_get_number_field(int index, char* name) {
lua_Number smlua_get_number_field(int index, const char* name) {
if (lua_type(gLuaState, index) != LUA_TTABLE) {
LOG_LUA_LINE("smlua_get_number_field received improper type '%d'", lua_type(gLuaState, index));
gSmLuaConvertSuccess = false;
@ -522,7 +522,7 @@ lua_Number smlua_get_number_field(int index, char* name) {
return val;
}
LuaFunction smlua_get_function_field(int index, char *name) {
LuaFunction smlua_get_function_field(int index, const char *name) {
if (lua_type(gLuaState, index) != LUA_TTABLE) {
LOG_LUA_LINE("smlua_get_function_field received improper type '%d'", lua_type(gLuaState, index));
gSmLuaConvertSuccess = false;
@ -645,7 +645,7 @@ LuaFunction smlua_get_any_function_mod_variable(const char *variable) {
///////////////////////////////////////////////////////////////////////////////////////////
char* smlua_lnt_to_str(struct LSTNetworkType* lnt) {
const char* smlua_lnt_to_str(struct LSTNetworkType* lnt) {
static char sLntStr[32] = "";
switch (lnt->type) {
case LST_NETWORK_TYPE_INTEGER:

View file

@ -30,19 +30,19 @@ bool packet_read_lnt(struct Packet* p, struct LSTNetworkType* lnt);
void smlua_push_object(lua_State* L, u16 lot, void* p);
void smlua_push_pointer(lua_State* L, u16 lvt, void* p);
void smlua_push_integer_field(int index, char* name, lua_Integer val);
void smlua_push_number_field(int index, char* name, lua_Number val);
void smlua_push_string_field(int index, char* name, const char* val);
void smlua_push_nil_field(int index, char* name);
void smlua_push_table_field(int index, char* name);
void smlua_push_integer_field(int index, const char* name, lua_Integer val);
void smlua_push_number_field(int index, const char* name, lua_Number val);
void smlua_push_string_field(int index, const char* name, const char* val);
void smlua_push_nil_field(int index, const char* name);
void smlua_push_table_field(int index, const char* name);
void smlua_push_lnt(struct LSTNetworkType* lnt);
lua_Integer smlua_get_integer_field(int index, char* name);
lua_Number smlua_get_number_field(int index, char* name);
LuaFunction smlua_get_function_field(int index, char *name);
lua_Integer smlua_get_integer_field(int index, const char* name);
lua_Number smlua_get_number_field(int index, const char* name);
LuaFunction smlua_get_function_field(int index, const char *name);
char* smlua_lnt_to_str(struct LSTNetworkType* lnt);
const char* smlua_lnt_to_str(struct LSTNetworkType* lnt);
s64 smlua_get_integer_mod_variable(u16 modIndex, const char* variable);
s64 smlua_get_any_integer_mod_variable(const char* variable);

View file

@ -42,7 +42,7 @@ struct CustomLevelInfo* smlua_level_util_get_info(s16 levelNum) {
return NULL;
}
struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(char* shortName) {
struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(const char* shortName) {
struct CustomLevelInfo* node = sCustomLevelHead;
while (node != NULL) {
if (!strcmp(node->shortName, shortName)) {

View file

@ -20,7 +20,7 @@ struct CustomLevelInfo {
void smlua_level_util_reset(void);
struct CustomLevelInfo* smlua_level_util_get_info(s16 levelNum);
struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(char* shortName);
struct CustomLevelInfo* smlua_level_util_get_info_from_short_name(const char* shortName);
s16 level_register(const char* scriptEntryName, s16 courseNum, const char* fullName, const char* shortName, u32 acousticReach, u32 echoLevel1, u32 echoLevel2, u32 echoLevel3);
bool level_is_vanilla_level(s16 levelNum);
bool warp_to_warpnode(s32 aLevel, s32 aArea, s32 aAct, s32 aWarpId);

View file

@ -594,7 +594,7 @@ void set_override_envfx(s32 envfx) {
///
char* get_os_name(void) {
const char* get_os_name(void) {
#if defined(_WIN32) || defined(_WIN64)
return "Windows";
#elif __APPLE__ || __MACH__

View file

@ -128,6 +128,6 @@ u32 get_time(void);
u16 get_envfx(void);
void set_override_envfx(s32 envfx);
char* get_os_name(void);
const char* get_os_name(void);
#endif

View file

@ -261,6 +261,6 @@ void smlua_text_utils_extra_text_replace(s16 index, const char* text) {
sReplacedActName[index] = true;
}
char* smlua_text_utils_get_language(void) {
const char* smlua_text_utils_get_language(void) {
return configLanguage;
}

View file

@ -10,6 +10,6 @@ void smlua_text_utils_course_acts_replace(s16 courseNum, const char* courseName,
void smlua_text_utils_secret_star_replace(s16 courseNum, const char* courseName);
void smlua_text_utils_castle_secret_stars_replace(const char* name);
void smlua_text_utils_extra_text_replace(s16 index, const char* text);
char* smlua_text_utils_get_language(void);
const char* smlua_text_utils_get_language(void);
#endif

View file

@ -172,7 +172,7 @@ static void coopnet_populate_description(void) {
char* buffer = sCoopNetDescription;
int bufferLength = 256;
// get version
char* version = get_version();
const char* version = get_version();
int versionLength = strlen(version);
snprintf(buffer, bufferLength, "%s", version);
buffer += versionLength;

View file

@ -216,7 +216,7 @@ void network_player_update(void) {
}
extern bool gCurrentlyJoining;
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* palette, char *name) {
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* palette, const char *name) {
// translate globalIndex to localIndex
u8 localIndex = globalIndex;
if (gNetworkType == NT_SERVER) {

View file

@ -82,7 +82,7 @@ void network_player_palette_to_color(struct NetworkPlayer *np, enum PlayerParts
void network_player_update(void);
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* playerPalette, char* name);
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* playerPalette, const char* name);
u8 network_player_disconnected(u8 globalIndex);
void construct_player_popup(struct NetworkPlayer* np, char* msg, const char* level);

View file

@ -43,7 +43,7 @@ u8* network_get_player_text_color(u8 localIndex) {
return sTextRgb;
}
char* network_get_player_text_color_string(u8 localIndex) {
const char* network_get_player_text_color_string(u8 localIndex) {
if (localIndex >= MAX_PLAYERS) { localIndex = 0; }
u8* rgb = network_get_player_text_color(localIndex);
static char sColorString[10] = { 0 };

View file

@ -11,6 +11,6 @@ bool network_is_server(void);
bool network_is_moderator(void);
u8* network_get_player_text_color(u8 localIndex);
char* network_get_player_text_color_string(u8 localIndex);
const char* network_get_player_text_color_string(u8 localIndex);
#endif

View file

@ -5,7 +5,7 @@
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
static char sLocalVersionString[MAX_LOCAL_VERSION_LENGTH] = { 0 };
char* get_version(void) {
const char* get_version(void) {
#if defined(VERSION_US)
if (MINOR_VERSION_NUMBER > 0) {
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER);
@ -22,7 +22,7 @@ char* get_version(void) {
return sVersionString;
}
char* get_version_local(void) {
const char* get_version_local(void) {
if (PATCH_VERSION_NUMBER <= 0) {
return get_version();
}
@ -36,7 +36,7 @@ char* get_version_local(void) {
return sLocalVersionString;
}
char* get_game_name(void) {
const char* get_game_name(void) {
#ifdef DEVELOPMENT
return "sm64ex-coop-dev";
#elif !defined(VERSION_US)

View file

@ -18,8 +18,8 @@
#define MAX_VERSION_LENGTH 32
#define MAX_LOCAL_VERSION_LENGTH 36
char* get_version(void);
char* get_version_local(void);
char* get_game_name(void);
const char* get_version(void);
const char* get_version_local(void);
const char* get_game_name(void);
#endif

View file

@ -5,13 +5,13 @@
#include "os_win.h"
#include "pc/platform.h"
OS_DIR* os_opendir(char* path) {
OS_DIR* os_opendir(const char* path) {
wchar_t wpath[SYS_MAX_PATH] = { 0 };
MultiByteToWideChar(CP_UTF8, 0, path, -1, wpath, SYS_MAX_PATH);
return _wopendir(wpath);
}
char* os_get_dir_name(os_dirent* dir) {
const char* os_get_dir_name(os_dirent* dir) {
static char path[SYS_MAX_PATH] = { 0 };
snprintf(path, SYS_MAX_PATH, "%ls", dir->d_name);
return path;

View file

@ -9,5 +9,5 @@
#define os_closedir(_x) _wclosedir(_x)
#define os_readdir(_x) _wreaddir(_x)
OS_DIR* os_opendir(char* path);
char* os_get_dir_name(os_dirent* dir);
OS_DIR* os_opendir(const char* path);
const char* os_get_dir_name(os_dirent* dir);

View file

@ -349,7 +349,7 @@ void main_func(void) {
#error No rendering API!
#endif
char* version = get_version_local();
const char* version = get_version_local();
char window_title[96] = { 0 };
#ifdef GIT_HASH
snprintf(window_title, 96, "sm64ex-coop: %s [%s]", version, GIT_HASH);

View file

@ -3,7 +3,7 @@
#include <stdbool.h>
#include "string_linked_list.h"
void string_linked_list_append(struct StringLinkedList* node, char* string) {
void string_linked_list_append(struct StringLinkedList* node, const char* string) {
int length = strlen(string);
while (1) {
if (node->string == NULL) {
@ -20,7 +20,7 @@ void string_linked_list_append(struct StringLinkedList* node, char* string) {
}
}
bool string_linked_list_contains(struct StringLinkedList* node, char* string) {
bool string_linked_list_contains(struct StringLinkedList* node, const char* string) {
if (string == NULL) {
return false;
}

View file

@ -6,8 +6,8 @@ struct StringLinkedList {
struct StringLinkedList* next;
};
void string_linked_list_append(struct StringLinkedList* node, char* string);
bool string_linked_list_contains(struct StringLinkedList* node, char* string);
void string_linked_list_append(struct StringLinkedList* node, const char* string);
bool string_linked_list_contains(struct StringLinkedList* node, const char* string);
bool string_linked_list_mismatch(struct StringLinkedList* a, struct StringLinkedList* b);
int string_linked_list_count(struct StringLinkedList* node);
void string_linked_list_free(struct StringLinkedList* node);