Browse Source

neercs: add a way to activate the old neercs code for testing purposes.

master
Sam Hocevar 12 years ago
parent
commit
f4aae2c468
5 changed files with 32 additions and 25 deletions
  1. +20
    -1
      neercs/neercs.cpp
  2. +9
    -0
      neercs/neercs.h
  3. +2
    -1
      neercs/old/attach.c
  4. +1
    -12
      neercs/old/client.c
  5. +0
    -11
      neercs/old/main.c

+ 20
- 1
neercs/neercs.cpp View File

@@ -39,6 +39,8 @@ using namespace lol;
#include "neercs.h" #include "neercs.h"
#include "video/render.h" #include "video/render.h"


#define USE_OLD_NEERCS 0

extern "C" extern "C"
{ {
#include "old/neercs.h" #include "old/neercs.h"
@@ -51,17 +53,29 @@ Neercs::Neercs(int argc, char **argv)
m_time(0.f) m_time(0.f)
{ {
Ticker::Ref(m_render); 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) 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) void Neercs::TickGame(float seconds)
{ {
WorldEntity::TickGame(seconds); WorldEntity::TickGame(seconds);


#if USE_OLD_NEERCS
mainloop_tick(&m_buf, m_screen_list);
#endif

m_time += seconds; m_time += seconds;


/* draw something */ /* draw something */
@@ -128,6 +142,11 @@ void Neercs::TickDraw(float seconds)


Neercs::~Neercs() Neercs::~Neercs()
{ {
#if USE_OLD_NEERCS
free(m_buf);
free_screen_list(m_screen_list);
#endif

Ticker::Unref(m_render); Ticker::Unref(m_render);
} }




+ 9
- 0
neercs/neercs.h View File

@@ -11,6 +11,11 @@


#include "video/render.h" #include "video/render.h"


extern "C"
{
#include "old/neercs.h"
}

class Neercs : public WorldEntity class Neercs : public WorldEntity
{ {
public: public:
@@ -30,6 +35,10 @@ private:
caca_canvas_t *m_caca; caca_canvas_t *m_caca;
Render *m_render; Render *m_render;
float m_time; float m_time;

/* Old neercs stuff */
char *m_buf;
struct screen_list *m_screen_list;
}; };


#endif // __NEERCS_H__ #endif // __NEERCS_H__


+ 2
- 1
neercs/old/attach.c View File

@@ -238,7 +238,8 @@ static char *select_socket(struct screen_list *screen_list)
debug("Connection refused on %s", sockets[i]); debug("Connection refused on %s", sockets[i]);
break; break;
case ECONNREFUSED: case ECONNREFUSED:
fprintf(stderr, "%s is dead\n", sockets[i]);
fprintf(stderr, "%s is dead, removing\n", sockets[i]);
unlink(sockets[i]);
break; break;
default: default:
fprintf(stderr, "Unknown error on %s:%s\n", sockets[i], fprintf(stderr, "Unknown error on %s:%s\n", sockets[i],


+ 1
- 12
neercs/old/client.c View File

@@ -159,17 +159,6 @@ int send_delay(struct screen_list *screen_list)
* - "TITLE": set window or display title * - "TITLE": set window or display title
* - wait for an input event with a 10ms timeout * - 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) int mainloop_tick(char **pbuf, struct screen_list *screen_list)
{ {
caca_event_t ev; 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, read(screen_list->comm.socket[SOCK_CLIENT], *pbuf,
NEERCS_RECV_BUFSIZE - 1)) > 0) NEERCS_RECV_BUFSIZE - 1)) > 0)
{ {
*pbuf[n] = 0;
(*pbuf)[n] = 0;
debug("Received from server: '%s' (%d bytes)", *pbuf, n); debug("Received from server: '%s' (%d bytes)", *pbuf, n);
if (!strncmp("DETACH", *pbuf, 6)) if (!strncmp("DETACH", *pbuf, 6))
{ {


+ 0
- 11
neercs/old/main.c View File

@@ -81,17 +81,6 @@ void usage(int argc, char **argv)
printf("\t--help\t\t-h \t\t\tthis help\n"); 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 *init_neercs(int argc, char **argv)
{ {
struct screen_list *screen_list = NULL; struct screen_list *screen_list = NULL;


Loading…
Cancel
Save