Cameron Murphy Reikes 2 years ago
parent 5d8a977e9b
commit 20b7465780

@ -346,11 +346,6 @@
"id":21, "id":21,
"name":"PLAYER", "name":"PLAYER",
"properties":[ "properties":[
{
"name":"held_items",
"type":"string",
"value":"{.data = {ITEM_Scroll1}, .cur_index = 1}"
},
{ {
"name":"standing", "name":"standing",
"type":"string", "type":"string",
@ -359,8 +354,8 @@
"rotation":0, "rotation":0,
"visible":true, "visible":true,
"width":32, "width":32,
"x":1528.58503401361, "x":1533.91836734694,
"y":2542.40136054421 "y":2659.73469387755
}, },
{ {
"class":"", "class":"",
@ -454,8 +449,8 @@
"rotation":0, "rotation":0,
"visible":true, "visible":true,
"width":32, "width":32,
"x":1451, "x":743,
"y":2652.33333333333 "y":2726.33333333333
}, },
{ {
"class":"", "class":"",
@ -504,8 +499,8 @@
"rotation":0, "rotation":0,
"visible":true, "visible":true,
"width":32, "width":32,
"x":1505.33333333333, "x":1537.33333333333,
"y":2401.33333333333 "y":2517.33333333333
}], }],
"opacity":1, "opacity":1,
"type":"objectgroup", "type":"objectgroup",

@ -7,7 +7,8 @@ copy main.c %OUTPUT_FOLDER%\main.c || goto :error
emcc ^ 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_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^ -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%^ %FLAGS%^
-Ithirdparty -Igen main.c -o %OUTPUT_FOLDER%\index.html --preload-file assets --shell-file web_template.html || goto :error -Ithirdparty -Igen main.c -o %OUTPUT_FOLDER%\index.html --preload-file assets --shell-file web_template.html || goto :error
@echo off @echo off

@ -53,6 +53,7 @@ typedef struct WebArena
size_t pos; size_t pos;
} WebArena; } WebArena;
WebArena *web_arena_alloc() WebArena *web_arena_alloc()
{ {
WebArena *to_return = malloc(sizeof(to_return)); WebArena *to_return = malloc(sizeof(to_return));
@ -130,6 +131,15 @@ void web_arena_set_auto_align(WebArena *arena, size_t align)
#endif #endif
#include "profiling.h" #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 #ifdef WEB
// fire off generation request, save id // fire off generation request, save id
MD_ArenaTemp scratch = MD_GetScratch(0, 0); 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( { int req_id = EM_ASM_INT( {
return make_generation_request(UTF8ToString($1, $2), UTF8ToString($0)); return make_generation_request(UTF8ToString($0, $1), UTF8ToString($2, $3));
}, terminated_completion_url.str, prompt_str.str, prompt_str.size); }, prompt_str.str, (int)prompt_str.size, terminated_completion_url.str, (int)terminated_completion_url.size);
it->gen_request_id = req_id; it->gen_request_id = req_id;
MD_ReleaseScratch(scratch); MD_ReleaseScratch(scratch);
#endif #endif

@ -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 // 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. // the api url must start with `http://` or https.
function make_generation_request(p, api) { function make_generation_request(p, api) {
cur_id += 1; cur_id += 1;
let to_push = { let to_push = {
"id": cur_id, "id": cur_id,
"request": new XMLHttpRequest(), "request": new XMLHttpRequest(),
"retries_remaining": max_retries, "retries_remaining": max_retries,
"request_info": {"url": api, "body": p}, "request_info": {"url": (' ' + api).slice(1), "body": p},
"failed": false, "failed": false,
} }
console.log("Making generation request with id " + to_push.id); console.log("Making generation request with id " + to_push.id);

Loading…
Cancel
Save