From cefc6ccad9e1fa4aec70309e9542dad7c5e4ad4c Mon Sep 17 00:00:00 2001 From: "psyc://psyced.org/~lynX" <@> Date: Wed, 27 Apr 2011 17:40:30 +0200 Subject: [PATCH] ideas for better mood methods --- world/net/library/share.c | 10 +++---- world/net/spyc/dispatch.i | 2 +- world/net/spyc/parse.c | 63 ++++++++++++++++++++++++++++++++------- 3 files changed, 58 insertions(+), 17 deletions(-) diff --git a/world/net/library/share.c b/world/net/library/share.c index 8e1a340..da6ac02 100644 --- a/world/net/library/share.c +++ b/world/net/library/share.c @@ -100,14 +100,14 @@ volatile mapping share = ([ 0 : "", // unspecified mood // any suggestions on these? 1 : "_dead", - 2 : "_angry", - 3 : "_sad", - 4 : "_moody", + 2 : "_angry", // tragic, enraged, sore, irate? + 3 : "_sad", // gloomy, miserable? + 4 : "_moody", // pensive? 5 : "_okay", 6 : "_good", 7 : "_happy", - 8 : "_bright", - 9 : "_nirvana", + 8 : "_bright", // blissful? blessed? joyous? + 9 : "_nirvana", // enlightened? paradisiacal? ]), #endif // _flag_disable_module_presence #ifndef _flag_disable_module_friendship diff --git a/world/net/spyc/dispatch.i b/world/net/spyc/dispatch.i index 4abc67e..130c8c2 100644 --- a/world/net/spyc/dispatch.i +++ b/world/net/spyc/dispatch.i @@ -46,7 +46,7 @@ void dispatch(mixed header_vars, mixed varops, mixed method, mixed body) { if ((t = vars["_target"])) { array(mixed) u; unless (u = parse_uniform(t)) { - DISPATCHERROR("target is not an uniform\n") + DISPATCHERROR("target is not a uniform\n") } // FIXME relaying support here? if (!is_localhost(lower_case(u[UHost]))) { diff --git a/world/net/spyc/parse.c b/world/net/spyc/parse.c index 316e61b..98e7558 100644 --- a/world/net/spyc/parse.c +++ b/world/net/spyc/parse.c @@ -6,8 +6,46 @@ #include private string buffer; -private string body_buffer; int state; + +#if __EFUN_DEFINED__(psyc_parse) +# echo ___ using libpsyc! + +void parser_init() { + if (state != PSYCPARSE_STATE_BLOCKED) + state = PSYCPARSE_STATE_HEADER; + buffer = ""; +} + +// called when a complete packet has arrived +void dispatch(mixed header_vars, mixed varops, mixed method, mixed body) { + parser_init(); +} + +// input data to the buffer +void feed(string data) { +# ifdef _flag_log_sockets_SPYC + log_file("RAW_SPYC", "ยป %O\n%s\n", ME, data); +# endif + buffer += data; + + if (data == "|\n") { + mixed p = psyc_parse(buffer); + if (pointerp(p) && sizeof(p) == 4) + dispatch(p[0], p[1], p[2], p[3]); + else { + P1(("psyc_parse(%O) returned %O\n", buffer, p)) + } + } +} + +mixed list_parse(string val) { + return 0; // TBD +} + +#else /* !libpsyc */ + +private string body_buffer; int body_len; int may_parse_more; @@ -51,16 +89,6 @@ void parser_init() { state = PSYCPARSE_STATE_GREET; // AFTER reset } -// it is sometimes useful to stop parsing -void interrupt_parse() { - state = PSYCPARSE_STATE_BLOCKED; -} - -// and resume after some blocking operation is done -void resume_parse() { - state = PSYCPARSE_STATE_HEADER; -} - // input data to the buffer void feed(string data) { # ifdef _flag_log_sockets_SPYC @@ -408,3 +436,16 @@ test() { list_parse("5\tabcde|4\tabcd"); } #endif + +#endif /* !libpsyc */ + +// it is sometimes useful to stop parsing +void interrupt_parse() { + state = PSYCPARSE_STATE_BLOCKED; +} + +// and resume after some blocking operation is done +void resume_parse() { + state = PSYCPARSE_STATE_HEADER; +} +