From b8c71209f76c933ecac496eb6e4d9da4c07533c4 Mon Sep 17 00:00:00 2001 From: hkc Date: Thu, 3 Oct 2024 15:49:08 +0300 Subject: [PATCH] Inverse mode and some old things --- .gitignore | 3 + Makefile | 11 +++- img421.cpi | 1 + src/bot.c | 4 +- src/listen-fullmap.c | 86 ++++++++++++++++++++++++ src/live-1chunk.c | 22 ++++++- src/live.c | 21 +++++- src/obcb-write.c | 154 +++++++++++++++++++++++++++++++++++++++++++ 8 files changed, 296 insertions(+), 6 deletions(-) create mode 100644 img421.cpi create mode 100644 src/listen-fullmap.c create mode 100644 src/obcb-write.c diff --git a/.gitignore b/.gitignore index 9237432..43c300c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ obcb-nbd.so live bot live-1chunk +*.data +obcb-write +listen-fullmap diff --git a/Makefile b/Makefile index c4350ad..acc7f29 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CFLAGS += LDFLAGS := -lm OBJECTS := obj/obcb.o obj/mongoose.o -all: obcb obcb-nbd.so live +all: obcb obcb-nbd.so live live-1chunk listen-fullmap obcb-write test: obcb ./obcb @@ -16,9 +16,18 @@ live-1chunk-run: live-1chunk bot-run: bot ./bot +listen-fullmap-run: listen-fullmap + ./listen-fullmap + +obcb-write: ./src/obcb-write.c $(OBJECTS) + $(CC) $(CFLAGS) $(OBJECTS) src/obcb-write.c $(LDFLAGS) -o obcb-write -lraylib -lm + bot: ./src/bot.c $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) src/bot.c $(LDFLAGS) -o bot -lraylib -lm +listen-fullmap: ./src/listen-fullmap.c $(OBJECTS) + $(CC) $(CFLAGS) $(OBJECTS) src/listen-fullmap.c $(LDFLAGS) -o listen-fullmap -lraylib -lm + live: ./src/live.c $(OBJECTS) $(CC) $(CFLAGS) $(OBJECTS) src/live.c $(LDFLAGS) -o live -lraylib -lm diff --git a/img421.cpi b/img421.cpi new file mode 100644 index 0000000..fad5ad7 --- /dev/null +++ b/img421.cpi @@ -0,0 +1 @@ +țzȉzzzxzzzzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzȉzxʙȒțzʈxʑzxzxʉʒʘxȔʅșzʐxzȑzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzʑʔȎʛzzzzzzzzzzzzxzʉʙzzzʑʙʑzȂxʛʑʙʖʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzzʘȉzʘzzʑzȐʙʐșʗzʈxzȗʘȉzzzʐșxzzzʘȊʊzzʑzxzxzȐzzzxȒȒʛʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzʒʖzɈzxʟzzzșȄʔʔzxzzzʉxțȒzʔxȒzxzzȖʗʉȝʒʛzʒʛʛʒʙzzzzzȖʛʔzzzzʛzʚzȒʔʖzʄʔzʅzʆzʅzʛzʅzzʚzȒʔʖzʄʔzʅzʆzʅzʛzʅzʑωʑxȃzzzʒzzzzȒʄʄȉʒșzzzzzzʛȐʙzzʒʛʞʚʉzzȗzzzzxzȒzȑʕʉxʄʙʒʆʙʉxzzțʙzʙʒzʔzxzxʘʒzʑzxzzʒʆʙʉxzzțʙzʙʒzʔzxzʞ|ǟzzzzʒʒzzzʒȒʛxzxzzȈzzʒxzzȞzxzȒxʒʔzzzʑȑʑxzzȒzzțȚȞzʒxzʆxzzȒzʘȑʚʈȒʙzʑzȒʔzʄxʛxʛʙzȗzzȑʙzzȖzȉϓzxʚzʒȐʕzzșʈȚzʙʂșʐʚzʈzzzȆxzʈzʁzzzxʒʄȖʄzʄʑʔzȒzzzʛzʑzzȔʑȉȘzʟʑʔzxzʑzʉzzzzțzzzʑzzȔʅzzʉȐzʒʛȖzʄțʆzzǕzzxzʔzxzxțzzʚzzțzzzȚʒzțzʖʆzzxʑțzzzzzzzȒzʒʄțzʛȔzzȑzzʑʒxzʛȈȑʛzȉʒzxzzzȉʒʛzzzʙzNJzzʛʑxȐʚzxȑȚʘʉʒʛxzʛzzʔzxzzzʒzʑxzʛzʐzȆȒzzxʛȝʙșzȅzʒʛzȑzzȄʚʐʙzțʐʙʉzȒʔʙzʛʘȘʒʛxzʔʛzǂȉxxʑxzzșʙȑzxʙzʑȄzzxzʒzȘzʈʒzȈxzzzxʌȒzʔzzzzȉzzțzʛzʈȐʖzzxzȒzșȒzʒʘzzʄțȘʒʛʙʑzzʆzʘzʛzzzʔzzțȄzʔz~ϐx,ʛʟzȗzʔʑȄțțʘȗzzʒxzʑzzȘzzzzȄʙʘzzzzʖʉxzʑzzʛzțȑzʉzȈxzzʒxzʄʔʅzțʘzȊzʛʛzʉȒʆʄșșzʛzϛ,((ʈǟzzʒʛzȒzzzȉzʛțzșzzxʟzʑʔzʓzzʛʔzzȒʙxzzzʒʛzʔʛʖʚȒʆʒzzȉzʛzȒzzȉʉȒʙxzʒzșʝʉxzzzzʉzȚzzzȄzʃ~z,Ϙυ򂨄((((ꅌ|zzxʒȘzʒʄzxxzxʙȉzʉʒʛzxșzȒʛʛʘʝʖzȄzʑzxzxzzʅzȗʛzʉzxzzzzțʈʑʚȊzzʛʐȖzxʉʈʙʒȗzțȔʛʔzzșȒʙÁ,ʀxʇzȞ(蛂.ꕇlψϗʛʗxʄzxzȈxzzzzxʒzʆʛʉʈʘʉʑșʝʅzȞȒʛȉʒzzzȝzʐzzzʄșȖȘʉʑʉxșzzzzȈȒzzȘzʉxzzʒxzșzzȉʑzxʆțȈȒzʅț((ꓧ/򂨛蕇LʘzxzʐzȞzzxʛzzzʒʒzȚzțșȚzʒșșxzʒzʒȒzzzzʘȝʅzșzțʒʛzzʘʙʞzʖzzzzzzzzzȎȗʑʑșʄ|NjǏϕȑ(((((.zzzr(((,ϚǃϟzʘzzʙʛȗzzzʘȉʘʖxzzzȘzȔzzʄʅzʑzxʅʑzșȔʑxzzʆțȈxzʑzzʉzʙʛʈȝzzʗzʉʉzzʑzzzȖʈxzzʛ虧Ȕǟ~ʄ(((.((ꕇzzz(((((ⅇ荬ȉʒʛʑʛʙʁȗzzȉzʄzzșʒzzzʒʙʆʄțșȒʆȆzʅzzʒzzzzʘʒzȒʔȉʉʚzʉʒȚzʘzzʛzzzxzzʑʉxȞzzʖzzȒʄȑzʊʚzϐxw((((臯Njzȅxxhh,rǙϔLǚϐύʚzʛzʑʙɉʑȚzzxșzzʙzzʅȄʔxʖzșxzʒzșʑȄʚzʙʆțʒzȊʐȉxzzʙzzȄzțzzzxxzzzzzzxʔzʒzʑ~(rz(.,'zʛʋzǒzzzzxʞʒzxʚxʒțzȆȆʗʔzʈȉzșȊʚzzzʚzʉʒʛʒʙȉzʔzʕʈȈxʈʒzxzzʛșzʒxʆʙʒzʑȚʈțxzʒzʒzzxʙzzʒʛzʇzz(((z{x(ʈʇ򒏁sh8zwzτzzʈȄʙȊzʑzzȒʄȊxʚʔzȝʛzȊzzȒzxzzȒzʛʒxȚzzzzȚzzʊzʛzʊzʑʛȔzȄzxʄʙʑzȘzzxxzzzzzșʑʙzzʑzʒʆʛzʂʐ(((((₧rȄ(,r8ȚxǘxǀwωzʑzzzzʉxzzʒxʅʉzxʞzʉzzzȔʆțzȈxʗʔʆțʑzxzʘʑʙʑzxzzzzȑʙʑzxʎȚʑʅzxʙzʙzxʔʅzzʑʑȚʒzzȑzːʙzȒzxʙxzʞhh(.r(((((,((ꊇ8ʁʋz{LjψzʛʙʟxȅʚzzxʗʉzʚzʉʒʙzʗzzzʛzȔʙzxxʁȄxxzzʔzxʙʈȘxʛxșzzzȕzzzxʔzʘȊzʄzzʄʔʆʛxzzȉʒʛʔzzzˆ(((.τ((((((r/ʉʁʝϒʉȒʛzȒʛʘxzʛxzzzʘzʒzzzzzzzȒzʒțzțzxʙzʚȝzʄʑzxzzʛʐxzʒʙxȒʛzzxzʟʒʛzzʑʉxzzʒzʙʛxzʆ,((((h((,ςȑ(((h(((((zxzψϛxzzșʊʘzzxʛzʑzʄxzʛzȗzzxȑʑzzȘʑȑȖʚxʙzʞzzzx˒zʑzz˒ʛțzʑzzzzʞȒzzʚzzʕzʃz(((((h(ʇ❂(ȟ,Ȅ(((..|ϒϒʚȑzșzzȑzʘzzțxʑʙʒzzzzʉzȘzzʒzxzʑʆzȔʅzzșʙțzzʄʑʔzxʒʔʉʞʒʛʖʛʘʉȈȉzʈ((((h(h(藌ϑϕ(((((((.|zxʛʗzʉzʛțȗʔzȆzzȑʔzȑzȒʛʙȆʛzzʘʑzzzzzʚʑzzzʔzȂʄȄ蚬zzșzʑʑșʈȉȘʁșʛzzzʝ(((((⛎ʗz(((((((ℨꗬϘ|ϒϐϛʛzʉzșȚʒʛțxzzxxzʒzzʒxxzȞzʑʛxzʒzʐxzxzzxzțzzțzʙzʕzzʑʙzzʆʒzʙzzʄ(((.Ꝃ蚬ǀrȂ,,,ϒϞϛʑʉzʑzxzʄxțzzʚzzxʒʛzȑzzʞzzʝʛzxʑxʙzzʂzzzʖzțxʛȔʅʙʔʙzȉʒȈȘzzʛzțʔʉxʚ'(.(Ꝃ(ʈꕏ|ȉϒʚzzʒzxʔʙzʄȑzzxzʘȘzʄʔzzzxʘʖʆzșʖʙzȑzʉʂțʅzʑzxʉʞzʘzʐȚȞzʊʐzɘzȘzʒʙzʉʒʔșʒʆʔʉxzʒʙzꞎ/ʂrrzρϘxȘʒzzʉzzȒȘʚzȒzzzʘzzʛzʙzʖzzʙʑʙ{ʛzzʒʛzȒʛz˒ʙʙʈzʑzxxxʙȒzʒxzșțxʑzzz˓ϟτ(x(((zzʑʑz{ʉzzzzxzzȘʒțzȉzȑzxȒʚzzʉzzzxzxȗzʑʉʙʂțzțțzzzțxzʑʛzʒʛzzzʙɉzzzȒzȝʐʔz”((zʞʌzʈȒʛʔzʛʈȉzxzțʖzzʑʙzȄzʌxʐȑʙʒʛxʆȘzzxʉȒʛʑʛʉȈʒȄzʒʐxzȒʛzzʒzȑʙʐxȒʛzʆʒʛzzʒzzrr((ꝬʄzxzʑzzzzȉʈʞzȈxʚɐʑzșȈzʙzʔʞzʔʙʒzȑzzzșzzzʝzzzʗʑʑzzʑzxxzzȒʖʉʝzʐȑzxȒzxzzzzȒʔzxzzȖz(((('zxzʆʛzzxʐʑȉʘʗʙʕzzȆzxzʉʘzzȒzʉzȔʆzʑzzȔzxzȒʛʔʉzʉzʙzʘȊzzzxzzzʑzxʒzȆzʒxʄʖzzʛʘʉxʑzȗȈzzʖσσσσσʖzșʄȆʆzʄțzzʔʖʛʒzʑʑxʘʞzȗzzʞzʉȘzȒʙzzʉȒʆȐzzʙxzzzʒzʒzzʑzzʒȚʟzʑʅzțȞʚzșɉʙʉzzzʑxʒzxˈzʔzxzʛzʘzʒȆzzzzʔzxzzzʒzzʄʔzȘzʘzzțʐȑʔzȘzzxxzȈzzʛʑz˒ʙzzʘʘzzzxȘʉxzzzȆʝzȑȉȐșʒxțzțʒʐzʉxzzxʐșʒzzȘʑxʘzʎțzxzʚțzxʙzșzʚzxzʙxȜzx,LQȄLxxʙȑʖʘʞzțȒzzzxzȆzzzzțzʔʙzxzʛʗʈʞʞzzzȚzzʈʄȑzzxȒʄʖʗʞȔʉzzȚzzzzzʒʒʔzzLȑLLL̓xxʛʒʛzȊzȘzʆțzʁȔʙɈzzxzʛ螌zxzxzzzʒʙȔʑxzxzʘȞzʔʉzzzzʑzzȒʙȔʙzȞzzʙzȁȁʟzxzxzʓxȑLLzxzzȖʒzzzzʚzzxzʙzzzzȒʆzʙxzʖțȔzʞʄxzȚȈzȒʛzʄȑʚʛʒzzzʚzz99xxzzȍLL΄Ξ΄xʝʙʐȇϊzzȘzzʗzzxʒxȄȑzzzzʞʞzȁȔʉȒzzxzxzzȒʛȒzȒzzzzxȟ̈́LxLȁ̆΄ʙʉzʐʖϑxzzzxʐzxʙʝzzzʙȒȘȉzzʙzȐʙzzȑȚxʍzzʞʉzʛzȔʚzzʐʚzxyyý͒ȟȄLȀ̒΁΁\zțzʞzʑzxzȒxȐʙzxʑțȔzzʒʄȄʖzzʆʘʘȈʑȆzȔʛzʄxʅzzțʘxxzzyyyّyy}xțȂLLğ|ΉΗǂʛzȉʝȇzȉʒʖʘxȒzʞʒʒʔzʞzxșˈzzʛxʕzʐʙʒȖʚʂțzzzʛzz狧zzzzyyٟy׈x؁Ȉ׈LLėȄΝ·ǖ|wwϘzzʄxȏǘǙDŽǁxʛzxʗʝʘzzzxxʔzzzșȒʚˈzʍzxzzzzz{yyٛי׈x~ΈΞΐxxz~τϒϛxʚxzzzzzʘȘʉʒʒzʑzzȉʈȘȞzȒʛʉǑΝΛ~~~z{yyy}yɂׂ|zϒρʅzzʐzxʘȒzʅzxzʔzzzʅzʛz~~z{{{}ׇxxȒבׄאΑ|̞΂wwxzzτzʒȐzzȐʑxʒxzʈȑțzzzxLΖϔ~{{{xxyɛ}}}}|܏ϟϐxx|xzzʒxzzȄxʒxʖzȒʄȑzzʛʒ̄{zʙzxǕזאןϚ,wwxzzxʒʆxzzzʛzʖzzʔʅzȈʒȍzzȇLǟzzzzʔzzx}}ׄן▬DŽwxzzȄʕzzʘʉȒʙȁzzȄȓzȒʔʑzzxȉȝʔzzzʙxܖ́}ū̕|zȄxșzxyyןߟǚꄨꕏʑʙʔzzxzȂxzʉʉxʙʈțxzzʂʄs9yי܈}ׂבǏǟ}xxʓʙʗʆțʒzzʄxȇzʒzyyyyy̖ʉ(((腏ȉʐzzxzzȗzzzzzzșʉʑzzΉ΄삧ʌx؟גׄǀw}xyzȝʙʞȗȘȉzʁșzzxzʙzzzzyyy߀w~,zꝂ.((荬ǗʑʒzȒzʒʔʉʔπzȉʒzzʒȒʛȝʞxzʑʛ~ΝΛ~΄zzzzzyyyȒzzʉxzʐșzʘʑzȒʊȝʚyyyy{xϙx(((xzȒʛȒʙȓz(((,xʛʑzzzzzȑzxȒʛzyxțzzxzzȔʑxȘzʙʘzzʒʆzʑʙxʕzz{zʒz((.,,ꕌʑzȒʛʛʒʆȈxʊxz((蛮ϗzȝzʉzțzʒʄzxzzzzzwwwyyȑʚʒʄȔʚzʘȘzʈzʘȈxȒʛzzȗʟ(➂ꝂxꝎʉʒʔzzȉxʙzȒȆʐ(((蚎zzʑȆzʙzʑzzʒzzʒzzzzzzzȐzzȞʑzzzzʔȒzxʞzzΛ~zzz{{{zʐșʑzzʚz(.┌ꛬωʑʕʑzzȒzȒzzʁ((((ꓬꂷzzȒʌȒʔʅzxxȑʑȒzȉzzxȔʚzzzzʅzʔzȄʑʘzȐșzzʘȊȈȚzzzʑʑʙʘʉzȊzzx~zz{ʔʉzzȒʛțȒʛzʂꟊʄꐧzꆇzȈȘzzʔʙʒȗʙʒǖ (⛎zzʛzzʅʔzzzʄȔʛzxzzʄʒȒʔzʛʉʑʙʉzzzzzzxzxʊʒʄxʑzzȞʈxzȋz~Ο΁~zzʑzzʈȒʛzzzȆzzzzʑʈ❬,ꒇʕzțʘzʟzȘzzʙz~8((,zzzzzʅzʑȒʔʙzʘȒʛ{ˑțʐʚțȞzzʕzxȑʙʑșʞzʉʒzțȒzʑțΟΟΝ~~zzʑzzȚzʑzȘʗʛzʛzwwȐʑxzȅϊϐ((˝ʔzʒxzȔʙȔzʐzʈȉxʛțʒzʆzʔzzzzʄțʛʉʉzʛzʒzȄxzx̀̑~~ʛʛzȚʘȚʈzʈȒzʒʛ虬ʙʄwwzxzxʅzʛLjh(((ʆʒzʉzțʙxzzʐʕzzȑʉxʖxȔzʒzȚʝʈȐʑzxzȘzzzzțzʙzʔʙʞz~ʑʑxțʙʉȗʑțzʒzzzʞz~xzʒʒzʑxʖx((꒬xʐʒzxxʒzʐzʒzzz{ʙzʉxzzʖȒʙzȒʙȘzțz|Έzzʒxzʔzʁzțʐʙzzșzzzxzȑʔxʕ{ʑzȒzxϛr,(ʝzzzʙʝʛȒxzʒxȉzxʆȄȆȒʄșzʉȘȈzʛʗʘȈʑʉxzʘȊzzzȚʈʑʛȅxΟʒʆȒzʚʘʓzʘȉʈȘʒʔʙȑzʄxzʈʉzzzzʛʙʘȝ|z(⟊ʒșʙzȒʔʙxzzʛzzȑzʚʒʙʔʆzzʔzzșȝʒʛʘzzʞʒʔzxȒzzʒzʘȉʒʆʙȒʒʄxzzʉʉȅwzʒʛzʉz~z((((ꝮzʙxʙʒxzzȆzȄȉxzzxzzȈzzzzʛʑzȑʅʑzȒȐʑzz|xxʑzzzʑxzʘzzzȖʆțzzzʞzwțʍʞ'(((꟮ʏxxzzxșzșɒʄȒxzțzzȐzʒzȊzʉȘȉzʒʙzȌʒʆʋ|L|ΝΈϑȖzșʘzzʉzzȄțȘzzȉʗzzʉxȉʘʖzzțȄzȄz''((((,ʐzȉzʅʖʛʑʉzxzʄȈȉȕzxʙțzʊʊzʖzȔzxʁȆzxȐL|ǎʙʁȄʔʑzzzțzzzʙʑxʞșȈȒzzʚțzzzxzzzzzzxzˆ((((蔧ʉʒxzzzzȞʐȖʑzȚʊzșzxʙzLzȖʉʑzzxzzzȒzʝzzʔzzȑʛȗzʚzxz'((((((ʂzxțȐȗzʐʅʙxzʛʘzzʌʒzʆzzzȒzǖ͂\̒|zzzxțzzzȑʄțʉʞzxzzʒțȘȑʉzzȒʛzȑzzʈȒʔzʒz'((⟮zǒzxʛțʒțxxʟʁxzzxȊzzʑxz̞̀ȂǂzzxȆzzʙȒzzȆʆșțzʉzzxzʅȉzȉʈʙʗʆȐzwʄʙʒʛʘʉȒʄțȒzzzxr(((‹xʂțʒzzzșʞʓzzzʑʙʉzzzʖʈxzzȄ\\͖}߆LjDŽzʒzʒzxzʔzˈʑʑzzʑzzzxzȚzʛʑȂxzwwwwwwʘzzʙʞzzzșʞʛʗzzž((((,zzȑʑxzxʘʉʒʛȟȆxzʘzzʄșʒȒʓyx͕͊גח̉ǞʉzʑʆzȒʛzzzxȒʔzzzzʛzzʛȗzʛzzzzzʖʛzʖzzxʛzʉzʛzʒșzʄxzx((((,r,,xʘxzzxzzzʄzȒzzzzzxʑx{xyי׉ג׈ǑǝzzzʒʆțʘzzʉʘʘȘzʉzȉȘzzzȑʑʙzzțʛzzʒzȐʕzzxzz{zxʔzxțzȊzzzʒʔʖzzȘȉʒzzȈzʚʘʉȒʛʁʑzzʈ炇,ox(ʉxxxzzxzzʞxʙقٟ׈ǕDŽȒxxʒzȈzxzȘʈxzxzzȒȒʒxzʈxzzzzzʒȐʑzxzzȚzzʅzzzzzzxzzzzʞxxʒxȒʛȒʖzzʚzzʉxʗʊzr(脨.ȝʉʐʙʉzʛʒzzʈzzzzyyyߗ߂xʔzțzzzzʑșʉʝʉzzzțʄțzʘʉʞʛʛȕzʒxzʔʑzzzxzʟʄȏzzxzʄʛzʛzzxȒʔʔzzʘʑʙxzzzzȉzȈxzʒzzʄțȒʛzʖxz((❂ʙʑʉxȚȚʟʙȑzzzzʙˑzzzzyyy{ȒzzzxzʒzʛʞzzȐʙʐȉʙzʙzzzʒzʛʗʒzȒzțȞȄʔșzʘȁȚzzzȔʆzțxʆʆțzțʔzzxȈxʉʚʒʄʔʒzșzzzʖʔʙʄzʘzʑʛʉʈȖzꃧʐꖧzʛxzzzʔzȝx{zzzzzzȒzȒʛȒzȒʑzzzȉʒʖzzzxȑzzzȊzʈȑʚʁxȐzʑzzzzzʁȆzʔzʑzxʝȒzʈʖʖʙzzzzzțzʑȉzzzȒʄʔzzzzxzxzzȆʆțzzʏțȑȄzʒʛʉxzxzzzzxzʆȄʑʌȉzxʑzȘʚzzʑʙʒʔʉȐʙzȉzʚzxzʉʚzʒʙʔʉzʘxzʕzzzʑzzxzzzzʙzȒʌʂțzxzțzxzzʅʖʛʙzțȒȆʙzȑzzʙzzȑzȆzȔʙzșʉzzzzzʛʄzzzʄȑʅzzzȆʐzȆzzxˑʅzxʓzz{xȑȉzzzʒțzțʛxȘʉʒzxzȒʒȒzʛȒʔʙʒzʅʑzzzzʆzʑʙzʄxxʒzzȒzzz˒zzȒʔzȅʛʒzȈȘʉʁȄʒxʒzțxȄʙʝʑʆʛzʙʅzȒzʛʄxșzțʞzzxzxʋx \ No newline at end of file diff --git a/src/bot.c b/src/bot.c index eda1242..40ff4ff 100644 --- a/src/bot.c +++ b/src/bot.c @@ -125,7 +125,7 @@ int render_thread(void *_conn) { int failure = 0; for (int i = (rand() % OBCB_CHUNK_SIZE); true; i = (i + 1) % OBCB_CHUNK_SIZE) { -#if 0 +#if 1 int blk_index = i / 256; int blk_pos = shuffle[i % 256]; int ox = blk_pos & 15, oy = blk_pos >> 4; @@ -149,7 +149,7 @@ int render_thread(void *_conn) { if ((chunk_current[byte] & mask) != (chunk_target[byte] & mask)) { obcb_send_toggle_bit(ws, index + dst_chunk_id * OBCB_CHUNK_SIZE); - usleep(2500); + usleep(5000); } else if (failure++ > 1024) { usleep(1000); failure = 0; diff --git a/src/listen-fullmap.c b/src/listen-fullmap.c new file mode 100644 index 0000000..958477b --- /dev/null +++ b/src/listen-fullmap.c @@ -0,0 +1,86 @@ +// x-run: make -C.. listen-fullmap-run +#include +#include +#include "mongoose.h" +#include +#include +#include "obcb.h" +#include "packets.h" + +#define OBCB_URL "ws://bitmap-ws.alula.me/" + +static uint8_t buffer_current[OBCB_BITMAP_SIZE / 8]; + +bool party_should_be_partying = true; + +static int mongoose_thread(void *mgr) { + mg_mgr_init(mgr); + while (party_should_be_partying) mg_mgr_poll(mgr, 1000); + mg_mgr_free(mgr); + return 0; +} + +static void mg_handler(struct mg_connection *c, int ev, void *ev_data) { + if (ev == MG_EV_OPEN) { + c->is_hexdumping = 0; + } else if (ev == MG_EV_WS_MSG) { + struct mg_ws_message *wsm = (struct mg_ws_message*)ev_data; + if (wsm->data.buf[0] == OBCB_MSG_HELLO) { + struct obcb_msg_hello hello; memcpy(&hello, &wsm->data.buf[1], sizeof(hello)); + printf("HELLO: v%d.%d. Why hello there, honey~\n", hello.version_major, hello.version_minor); + } else if (wsm->data.buf[0] == OBCB_MSG_STATS) { + struct obcb_msg_stats stats; memcpy(&stats, &wsm->data.buf[1], sizeof(stats)); + printf("STATS: %d clients connected\n", stats.current_clients); + } else if (wsm->data.buf[0] == OBCB_MSG_FULL_STATE_RESPONSE) { + struct obcb_msg_full_state_response state; memcpy(&state, &wsm->data.buf[1], sizeof(state)); + printf("Got full state\n"); + + memcpy(&buffer_current[state.chunk_index * OBCB_CHUNK_SIZE_BYTES], state.bitmap, OBCB_CHUNK_SIZE_BYTES); + } else { + printf("UNHANDLED MESSAGE 0x%02x\n", wsm->data.buf[0]); + } + } +} + +struct chunk { + double last_updated; + bool requested; +} chunks[OBCB_CHUNK_COUNT]; + + +int main(void) { + thrd_t mg_mgr_thread; + struct mg_mgr mg_manager; + struct mg_connection *mg_connections[OBCB_CHUNK_COUNT]; + + thrd_create(&mg_mgr_thread, mongoose_thread, &mg_manager); + + for (int i = 0; i < 64; i++) { + mg_connections[i] = mg_ws_connect( + &mg_manager, + OBCB_URL, + mg_handler, 0, + "User-Agent: maidcore/4.2.0 (kc.is.being.pet), mongoose.ws/" MG_VERSION "\r\n"); + } + + InitWindow(512, 512, "listener"); + SetTargetFPS(60); + + while (!WindowShouldClose()) { + double current_time = GetTime(); + BeginDrawing(); + ClearBackground(BLACK); + for (int i = 0; i < OBCB_CHUNK_COUNT; i++) { + int x = i % 64, y = i / 64; + double since_update = current_time - chunks[i].last_updated; + float alpha = 2.0 - sqrtf((since_update + 3.0) / 3.0); + DrawRectangle(x * 8, y * 8, 8, 8, Fade(RED, alpha)); + } + EndDrawing(); + } + + party_should_be_partying = false; + thrd_join(mg_mgr_thread, 0); + + return 0; +} diff --git a/src/live-1chunk.c b/src/live-1chunk.c index c542aab..aa042d9 100644 --- a/src/live-1chunk.c +++ b/src/live-1chunk.c @@ -1,8 +1,10 @@ // x-run: make -C.. CFLAGS+=-ggdb live-1chunk-run +#include #include #include "mongoose.h" #include #include +#include #include #include "obcb.h" #include "packets.h" @@ -15,6 +17,8 @@ int connected_clients = 0; double last_msg_time = 0; +uint8_t chunk_data[OBCB_CHUNK_SIZE_BYTES]; + static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { if (ev == MG_EV_OPEN) { printf("Connected to WebSocket\n"); @@ -38,6 +42,7 @@ static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { view[i] = state.bitmap[i >> 3] & (1 << (i & 7)) ? 0xff : 0x00; } last_msg_time = GetTime(); + memcpy(chunk_data, state.bitmap, OBCB_CHUNK_SIZE_BYTES); } else if (wsm->data.buf[0] == OBCB_MSG_PARTIAL_STATE_UPDATE) { struct obcb_msg_partial_state_update update; memcpy(&update, &wsm->data.buf[1], sizeof(update)); @@ -46,10 +51,13 @@ static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { if (chunk_index != chunk_id) return; + printf("Partial update\n"); + unsigned char *view = c->fn_data; for (int i = 0; i < OBCB_UPDATE_CHUNK_SIZE * 8; i++) { view[i + byte_offset * 8] = update.chunk[i >> 3] & (1 << (i & 7)) ? 0xFF : 0x00; } + memcpy(&chunk_data[byte_offset], update.chunk, OBCB_UPDATE_CHUNK_SIZE); last_msg_time = GetTime(); } else { printf("UNHANDLED MESSAGE 0x%02x\n", wsm->data.buf[0]); @@ -67,10 +75,14 @@ static int mongoose_thread(void *_mgr) { void DrawTextShadow(Font font, const char *txt, int x, int y, int size, Color color); -int main(void) { +int main(int argc, char **argv) { InitWindow(512, 512, "obcb-1chunk"); SetTargetFPS(60); + if (argc >= 2) { + chunk_id = atoi(argv[1]); + } + thrd_t mongoose_manager_thrd; thrd_create(&mongoose_manager_thrd, mongoose_thread, 0); @@ -95,9 +107,17 @@ int main(void) { for (int frame = 0; !WindowShouldClose(); frame++) { if (IsKeyPressed(KEY_R)) { printf("Requesting state again\n"); + obcb_send_partial_subscription(ws, chunk_id); obcb_send_full_state_request(ws, chunk_id); } + if (IsKeyPressed(KEY_S)) { + FILE *fp = fopen(TextFormat("save.%d.%d.data", time(0), chunk_id), "wb"); + printf("Saving...\n"); + fwrite(chunk_data, OBCB_CHUNK_SIZE_BYTES, 1, fp); + fclose(fp); + } + BeginDrawing(); UpdateTexture(tex, img.data); DrawTexture(tex, 0, 0, WHITE); diff --git a/src/live.c b/src/live.c index cf63b37..006465b 100644 --- a/src/live.c +++ b/src/live.c @@ -8,6 +8,7 @@ #include "obcb.h" #define WAITING_QUEUE_SIZE 48 +#define INVERSE_COLORS 1 static uint32_t connected_clients = 0; static bool running = true; @@ -59,7 +60,7 @@ struct img_and_tex { Texture2D tex; } blocks[32 * 32], subscribed; -int subscribed_chunk_id = 420; +int subscribed_chunk_id = -1; static struct waiting_queue_elem { uint16_t index; @@ -99,10 +100,18 @@ static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { int in_chunk_x = x % 1024, in_chunk_y = y % 1024; uint8_t *img = blocks[chunk_x + chunk_y * 32].img.data; bool bit = state.bitmap[i >> 3] & (1 << (i & 7)); +#if INVERSE_COLORS + img[in_chunk_x + in_chunk_y * 1024] = bit ? 0x00 : 0xFF; +#else img[in_chunk_x + in_chunk_y * 1024] = bit ? 0xFF : 0x00; +#endif if (state.chunk_index == subscribed_chunk_id) { +#if INVERSE_COLORS + view[i] = bit ? 0x00 : 0xFF; +#else view[i] = bit ? 0xFF : 0x00; +#endif } } @@ -115,7 +124,11 @@ static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { int chunk_x = x / 1024, chunk_y = y / 1024; int in_chunk_x = x % 1024, in_chunk_y = y % 1024; uint8_t *img = blocks[chunk_x + chunk_y * 32].img.data; +#if INVERSE_COLORS + img[in_chunk_x + in_chunk_y * 1024] = update.chunk[i >> 3] & (1 << (i & 7)) ? 0x00 : 0xFF; +#else img[in_chunk_x + in_chunk_y * 1024] = update.chunk[i >> 3] & (1 << (i & 7)) ? 0xFF : 0x00; +#endif } uint32_t chunk_index = update.offset / OBCB_CHUNK_SIZE_BYTES; @@ -124,7 +137,11 @@ static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { printf("That's our chunk!\n"); unsigned char *view = subscribed.img.data; for (int i = 0; i < OBCB_UPDATE_CHUNK_SIZE; i++) { +#if INVERSE_COLORS + view[i + byte_offset * 8] = update.chunk[i >> 3] & (1 << (i & 7)) ? 0x00 : 0xFF; +#else view[i + byte_offset * 8] = update.chunk[i >> 3] & (1 << (i & 7)) ? 0xFF : 0x00; +#endif } } } else { @@ -189,7 +206,7 @@ int main(void) { .zoom = 0.125 }; - double zoom = 1.0; + double zoom = 0.5; int req_chunk = 0; for (unsigned long frame = 0; !WindowShouldClose(); frame++) { diff --git a/src/obcb-write.c b/src/obcb-write.c new file mode 100644 index 0000000..f1bad3b --- /dev/null +++ b/src/obcb-write.c @@ -0,0 +1,154 @@ +// x-run: make -C.. obcb-write && ../obcb-write 421 ../img421.cpi + +#include "mongoose.h" +#include "obcb.h" +#include "packets.h" +#include +#include +#include +#include +#include + +void usage(const char *progname) { + printf("Usage: %s [page:int] [infile:path]\n", progname); +} + +int chunk_id = 0; +bool has_data = false; +size_t buffer_size = 0; +unsigned char buffer[OBCB_CHUNK_SIZE_BYTES], current[OBCB_CHUNK_SIZE_BYTES]; + +const uint8_t shuffle[256] = { + 0, 128, 64, 192, 32, 160, 96, 224, 16, + 144, 80, 208, 48, 176, 112, 240, 8, + 136, 72, 200, 40, 168, 104, 232, 24, + 152, 88, 216, 56, 184, 120, 248, 4, + 132, 68, 196, 36, 164, 100, 228, 20, + 148, 84, 212, 52, 180, 116, 244, 12, + 140, 76, 204, 44, 172, 108, 236, 28, + 156, 92, 220, 60, 188, 124, 252, 2, + 130, 66, 194, 34, 162, 98, 226, 18, + 146, 82, 210, 50, 178, 114, 242, 10, + 138, 74, 202, 42, 170, 106, 234, 26, + 154, 90, 218, 58, 186, 122, 250, 6, + 134, 70, 198, 38, 166, 102, 230, 22, + 150, 86, 214, 54, 182, 118, 246, 14, + 142, 78, 206, 46, 174, 110, 238, 30, + 158, 94, 222, 62, 190, 126, 254, 1, + 129, 65, 193, 33, 161, 97, 225, 17, + 145, 81, 209, 49, 177, 113, 241, 9, + 137, 73, 201, 41, 169, 105, 233, 25, + 153, 89, 217, 57, 185, 121, 249, 5, + 133, 69, 197, 37, 165, 101, 229, 21, + 149, 85, 213, 53, 181, 117, 245, 13, + 141, 77, 205, 45, 173, 109, 237, 29, + 157, 93, 221, 61, 189, 125, 253, 3, + 131, 67, 195, 35, 163, 99, 227, 19, + 147, 83, 211, 51, 179, 115, 243, 11, + 139, 75, 203, 43, 171, 107, 235, 27, + 155, 91, 219, 59, 187, 123, 251, 7, + 135, 71, 199, 39, 167, 103, 231, 23, + 151, 87, 215, 55, 183, 119, 247, 15, + 143, 79, 207, 47, 175, 111, 239, 31, + 159, 95, 223, 63, 191, 127, 255 +}; + + +static void obcb_mg_handler(struct mg_connection *c, int ev, void *ev_data) { + if (ev == MG_EV_OPEN) { + printf("Connected to WebSocket\n"); + } else if (ev == MG_EV_WS_OPEN) { + obcb_send_full_state_request(c, 0); + } else if (ev == MG_EV_WS_MSG) { + struct mg_ws_message *wsm = (struct mg_ws_message*)ev_data; + if (wsm->data.buf[0] == OBCB_MSG_HELLO) { + struct obcb_msg_hello hello; memcpy(&hello, &wsm->data.buf[1], sizeof(hello)); + printf("HELLO: v%d.%d. Why hello there, honey~\n", hello.version_major, hello.version_minor); + } else if (wsm->data.buf[0] == OBCB_MSG_STATS) { + struct obcb_msg_stats stats; memcpy(&stats, &wsm->data.buf[1], sizeof(stats)); + } else if (wsm->data.buf[0] == OBCB_MSG_FULL_STATE_RESPONSE) { + struct obcb_msg_full_state_response state; memcpy(&state, &wsm->data.buf[1], sizeof(state)); + if (state.chunk_index == chunk_id) { + memcpy(current, state.bitmap, OBCB_CHUNK_SIZE_BYTES); + } + has_data = true; + } else if (wsm->data.buf[0] == OBCB_MSG_PARTIAL_STATE_UPDATE) { + struct obcb_msg_partial_state_update update; memcpy(&update, &wsm->data.buf[1], sizeof(update)); + uint32_t chunk_index = update.offset / OBCB_CHUNK_SIZE_BYTES; + uint32_t byte_index = update.offset % OBCB_CHUNK_SIZE_BYTES; + if (chunk_index == chunk_id) { + memcpy(¤t[byte_index], update.chunk, OBCB_UPDATE_CHUNK_SIZE); + } + } else { + printf("UNHANDLED MESSAGE 0x%02x\n", wsm->data.buf[0]); + } + } +} + +int render_thread(void *_conn); + +int main(int argc, char **argv) { + if (argc < 3) { + usage(argv[0]); + return 1; + } + + chunk_id = atoi(argv[1]); + + FILE *fp = fopen(argv[2], "rb"); + buffer_size = fread(buffer, 1, OBCB_CHUNK_SIZE_BYTES, fp); + fclose(fp); + + printf("Writing %zu bytes at the chunk %d\n", buffer_size, chunk_id); + + struct mg_mgr manager; + mg_mgr_init(&manager); + struct mg_connection *ws = mg_ws_connect(&manager, "ws://bitmap-ws.alula.me/", obcb_mg_handler, 0, "%s", "User-Agent: maidcore/4.2.0 (kc.is.being.pet)\r\n"); + obcb_send_full_state_request(ws, chunk_id); + obcb_send_partial_subscription(ws, chunk_id); + + + time_t last_request = time(0); + int t = 0; + while (true) { + time_t now = time(0); + if ((now - last_request) > 10) { + obcb_send_full_state_request(ws, chunk_id); + last_request = now; + } + if (has_data) { + for (int j = 0; j < 32; j++){ + size_t i = ((t & ~0xFFL) | shuffle[t & 0xFF]) % buffer_size; + if (buffer[i] != current[i]) { + for (int bit = 0, mask = 1; bit < 8; bit++, mask <<= 1) { + if ((buffer[i] ^ current[i]) & mask) { + obcb_send_toggle_bit(ws, chunk_id * OBCB_CHUNK_SIZE + i * 8 + bit); + usleep(5000); + } + } + } + t++; + } + } + mg_mgr_poll(&manager, 100); + } + mg_mgr_free(&manager); + + return 0; +} + +int render_thread(void *_conn) { + struct mg_connection *ws = _conn; + while (!has_data) { + usleep(1000); + } + + printf("Got initial state!\n"); + + for (int t = 0; true; t++) { + if ((t % 100) == 0) { + usleep(100); + } + } +} +