mirror of https://git.sr.ht/~rabbits/parade
Fixed issue with nv creation
This commit is contained in:
parent
b58b9ae372
commit
44ec0c4122
|
@ -0,0 +1,18 @@
|
|||
Benchmark
|
||||
|
||||
answer(¶de, "create a teapot");
|
||||
answer(¶de, "become the teapot");
|
||||
answer(¶de, "enter the ghost");
|
||||
answer(¶de, "leave");
|
||||
|
||||
answer(¶de, "take the ghost");
|
||||
answer(¶de, "drop the ghost");
|
||||
answer(¶de, "warp in the teapot");
|
||||
answer(¶de, "transform into a bat");
|
||||
|
||||
answer(¶de, "note the bat is dark.");
|
||||
answer(¶de, "program create a teapot");
|
||||
answer(¶de, "warp to the library");
|
||||
answer(¶de, "become the ghost");
|
||||
answer(¶de, "use the bat");
|
||||
|
2
build.sh
2
build.sh
|
@ -1,11 +1,9 @@
|
|||
#!/bin/bash
|
||||
|
||||
clang-format -i main.c
|
||||
clang-format -i comm.c
|
||||
|
||||
# Linux
|
||||
cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined -o main main.c
|
||||
cc -std=c89 -DDEBUG -Wall -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined -o comm comm.c
|
||||
|
||||
# Plan9
|
||||
# pcc main.c -o main
|
||||
|
|
25
main.c
25
main.c
|
@ -151,7 +151,7 @@ addvessel(Parade* p, Vessel* v, char* name)
|
|||
{
|
||||
Vessel* nv = &p->vessels[p->len];
|
||||
nv->id = p->len;
|
||||
nv->owner = v ? v->parent : nv;
|
||||
nv->owner = v ? v : nv;
|
||||
nv->parent = v ? v->parent : nv;
|
||||
sstr(name, nv->name, 0, imin(slen(name), NAMELEN - 1));
|
||||
p->len++;
|
||||
|
@ -281,7 +281,7 @@ warpvessel(Parade* p, char* val)
|
|||
if(!v)
|
||||
printf("You cannot warp to the %s.\n", val);
|
||||
else {
|
||||
v->parent = v;
|
||||
guest->parent = v;
|
||||
printf("You warped to the %s%c.\n", v->name, rune(v));
|
||||
}
|
||||
}
|
||||
|
@ -389,6 +389,23 @@ act(Parade* p, char* cmd, char* val)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
save(Parade* p)
|
||||
{
|
||||
int i;
|
||||
char body[1024];
|
||||
for(i = 0; i < p->len; ++i) {
|
||||
printf("%-4d %-4d %-4d %-16s %s | %s\n",
|
||||
p->vessels[i].id,
|
||||
p->vessels[i].owner->id,
|
||||
p->vessels[i].parent->id,
|
||||
p->vessels[i].name,
|
||||
p->vessels[i].note,
|
||||
p->vessels[i].prog);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
answer(Parade* p, char* input)
|
||||
{
|
||||
|
@ -396,6 +413,10 @@ answer(Parade* p, char* input)
|
|||
char action[NAMELEN], value[TEXTLEN];
|
||||
if(scmp(input, "quit"))
|
||||
return 0;
|
||||
if(scmp(input, "save"))
|
||||
return save(p);
|
||||
if(cpos(input, '|') >= 0)
|
||||
return 1;
|
||||
if(split >= 0) {
|
||||
sstr(input, action, 0, split);
|
||||
sstr(input, value, split + 1, imin(slen(input) - split, TEXTLEN - 1));
|
||||
|
|
Loading…
Reference in New Issue