Merge branch 'master' of ssh://bitsetter.de:8090/netsl

This commit is contained in:
Lennart Buhl 2013-11-03 13:14:27 +01:00
commit 646a1b8806
2 changed files with 15 additions and 12 deletions

View File

@ -66,6 +66,16 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
static char *img = NULL;
static int w;
static int h;
if (!img && msg->image) {
img = msg->image;
w = msg->width;
h = msg->height;
}
if (!img) {
printf("awaiting state ... %d\r", msg->timestamp);
return;
}
if (!init) {
// printf("init start\n");
initscr();
@ -74,14 +84,6 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
init = 1;
// printf("init end\n");
}
if (!img && msg->image) {
img = msg->image;
w = msg->width;
h = msg->height;
}
if (!img)
return;
int frame = msg->timestamp;
int right = pinfo->client_offset;
@ -92,8 +94,10 @@ void prntscreen(const struct message *msg, const struct prog_info *pinfo) {
int coloffset = left-frame;
for (int y=0; y<h; y++) { // y<msg->height; y++) {
for (int x=left-frame; x<cols; x++) {
mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
//mvaddch(y + rowoffset, x, ('0' + x-(left-frame)+y));
int p = x-(left-frame);
mvaddch(y + rowoffset, x, p>=w?' ':img[y*w+p]);
}
}

View File

@ -81,7 +81,6 @@ int run_server(const struct prog_info *pinfo, char *img, int w, int h) {
for (;;) {
//printf("sending...\n");
int numbytes;
// TODO: Hier den Messageblock erstellen und serialisieren.
t++;
t %= pinfo->width;
@ -102,7 +101,7 @@ int run_server(const struct prog_info *pinfo, char *img, int w, int h) {
if ((numbytes = sendto(sockfd, outbuf, buflen, 0, p->ai_addr, p->ai_addrlen)) == -1) {
perror("error sending");
return -44;
return -42;
}
nanosleep(&tim, NULL);
}