home · contact · privacy
Load last world state from save file, not from re-stepping record file.
[plomrogue] / src / server / io.h
1 /* io.h
2  *
3  * Communication of the server with the outside world and its client via input,
4  * output and world state files.
5  */
6
7 #ifndef IO_H
8 #define IO_H
9
10
11
12 /* Return single \0-terminated string read from input queue (world.queue); or,
13  * if queue is empty and world.turn is unequal world.last_update_turn, update
14  * world state file (and world.last_update_turn) and write a single dot line to
15  * server out file, then read server in file for the next load of bytes to put
16  * onto the input queue.
17  *
18  * Reading the server in file may put many \0-terminated strings on the queue at
19  * once. Successive calls of io_round() will make these available one by one.
20  * Each such call cuts off bytes from the beginning of world.queue, up to and
21  * including the last \0 byte that is followed by a non-\0 byte or ends the
22  * queue. If the queue starts with a \0 byte, it and its \0 followers are cut
23  * and a NULL pointer is returned. Reading from the input file stops only when
24  * one or more byte were read and the next read returns 0 bytes. If the
25  * re-filled queue does not end in a \0 byte, a \0 byte is appended to it.
26  */
27 extern char * io_round();
28
29 /* Write to savefile god commands (one per line) to rebuild the current world
30  * state.
31  */
32 extern void save_world();
33
34
35
36 #endif