Skip to content

Commit c48e30c

Browse files
committed
Fix IB_LAUNCHER bitflag
1 parent 7d14918 commit c48e30c

File tree

4 files changed

+46
-9
lines changed

4 files changed

+46
-9
lines changed

include/common.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@
3434

3535
#define IB_CLIENT (0x1 << 0)
3636
#define IB_SERVER (0x1 << 1)
37-
#define IB_LAUNCHER (IB_CLIENT | IB_SERVER)
38-
#define IB_MAIN_LOADED (0x1 << 2)
39-
#define IB_MAIN_LOADING (0x1 << 3)
40-
#define IB_ENET (0x1 << 4)
37+
#define IB_LAUNCHER (0x1 << 2)
38+
#define IB_MAIN_LOADED (0x1 << 3)
39+
#define IB_MAIN_LOADING (0x1 << 4)
40+
#define IB_ENET (0x1 << 5)
4141

4242
#define IB_QUIT_SHUTDOWN (0x1 << 0)
4343
#define IB_QUIT_RESTART (0x1 << 1)
@@ -621,6 +621,7 @@ int error_sdl(char *msg);
621621
int error_perror(char *msg);
622622

623623
#ifndef DEDI
624+
void ib_create_launcher(int port, const char *pkg);
624625
void ib_create_server(int port, const char *pkg);
625626
void ib_join_server(const char *address, int port);
626627
#endif

pkg/iceball/launch/main_client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function client.hook_key(key, state, modif, uni)
9696
client.create_server(20737, "pkg/base")
9797
-- client.mk_sys_execv("-s", "20737", "pkg/base", arg_closure(argv))
9898
elseif key == SDLK_c then
99-
client.create_server(0, "pkg/iceball/config")
99+
client.create_launcher(0, "pkg/iceball/config")
100100
-- client.mk_sys_execv("-l", "pkg/iceball/config")
101101
elseif key == SDLK_ESCAPE then
102102
client.hook_tick = nil

src/lua.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ int icelua_fn_client_join_server(lua_State *L)
9999
int icelua_fn_client_create_server(lua_State *L)
100100
{
101101
if (!(boot_mode & IB_LAUNCHER))
102-
return luaL_error(L, "join_server called when not in -l mode");
102+
return luaL_error(L, "create_server called when not in -l mode");
103103

104104
int top = lua_gettop(L);
105105

@@ -111,6 +111,21 @@ int icelua_fn_client_create_server(lua_State *L)
111111
return 2;
112112
}
113113

114+
int icelua_fn_client_create_launcher(lua_State *L)
115+
{
116+
if (!(boot_mode & IB_LAUNCHER))
117+
return luaL_error(L, "create_launcher called when not in -l mode");
118+
119+
int top = lua_gettop(L);
120+
121+
int port = lua_tonumber(L, -2);
122+
const char *pkg = lua_tostring(L, -1);
123+
124+
ib_create_launcher(port, pkg);
125+
126+
return 2;
127+
}
128+
114129
int icelua_fn_client_mk_sys_execv(lua_State *L)
115130
{
116131
if(!(boot_mode & IB_LAUNCHER))
@@ -238,6 +253,7 @@ int icelua_fn_client_mk_set_title(lua_State *L)
238253

239254
#ifndef DEDI
240255
struct icelua_entry icelua_client[] = {
256+
{icelua_fn_client_create_launcher, "create_launcher"},
241257
{icelua_fn_client_create_server, "create_server"},
242258
{icelua_fn_client_join_server, "join_server"},
243259
{icelua_fn_client_mk_set_title, "mk_set_title"},

src/main.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,26 @@ int64_t platform_get_time_usec(void)
409409
}
410410

411411
#ifndef DEDI
412+
void ib_create_launcher(int port, const char *pkg)
413+
{
414+
if (net_address) {
415+
free(net_address);
416+
}
417+
418+
net_address = NULL;
419+
net_port = port;
420+
421+
if (mod_basedir) {
422+
free(mod_basedir);
423+
}
424+
425+
mod_basedir = malloc(PATH_LEN_MAX);
426+
mod_basedir = strncpy(mod_basedir, pkg, PATH_LEN_MAX);
427+
428+
restart_boot_mode = IB_LAUNCHER | IB_CLIENT | IB_SERVER;
429+
quitflag |= IB_QUIT_RESTART;
430+
}
431+
412432
void ib_create_server(int port, const char *pkg)
413433
{
414434
if (net_address) {
@@ -425,7 +445,7 @@ void ib_create_server(int port, const char *pkg)
425445
mod_basedir = malloc(PATH_LEN_MAX);
426446
mod_basedir = strncpy(mod_basedir, pkg, PATH_LEN_MAX);
427447

428-
restart_boot_mode = IB_LAUNCHER;
448+
restart_boot_mode = IB_CLIENT | IB_SERVER;
429449
quitflag |= IB_QUIT_RESTART;
430450
}
431451

@@ -986,7 +1006,7 @@ static int parse_args(int argc, char *argv[], struct cli_args *args) {
9861006
if (argc <= 1) {
9871007
args->net_port = 0;
9881008
args->basedir = strncpy(args->basedir, "pkg/iceball/launch", PATH_LEN_MAX);
989-
args->boot_mode = IB_LAUNCHER;
1009+
args->boot_mode = IB_CLIENT | IB_SERVER | IB_LAUNCHER;
9901010
args->used_args = 4;
9911011
} else
9921012
#endif
@@ -997,7 +1017,7 @@ static int parse_args(int argc, char *argv[], struct cli_args *args) {
9971017
} else if (!strcmp(argv[1], "-l")) {
9981018
// TODO: Merge this with the argc <= 1 thing above
9991019
args->net_port = 0;
1000-
args->boot_mode = IB_LAUNCHER;
1020+
args->boot_mode = IB_CLIENT | IB_SERVER | IB_LAUNCHER;
10011021
// TODO: Ensure used_args values are correct
10021022
args->used_args = 2;
10031023
if (argc >= 3) {

0 commit comments

Comments
 (0)