Skip to content

Commit e7cd28a

Browse files
committed
Update global function, variable and table capitalisations in auto splitters
Functions such as 'split' must now be 'Split' Variables such as 'refreshRate' must now be 'RefreshRate' The 'state' table must now be 'State'
1 parent c4a692a commit e7cd28a

File tree

2 files changed

+31
-33
lines changed

2 files changed

+31
-33
lines changed

src/auto-splitter.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ bool call_va(lua_State* L, const char* func, const char* sig, ...)
248248

249249
int get_process_names(lua_State* L, char process_names[100][256], int* num_process_names)
250250
{
251-
lua_getglobal(L, "state");
251+
lua_getglobal(L, "State");
252252
if (lua_istable(L, -1)) {
253253
lua_pushnil(L);
254254
while (lua_next(L, -2) != 0) {
@@ -268,15 +268,15 @@ int get_process_names(lua_State* L, char process_names[100][256], int* num_proce
268268

269269
void startup(lua_State* L)
270270
{
271-
call_va(L, "startup", "");
271+
call_va(L, "Startup", "");
272272

273-
lua_getglobal(L, "refreshRate");
273+
lua_getglobal(L, "RefreshRate");
274274
if (lua_isnumber(L, -1)) {
275275
refresh_rate = lua_tointeger(L, -1);
276276
}
277277
lua_pop(L, 1); // Remove 'refreshRate' from the stack
278278

279-
lua_getglobal(L, "mapsCacheCycles");
279+
lua_getglobal(L, "MapsCacheCycles");
280280
if (lua_isnumber(L, -1)) {
281281
maps_cache_cycles = lua_tointeger(L, -1);
282282
maps_cache_cycles_value = maps_cache_cycles;
@@ -287,7 +287,7 @@ void startup(lua_State* L)
287287
bool update(lua_State* L)
288288
{
289289
bool ret;
290-
if (call_va(L, "update", ">b", &ret)) {
290+
if (call_va(L, "Update", ">b", &ret)) {
291291
lua_pop(L, 1);
292292
return ret;
293293
}
@@ -298,9 +298,9 @@ bool update(lua_State* L)
298298
bool start(lua_State* L)
299299
{
300300
bool ret;
301-
if (call_va(L, "start", ">b", &ret) && ret) {
301+
if (call_va(L, "Start", ">b", &ret) && ret) {
302302
atomic_store(&call_start, true);
303-
printf("start: true\n");
303+
printf("Start: true\n");
304304
lua_pop(L, 1);
305305
return true;
306306
}
@@ -311,9 +311,9 @@ bool start(lua_State* L)
311311
bool split(lua_State* L)
312312
{
313313
bool ret;
314-
if (call_va(L, "split", ">b", &ret) && ret) {
314+
if (call_va(L, "Split", ">b", &ret) && ret) {
315315
atomic_store(&call_split, true);
316-
printf("split: true\n");
316+
printf("Split: true\n");
317317
lua_pop(L, 1);
318318
return true;
319319
}
@@ -324,10 +324,10 @@ bool split(lua_State* L)
324324
void is_loading(lua_State* L)
325325
{
326326
bool ret;
327-
if (call_va(L, "isLoading", ">b", &ret)) {
327+
if (call_va(L, "IsLoading", ">b", &ret)) {
328328
if (ret != prev_is_loading) {
329329
atomic_store(&toggle_loading, true);
330-
printf("isLoading: %s\n", ret ? "true" : "false");
330+
printf("IsLoading: %s\n", ret ? "true" : "false");
331331
prev_is_loading = !prev_is_loading;
332332
}
333333
}
@@ -337,9 +337,9 @@ void is_loading(lua_State* L)
337337
bool reset(lua_State* L)
338338
{
339339
bool ret;
340-
if (call_va(L, "reset", ">b", &ret) && ret) {
340+
if (call_va(L, "Reset", ">b", &ret) && ret) {
341341
atomic_store(&call_reset, true);
342-
printf("reset: true\n");
342+
printf("Reset: true\n");
343343
lua_pop(L, 1);
344344
return true;
345345
}
@@ -349,10 +349,11 @@ bool reset(lua_State* L)
349349

350350
const char* version(lua_State* L)
351351
{
352-
lua_getglobal(L, "version");
352+
lua_getglobal(L, "Version");
353353
if (lua_isstring(L, -1)) {
354354
const char* version = lua_tostring(L, -1);
355355
lua_pop(L, 1);
356+
printf("Version: %s\n", version);
356357
return version;
357358
}
358359
lua_pop(L, 1);
@@ -392,16 +393,16 @@ void run_auto_splitter_cycle(
392393
if (!atomic_load(&timer_started)) {
393394
if (start_exists && start(L)) {
394395
if (on_start_exists) {
395-
call_va(L, "onStart", "");
396+
call_va(L, "OnStart", "");
396397
}
397398
}
398399
} else if (reset_exists && reset(L)) {
399400
if (on_reset_exists) {
400-
call_va(L, "onReset", "");
401+
call_va(L, "OnReset", "");
401402
}
402403
} else if (split_exists && split(L)) {
403404
if (on_split_exists) {
404-
call_va(L, "onSplit", "");
405+
call_va(L, "OnSplit", "");
405406
}
406407
}
407408

@@ -444,16 +445,16 @@ void run_auto_splitter()
444445
char current_file[PATH_MAX];
445446
strcpy(current_file, auto_splitter_file);
446447

447-
bool start_exists = lua_function_exists(L, "start");
448-
bool on_start_exists = lua_function_exists(L, "onStart");
449-
bool split_exists = lua_function_exists(L, "split");
450-
bool on_split_exists = lua_function_exists(L, "onSplit");
451-
bool is_loading_exists = lua_function_exists(L, "isLoading");
452-
bool startup_exists = lua_function_exists(L, "startup");
453-
bool reset_exists = lua_function_exists(L, "reset");
454-
bool on_reset_exists = lua_function_exists(L, "onReset");
455-
bool update_exists = lua_function_exists(L, "update");
456-
bool init_exists = lua_function_exists(L, "init");
448+
bool start_exists = lua_function_exists(L, "Start");
449+
bool on_start_exists = lua_function_exists(L, "OnStart");
450+
bool split_exists = lua_function_exists(L, "Split");
451+
bool on_split_exists = lua_function_exists(L, "OnSplit");
452+
bool is_loading_exists = lua_function_exists(L, "IsLoading");
453+
bool startup_exists = lua_function_exists(L, "Startup");
454+
bool reset_exists = lua_function_exists(L, "Reset");
455+
bool on_reset_exists = lua_function_exists(L, "OnReset");
456+
bool update_exists = lua_function_exists(L, "Update");
457+
bool init_exists = lua_function_exists(L, "Init");
457458
bool memory_map_exists = false;
458459

459460
if (startup_exists) {
@@ -469,16 +470,13 @@ void run_auto_splitter()
469470
if (get_process_names(L, process_names, &num_process_names)) {
470471
if (find_process_id(process_names, num_process_names)) {
471472
if (init_exists) {
472-
call_va(L, "init", "");
473+
call_va(L, "Init", "");
473474
}
474475
lua_newtable(L);
475476
lua_setglobal(L, "old");
476477
lua_newtable(L);
477478
lua_setglobal(L, "current");
478479
version_str = version(L);
479-
if (version_str) {
480-
printf("Version: %s\n", version_str);
481-
}
482480
memory_map_exists = store_memory_tables(L, version_str);
483481
}
484482
}
@@ -488,7 +486,7 @@ void run_auto_splitter()
488486
clock_gettime(CLOCK_MONOTONIC, &clock_start);
489487

490488
if (!process_exists() && find_process_id(process_names, num_process_names) && init_exists) {
491-
call_va(L, "init", "");
489+
call_va(L, "Init", "");
492490
} else if (!atomic_load(&auto_splitter_enabled) || strcmp(current_file, auto_splitter_file) != 0) {
493491
break;
494492
}

src/memory.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ int store_memory_tables(lua_State* L, const char* version)
216216
{
217217
memory_table_count = 0;
218218

219-
lua_getglobal(L, "state");
219+
lua_getglobal(L, "State");
220220
lua_getfield(L, -1, process.name);
221221

222222
if (version != NULL) {

0 commit comments

Comments
 (0)