X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=src%2Fserver%2Frun.h;h=414df1b3e684efb4d9152040e629d04852871318;hb=36519c3ce33ac973889e92971abded12b51f04db;hp=bd13d1dde788d7a370d0c08aaeca1888167280eb;hpb=2b2a1e0169b3a863fd87b679d789a4e2b789eb67;p=plomrogue diff --git a/src/server/run.h b/src/server/run.h index bd13d1d..414df1b 100644 --- a/src/server/run.h +++ b/src/server/run.h @@ -14,8 +14,8 @@ -/* Append "answer" to server output file, with instant fflush(). */ -extern void send_to_outfile(char * answer); +/* Append "answer" to server output file, with instant fflush() if "flush". */ +extern void send_to_outfile(char * answer, uint8_t flush); /* Record save and record file data. Both are only written if "force" is set, or * on the first run with unset "force", or if 15 seconds have passed since the @@ -23,20 +23,23 @@ extern void send_to_outfile(char * answer); */ extern void record(char * msg, uint8_t force); -/* Try parsing "msg" into a command to apply, and apply it. Output commands to - * stdout if "do_verbose" and world.is_verbose are set. If "do_record" is set, - * record commands to record file, and run save_world() if the last call to it - * via this function has not happened yet or is at least one minute in the past. +/* Try parsing "msg" into a command to apply. Output "msg" if world.is_verbose. + * If "obey_state" is > 1 and world.replay is set, any non-meta command message + * is not executed, but merely returns 3. The QUIT meta command (if well-formed) + * always returns 2. Other meta commands and (with "obey_state" < 2) non-meta + * commands return 1 if well-formed. Malformed or empty command messages return + * 0. If "obey_state" is 1, "msg" is recorded via a non-forced record(). If a + * non-meta command is executed and world.exists, world.do_update is set. */ -extern void obey_msg(char * msg, uint8_t do_record, uint8_t do_verbose); +extern uint8_t obey_msg(char * msg, uint8_t obey_state); -/* Loop for receiving commands via io_round(), and acting on them. Exits with 1 - * on "QUIT" command. In replay mode, exits with 0 on each non-"QUIT" command. - * In play mode, processes incomming god and player commands via obey_msg(). - * Compares the first line of the server out file with world.server_test to - * ensure that the current server process has not been superseded by a new one. +/* Loop to read commands via io_round() and call obey_msg() with "obey_state" + * set on them. If latter returns 2 and world.replay is not set, or returns > 1 + * and world.replay is set, abort loop to return that result. After io_round(), + * compares 1st line of the server out file is compared with world.server_test + * to ensure the server process hasn't been superseded by a new one. */ -extern uint8_t io_loop(); +extern uint8_t io_loop(uint8_t obey_state);