Split up startup
This allows for easier Pythonification
This commit is contained in:
parent
8f233afc83
commit
a7a25738cf
28
worm.c
28
worm.c
|
@ -88,6 +88,8 @@ char outbuf[BUFSIZ];
|
||||||
void crash(void) __attribute__((__noreturn__));
|
void crash(void) __attribute__((__noreturn__));
|
||||||
void display(const struct body *, char);
|
void display(const struct body *, char);
|
||||||
int main(int, char **);
|
int main(int, char **);
|
||||||
|
int run_size(int);
|
||||||
|
int run_worm();
|
||||||
void leave(int) __attribute__((__noreturn__));
|
void leave(int) __attribute__((__noreturn__));
|
||||||
void life(void);
|
void life(void);
|
||||||
void newpos(struct body *);
|
void newpos(struct body *);
|
||||||
|
@ -97,12 +99,24 @@ int rnd(int);
|
||||||
void setup(void);
|
void setup(void);
|
||||||
void wake(int);
|
void wake(int);
|
||||||
|
|
||||||
int
|
int main(int argc, char **argv) {
|
||||||
main(argc, argv)
|
if (argc == 2)
|
||||||
int argc;
|
run_size(atoi(argv[1]));
|
||||||
char **argv;
|
if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3))
|
||||||
{
|
run_size(LENGTH);
|
||||||
|
|
||||||
|
int retval = run_worm();
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_size(int sl) {
|
||||||
|
start_len = sl;
|
||||||
|
run_worm();
|
||||||
|
}
|
||||||
|
|
||||||
|
int run_worm() {
|
||||||
/* Revoke setgid privileges */
|
/* Revoke setgid privileges */
|
||||||
setregid(getgid(), getgid());
|
setregid(getgid(), getgid());
|
||||||
|
|
||||||
|
@ -128,10 +142,6 @@ main(argc, argv)
|
||||||
endwin();
|
endwin();
|
||||||
errx(1, "screen too small");
|
errx(1, "screen too small");
|
||||||
}
|
}
|
||||||
if (argc == 2)
|
|
||||||
start_len = atoi(argv[1]);
|
|
||||||
if ((start_len <= 0) || (start_len > ((LINES-3) * (COLS-2)) / 3))
|
|
||||||
start_len = LENGTH;
|
|
||||||
stw = newwin(1, COLS-1, 0, 0);
|
stw = newwin(1, COLS-1, 0, 0);
|
||||||
tv = newwin(LINES-1, COLS-1, 1, 0);
|
tv = newwin(LINES-1, COLS-1, 1, 0);
|
||||||
box(tv, '*', '*');
|
box(tv, '*', '*');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user