diff --git a/assets/new_level.json b/assets/new_level.json index b517c5c..3e57ff7 100644 --- a/assets/new_level.json +++ b/assets/new_level.json @@ -346,11 +346,6 @@ "id":21, "name":"PLAYER", "properties":[ - { - "name":"held_items", - "type":"string", - "value":"{.data = {ITEM_Scroll1}, .cur_index = 1}" - }, { "name":"standing", "type":"string", @@ -359,8 +354,8 @@ "rotation":0, "visible":true, "width":32, - "x":1528.58503401361, - "y":2542.40136054421 + "x":1533.91836734694, + "y":2659.73469387755 }, { "class":"", @@ -454,8 +449,8 @@ "rotation":0, "visible":true, "width":32, - "x":1451, - "y":2652.33333333333 + "x":743, + "y":2726.33333333333 }, { "class":"", @@ -504,8 +499,8 @@ "rotation":0, "visible":true, "width":32, - "x":1505.33333333333, - "y":2401.33333333333 + "x":1537.33333333333, + "y":2517.33333333333 }], "opacity":1, "type":"objectgroup", diff --git a/build_web_common.bat b/build_web_common.bat index 9b2d86c..224a5c9 100644 --- a/build_web_common.bat +++ b/build_web_common.bat @@ -7,7 +7,8 @@ copy main.c %OUTPUT_FOLDER%\main.c || goto :error emcc ^ -sEXPORTED_FUNCTIONS=_main,_end_text_input,_stop_controlling_input,_start_controlling_input,_read_from_save_data,_dump_save_data,_is_receiving_text_input^ -sEXPORTED_RUNTIME_METHODS=ccall,cwrap^ - -s ALLOW_MEMORY_GROWTH -s TOTAL_STACK=5242880^ + -s INITIAL_MEMORY=62914560^ + -s ALLOW_MEMORY_GROWTH -s TOTAL_STACK=15728640^ %FLAGS%^ -Ithirdparty -Igen main.c -o %OUTPUT_FOLDER%\index.html --preload-file assets --shell-file web_template.html || goto :error @echo off diff --git a/main.c b/main.c index 66c05b9..e81c3d7 100644 --- a/main.c +++ b/main.c @@ -53,6 +53,7 @@ typedef struct WebArena size_t pos; } WebArena; + WebArena *web_arena_alloc() { WebArena *to_return = malloc(sizeof(to_return)); @@ -130,6 +131,15 @@ void web_arena_set_auto_align(WebArena *arena, size_t align) #endif #include "profiling.h" +MD_String8 nullterm(MD_Arena *copy_onto, MD_String8 to_nullterm) +{ + MD_String8 to_return = {0}; + to_return.str = MD_PushArray(copy_onto, MD_u8, to_nullterm.size + 1); + to_return.size = to_nullterm.size + 1; + to_return.str[to_return.size - 1] = '\0'; + memcpy(to_return.str, to_nullterm.str, to_nullterm.size); + return to_return; +} @@ -4447,10 +4457,10 @@ void frame(void) #ifdef WEB // fire off generation request, save id MD_ArenaTemp scratch = MD_GetScratch(0, 0); - MD_String8 terminated_completion_url = FmtWithLint(scratch.arena, "%s:%d/completion\0", SERVER_DOMAIN, SERVER_PORT); + MD_String8 terminated_completion_url = nullterm(scratch.arena, FmtWithLint(scratch.arena, "%s://%s:%d/completion", IS_SERVER_SECURE ? "https" : "http", SERVER_DOMAIN, SERVER_PORT)); int req_id = EM_ASM_INT( { - return make_generation_request(UTF8ToString($1, $2), UTF8ToString($0)); - }, terminated_completion_url.str, prompt_str.str, prompt_str.size); + return make_generation_request(UTF8ToString($0, $1), UTF8ToString($2, $3)); + }, prompt_str.str, (int)prompt_str.size, terminated_completion_url.str, (int)terminated_completion_url.size); it->gen_request_id = req_id; MD_ReleaseScratch(scratch); #endif diff --git a/web_template.html b/web_template.html index ede8f63..6f0f4a4 100644 --- a/web_template.html +++ b/web_template.html @@ -447,12 +447,13 @@ function set_server_url(p) { // Returns an integer, a "handle" into the generation request. Takes in the string prompt, and api URL // the api url must start with `http://` or https. function make_generation_request(p, api) { + cur_id += 1; let to_push = { "id": cur_id, "request": new XMLHttpRequest(), "retries_remaining": max_retries, - "request_info": {"url": api, "body": p}, + "request_info": {"url": (' ' + api).slice(1), "body": p}, "failed": false, } console.log("Making generation request with id " + to_push.id);