Sfoglia il codice sorgente

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

master
Sam Hocevar 12 anni fa
parent
commit
f4aae2c468
5 ha cambiato i file con 32 aggiunte e 25 eliminazioni
  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 Vedi File

@@ -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);
}



+ 9
- 0
neercs/neercs.h Vedi File

@@ -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__


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

@@ -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],


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

@@ -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))
{


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

@@ -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;


Caricamento…
Annulla
Salva