diff --git a/neercs/neercs.cpp b/neercs/neercs.cpp index fe97a5d..3fd2679 100644 --- a/neercs/neercs.cpp +++ b/neercs/neercs.cpp @@ -39,6 +39,8 @@ using namespace lol; #include "neercs.h" #include "video/render.h" +#define USE_OLD_NEERCS 0 + extern "C" { #include "old/neercs.h" @@ -51,17 +53,29 @@ Neercs::Neercs(int argc, char **argv) m_time(0.f) { Ticker::Ref(m_render); + +#if USE_OLD_NEERCS + m_buf = NULL; + m_screen_list = init_neercs(argc, argv); + if (!m_screen_list) + exit(-1); + m_screen_list->last_key_time = get_us(); +#endif } int Neercs::hex_color(float r, float g, float b) { -return ((int)(r * 15.99f) << 8) | ((int)(g * 15.99f) << 4) | (int)(b * 15.99f); + return ((int)(r * 15.99f) << 8) | ((int)(g * 15.99f) << 4) | (int)(b * 15.99f); } void Neercs::TickGame(float seconds) { WorldEntity::TickGame(seconds); +#if USE_OLD_NEERCS + mainloop_tick(&m_buf, m_screen_list); +#endif + m_time += seconds; /* draw something */ @@ -128,6 +142,11 @@ void Neercs::TickDraw(float seconds) Neercs::~Neercs() { +#if USE_OLD_NEERCS + free(m_buf); + free_screen_list(m_screen_list); +#endif + Ticker::Unref(m_render); } diff --git a/neercs/neercs.h b/neercs/neercs.h index caf008e..5e8b790 100644 --- a/neercs/neercs.h +++ b/neercs/neercs.h @@ -11,6 +11,11 @@ #include "video/render.h" +extern "C" +{ +#include "old/neercs.h" +} + class Neercs : public WorldEntity { public: @@ -30,6 +35,10 @@ private: caca_canvas_t *m_caca; Render *m_render; float m_time; + + /* Old neercs stuff */ + char *m_buf; + struct screen_list *m_screen_list; }; #endif // __NEERCS_H__ diff --git a/neercs/old/attach.c b/neercs/old/attach.c index 6685914..0ac1593 100644 --- a/neercs/old/attach.c +++ b/neercs/old/attach.c @@ -238,7 +238,8 @@ static char *select_socket(struct screen_list *screen_list) debug("Connection refused on %s", sockets[i]); break; case ECONNREFUSED: - fprintf(stderr, "%s is dead\n", sockets[i]); + fprintf(stderr, "%s is dead, removing\n", sockets[i]); + unlink(sockets[i]); break; default: fprintf(stderr, "Unknown error on %s:%s\n", sockets[i], diff --git a/neercs/old/client.c b/neercs/old/client.c index 2c161a7..81d9464 100644 --- a/neercs/old/client.c +++ b/neercs/old/client.c @@ -159,17 +159,6 @@ int send_delay(struct screen_list *screen_list) * - "TITLE": set window or display title * - wait for an input event with a 10ms timeout */ -void mainloop(struct screen_list *screen_list) -{ - char *buf = NULL; - screen_list->last_key_time = get_us(); - - while (mainloop_tick(&buf, screen_list)) - ; - - free(buf); -} - int mainloop_tick(char **pbuf, struct screen_list *screen_list) { caca_event_t ev; @@ -189,7 +178,7 @@ int mainloop_tick(char **pbuf, struct screen_list *screen_list) read(screen_list->comm.socket[SOCK_CLIENT], *pbuf, NEERCS_RECV_BUFSIZE - 1)) > 0) { - *pbuf[n] = 0; + (*pbuf)[n] = 0; debug("Received from server: '%s' (%d bytes)", *pbuf, n); if (!strncmp("DETACH", *pbuf, 6)) { diff --git a/neercs/old/main.c b/neercs/old/main.c index edfaf91..dd2bd3b 100644 --- a/neercs/old/main.c +++ b/neercs/old/main.c @@ -81,17 +81,6 @@ void usage(int argc, char **argv) printf("\t--help\t\t-h \t\t\tthis help\n"); } -#if 0 -int main(int argc, char **argv) -{ - struct screen_list *screen_list = init_neercs(argc, argv); - if (!screen_list) - return -1; - - mainloop(screen_list); -} -#endif - struct screen_list *init_neercs(int argc, char **argv) { struct screen_list *screen_list = NULL;