You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(180) |
Apr
(20) |
May
|
Jun
(91) |
Jul
(78) |
Aug
(18) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Peep P. <so...@us...> - 2004-08-05 13:44:21
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27183 Modified Files: gui.c main.c net.c Log Message: Backspace; scrolling Index: net.c =================================================================== RCS file: /cvsroot/agd/client/net.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- net.c 5 Aug 2004 13:25:28 -0000 1.2 +++ net.c 5 Aug 2004 13:44:13 -0000 1.3 @@ -4,8 +4,7 @@ #include "net.h" #include "gui.h" -extern int cursor_y; -extern gui_font_t *fonts; +extern int cursor_x, text_begin_x; int fd; fd_set readfd; @@ -86,6 +85,7 @@ /* p = buf; while(strlen(p)) {*/ gui_printf(screen, buf); + text_begin_x = cursor_x; /* gui_label(screen, 0, buf, 0, cursor_y, SCREEN_W, SCREEN_H); cursor_y += fonts[0].b->h;*/ break; Index: main.c =================================================================== RCS file: /cvsroot/agd/client/main.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- main.c 5 Aug 2004 13:25:06 -0000 1.3 +++ main.c 5 Aug 2004 13:44:13 -0000 1.4 @@ -85,17 +85,25 @@ net_events(); while(keypressed()) { int c = readkey() & 0xff; - if(c == '\r') { - gui_putchar(screen, 0, '\n'); - net_send(kb_buf, kb_buf_siz); - memset(kb_buf, 0, kb_buf_siz); - } else { - if(strlen(kb_buf)+1 >= kb_buf_siz) { - kb_buf_siz += (kb_buf_siz / 2); - kb_buf = xrealloc(kb_buf, kb_buf_siz); - } - sprintf(kb_buf, "%s%c", kb_buf, c); - gui_putchar(screen, 0, c); + switch(c) { + case '\r': + gui_putchar(screen, 0, '\n'); + net_send(kb_buf, kb_buf_siz); + memset(kb_buf, 0, kb_buf_siz); + break; + case '\b': + gui_putchar(screen, 0, '\b'); + if(strlen(kb_buf)) + kb_buf[strlen(kb_buf) - 1] = '\0'; + break; + default: + if(strlen(kb_buf)+1 >= kb_buf_siz) { + kb_buf_siz += (kb_buf_siz / 2); + kb_buf = xrealloc(kb_buf, kb_buf_siz); + } + sprintf(kb_buf, "%s%c", kb_buf, c); + gui_putchar(screen, 0, c); + break; } } /* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ Index: gui.c =================================================================== RCS file: /cvsroot/agd/client/gui.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gui.c 5 Aug 2004 13:24:43 -0000 1.3 +++ gui.c 5 Aug 2004 13:44:13 -0000 1.4 @@ -7,6 +7,8 @@ static int numfonts, fontsalloced; static gui_font_t *fonts; int cursor_x, cursor_y; +int text_begin_x; + extern BITMAP *buffer; void gui_init(void) @@ -219,19 +221,40 @@ cursor_y = y; } -void gui_newline(int font) +void gui_newline(BITMAP *bmp, int font) { cursor_y += fonts[font].b->h + 2; cursor_x = 0; + if(cursor_y + fonts[font].b->h >= SCREEN_H) { + BITMAP *tmp; + tmp = create_bitmap(SCREEN_W, SCREEN_H); + blit(bmp, tmp, 0, 0, 0, -fonts[font].b->h-2, SCREEN_W, SCREEN_H); + clear_to_color(bmp, /*AGI_BLACK*/0); + blit(tmp, bmp, 0, 0, 0, 0, SCREEN_W, SCREEN_H); + cursor_y -= fonts[font].b->h + 2; +/* void blit(BITMAP *source, BITMAP *dest, int source_x, int source_y, int dest_x, int dest_y, int width, int height);*/ + } } void gui_putchar(BITMAP *bmp, int font, char c) { + if(c == '\b') { + if(cursor_x >= text_begin_x + fonts[font].char_w) { + cursor_x -= fonts[font].char_w; + rectfill(bmp, cursor_x, cursor_y, cursor_x+fonts[font].char_w, cursor_y+fonts[font].b->h, 0); + if(cursor_x <= 0 && cursor_y >= (fonts[font].b->h + 2)) { + cursor_y -= fonts[font].b->h + 2; + cursor_x = SCREEN_W - fonts[font].b->w; + } + } + return; + } + if(cursor_x + fonts[font].char_w >= SCREEN_W) - gui_newline(font); + gui_newline(bmp, font); if(c == '\n') { - gui_newline(font); + gui_newline(bmp, font); return; } @@ -285,7 +308,7 @@ int tmp; tmp = gui_text(bmp, 0, ex->str[i], 0); if(i+1 < ex->num) - gui_newline(0); + gui_newline(bmp, 0); if(!tmp) break; ex->str[i] += tmp; |
From: Peep P. <so...@us...> - 2004-08-05 13:25:38
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24697 Modified Files: net.c Log Message: Errors are now displayed with gui_printf; net_send Index: net.c =================================================================== RCS file: /cvsroot/agd/client/net.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- net.c 3 Aug 2004 14:50:13 -0000 1.1 +++ net.c 5 Aug 2004 13:25:28 -0000 1.2 @@ -10,50 +10,50 @@ int fd; fd_set readfd; -void net_connect() { +int net_connect() { struct sockaddr_in sin; int ret; #ifdef WIN32 WSADATA wsaData; if(WSAStartup(MAKEWORD(1, 1), &wsaData)) { - fprintf(stderr, "Can't initialize Winsock!\n"); - exit(1); + gui_printf(screen, "Can't initialize Winsock"); + return 0; } #endif sin.sin_family = AF_INET; sin.sin_port = htons(conf.port); - printf("port: %d\n", conf.port); if(conf.host[0] > '0' && conf.host[0] < '9') { /* This is an IP address. */ if(!inet_aton(conf.host, &sin.sin_addr)) { - printf("Invalid IP address '%s'.\n", conf.host); - return; + gui_printf(screen, "Invalid IP address '%s'.\n", conf.host); + return 0; } } else { /* This is a hostname. */ struct hostent *he; he = gethostbyname(conf.host); if(!he) { - printf("Cannot look up %s.\n", conf.host); - return; + gui_printf(screen, "Cannot look up %s.\n", conf.host); + return 0; } sin.sin_addr = *(struct in_addr *)he->h_addr; } fd = socket(PF_INET, SOCK_STREAM, 0); if(fd < 0) { - perror("Can't open socket"); - exit(1); + gui_printf(screen, "Can't open socket: %s", strerror(errno)); + return 0; } ret = connect(fd, (struct sockaddr *) &sin, sizeof sin); if(ret < 0) { - perror("Can't connect"); - exit(1); + gui_printf(screen, "Can't connect: %s", strerror(errno)); + return 0; } + return 1; } void net_events() { @@ -66,26 +66,34 @@ ret = select(fd + 1, &readfd, 0, 0, &timeout); if(ret <= 0) { - if(ret < 0 ) + if(ret < 0) perror("select"); return; } if(FD_ISSET(fd, &readfd)) { + memset(buf, 0, 4096); ret = recv(fd, buf, 4096, 0); switch(ret) { case -1: - printf("Error reading from server\n"); + gui_printf(screen, "Error reading from server\n"); /* fallthrough */ case 0: - printf("Disconnected from server.\n"); - break; + gui_printf(screen, "Disconnected"); + readkey(); + exit(1); default: /* p = buf; while(strlen(p)) {*/ - gui_label(screen, 0, buf, 0, cursor_y, SCREEN_W, SCREEN_H); - cursor_y += fonts[0].b->h; + gui_printf(screen, buf); +/* gui_label(screen, 0, buf, 0, cursor_y, SCREEN_W, SCREEN_H); + cursor_y += fonts[0].b->h;*/ break; } } } + +void net_send(char *buf, int len) +{ + send(fd, buf, len, 0); +} |
From: Peep P. <so...@us...> - 2004-08-05 13:25:15
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24652 Modified Files: main.c Log Message: Moved gfx_init to gfx.c, cleanup Index: main.c =================================================================== RCS file: /cvsroot/agd/client/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- main.c 3 Aug 2004 14:49:12 -0000 1.2 +++ main.c 5 Aug 2004 13:25:06 -0000 1.3 @@ -1,30 +1,16 @@ #include <allegro.h> #include <stdio.h> -#include "agi.h" +#include "gfx.h" #include "gui.h" #include "sys.h" -BITMAP *buffer; +BITMAP *bg_pic; +extern BITMAP *buffer; + +#if 0 static int update; gui_window_t *login; -void gfx_init(void) -{ - allegro_init(); - install_keyboard(); - install_mouse(); - set_palette(agipal); - - set_window_title("AGD client " VERSION); - printf("AGD client %s\n%s\n", VERSION, allegro_id); - set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 400, 0, 0); - buffer = create_bitmap(SCREEN_W, SCREEN_H); - - agipix_w = SCREEN_W / AGI_ORIGINAL_W; - agipix_h = SCREEN_H / AGI_ORIGINAL_H; - printf("agipix: %d;%d\n", agipix_w, agipix_h); -} - void login_connect_cb(void) { login->visible = 0; @@ -59,62 +45,61 @@ return win; } +#endif int main(int argc, char *argv[]) { + picture_t *pic; + char *kb_buf; + int kb_buf_siz; + if(argc > 1) { if(argc > 2) conf.port = atoi(argv[2]); - else - conf.port = NET_DEFAULT_PORT; conf.host = argv[1]; } + if(!conf.port) + conf.port = NET_DEFAULT_PORT; + if(!conf.host) + conf.host = "localhost"; + if(!conf.host || !conf.port) { printf("Syntax: %s <server hostname> [port]\n", argv[0]); exit(1); } - net_connect(); - gfx_init(); - show_mouse(NULL); - clear_to_color(buffer, AGI_BLACK); - gui_init(); - - while(!key[KEY_ESC]) { -/* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ + gui_init(); /* For fonts. */ + kb_buf = xmalloc(256); + memset(kb_buf, 0, 256); + kb_buf_siz = 256; - net_events(); -/* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ -#if 0 - gui_draw(); - gui_events(); -#endif + if(!net_connect()) { + readkey(); + exit(1); } -#if 0 - login = make_login(); - - update = 1; + show_mouse(NULL); while(!key[KEY_ESC]) { - if(update) { - clear_to_color(buffer, AGI_CYAN); -/* gui_draw(buffer);*/ - gui_draw_window(buffer, login); - - show_mouse(NULL); - blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); - show_mouse(screen); - - update = 0; + net_events(); + while(keypressed()) { + int c = readkey() & 0xff; + if(c == '\r') { + gui_putchar(screen, 0, '\n'); + net_send(kb_buf, kb_buf_siz); + memset(kb_buf, 0, kb_buf_siz); + } else { + if(strlen(kb_buf)+1 >= kb_buf_siz) { + kb_buf_siz += (kb_buf_siz / 2); + kb_buf = xrealloc(kb_buf, kb_buf_siz); + } + sprintf(kb_buf, "%s%c", kb_buf, c); + gui_putchar(screen, 0, c); + } } - -/* gui_events();*/ - if(login->visible) - gui_events(login); +/* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ } -#endif return 0; } |
From: Peep P. <so...@us...> - 2004-08-05 13:24:52
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24539 Modified Files: gui.c gui.h Log Message: gui_putchar, gui_printf, lots of cleanups Index: gui.c =================================================================== RCS file: /cvsroot/agd/client/gui.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gui.c 3 Aug 2004 14:48:46 -0000 1.2 +++ gui.c 5 Aug 2004 13:24:43 -0000 1.3 @@ -5,8 +5,9 @@ #include "sys.h" static int numfonts, fontsalloced; -/*static*/ gui_font_t *fonts; -int cursor_y; +static gui_font_t *fonts; +int cursor_x, cursor_y; +extern BITMAP *buffer; void gui_init(void) { @@ -21,10 +22,15 @@ fonts = xrealloc(fonts, sizeof(BITMAP*) * (fontsalloced *= 2)); } fonts[numfonts].b = load_bitmap(filename, NULL); + if(!fonts[numfonts].b) { + printf("Can't load font %s\n", filename); + exit(1); + } fonts[numfonts].char_w = fonts[numfonts].b->w / 94; numfonts++; } +#if 0 gui_window_t *gui_new_window(int w, int h, int x, int y, int properties) { gui_window_t *win = xmalloc(sizeof(gui_window_t)); @@ -205,11 +211,48 @@ rectfill(bmp, x+1, y+1, x+w-1, y+h-1, col_face); gui_text(bmp, font, caption, x+(w/2-text_w/2)+1+pressed, y+(h/2-text_h/2)+1+pressed, w); } +#endif -/* returns 1 if wrapped */ -int gui_text(BITMAP *bmp, int font, char *text, int x, int y, int maxwidth) +void gui_goto(int x, int y) { - int scrx, i; + cursor_x = x; + cursor_y = y; +} + +void gui_newline(int font) +{ + cursor_y += fonts[font].b->h + 2; + cursor_x = 0; +} + +void gui_putchar(BITMAP *bmp, int font, char c) +{ + if(cursor_x + fonts[font].char_w >= SCREEN_W) + gui_newline(font); + + if(c == '\n') { + gui_newline(font); + return; + } + + masked_blit(fonts[font].b, bmp, fonts[font].char_w * (c - '!'), 0, + cursor_x, cursor_y, fonts[font].char_w, fonts[font].b->h); + cursor_x += fonts[font].char_w; +} + +/* returns length of written text if wrapped */ +int gui_text(BITMAP *bmp, int font, char *text, int maxwidth) +{ + char *p; + int begin_x; + + begin_x = cursor_x; + for(p=text;*p;p++) { + if(maxwidth && cursor_x - begin_x >= maxwidth) + return p-text; + gui_putchar(bmp, font, *p); + } +/* int scrx, i; for(scrx = x, i = 0; text[i]; scrx += fonts[font].char_w, i++) { if(scrx-x >= maxwidth) return 1; @@ -217,27 +260,52 @@ fonts[font].char_w * (text[i] - '!'), 0, scrx, y, fonts[font].char_w, fonts[font].b->h); - } + }*/ return 0; } -void gui_label(BITMAP *bmp, int font, char *text, int x, int y, int w, int h) +void gui_printf(BITMAP *bmp, char *fmt, ...) { + va_list va; + char buf[1024]; + exploded_t *ex; int i, yy; - ex = explode(text, "\n"); + va_start(va, fmt); + vsprintf(buf, fmt, va); + va_end(va); + + ex = explode(buf, "\n"); - yy = y; - for(i=0;i<ex->num;i++,yy+=fonts[font].b->h) { - if(ex->str[i]) - while(gui_text(bmp, font, ex->str[i], x, yy, w)) { +/* yy = y;*/ + for(i=0;i<ex->num;i++/*,yy+=fonts[0].b->h*/) { + if(ex->str[i] && strlen(ex->str[i])) { + while(1) { + int tmp; + tmp = gui_text(bmp, 0, ex->str[i], 0); + if(i+1 < ex->num) + gui_newline(0); + if(!tmp) + break; + ex->str[i] += tmp; + } + } else { + gui_putchar(bmp, 0, '\n'); + } +/* while(gui_text(bmp, 0, ex->str[i], x, yy, w)) { ex->str[i] += w / fonts[font].char_w; yy += fonts[font].b->h; - } + }*/ } } + +#if 0 +void gui_label(BITMAP *bmp, int font, char *text, int x, int y, int w, int h) +{ +} + void gui_textbox(BITMAP *bmp, int font, char *value, int x, int y, int w, int h) { int text_w, text_h; @@ -260,6 +328,7 @@ /* gui_text(bmp, font, value, x+(w/2-text_w/2)+1+pressed, y+(h/2-text_h/2)+1+pressed, w);*/ gui_text(bmp, font, value, x + 1, y + ((h - text_h)/ 2) + 1, w); } +#endif #if 0 int gui_menu(BITMAP *bmp, int gui_active_menu) Index: gui.h =================================================================== RCS file: /cvsroot/agd/client/gui.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- gui.h 3 Aug 2004 14:50:03 -0000 1.2 +++ gui.h 5 Aug 2004 13:24:43 -0000 1.3 @@ -66,7 +66,7 @@ void gui_add_widget(gui_window_t *win, void *widg, int type, int x, int y); void gui_draw_window(BITMAP *bmp, gui_window_t *win); -int gui_text(BITMAP *bmp, int font, char *text, int x, int y, int maxwidth); +int gui_text(BITMAP *bmp, int font, char *text, int maxwidth); void gui_button(BITMAP *bmp, int font, char *caption, int x, int y, int w, int h, int pressed); void gui_label(BITMAP *bmp, int font, char *text, int x, int y, int w, int h); void gui_textbox(BITMAP *bmp, int font, char *value, int x, int y, int w, int h); |
From: Peep P. <so...@us...> - 2004-08-05 13:24:24
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24458 Added Files: gfx.c gfx.h Log Message: AGI PICTURE drawing - only absolute line and fill at the moment --- NEW FILE: gfx.c --- #include <math.h> #include <stdio.h> #include "gfx.h" #include "sys.h" PALETTE agipal = { {0x00, 0x00, 0x00}, /* black */ {0x00, 0x00, 0x2A}, /* blue */ {0x00, 0x2A, 0x00}, /* green */ {0x00, 0x2A, 0x2A}, /* cyan */ {0x2A, 0x00, 0x00}, /* red */ {0x2A, 0x00, 0x2A}, /* magenta */ {0x2A, 0x15, 0x00}, /* brown */ {0x2A, 0x2A, 0x2A}, /* light grey */ {0x15, 0x15, 0x15}, /* dark grey */ {0x15, 0x15, 0x3F}, /* light blue */ {0x15, 0x3F, 0x15}, /* light green */ {0x15, 0x3F, 0x3F}, /* light cyan */ {0x3F, 0x15, 0x15}, /* light red */ {0x3F, 0x15, 0x3F}, /* light magenta */ {0x3F, 0x3F, 0x15}, /* yellow */ {0x3F, 0x3F, 0x3F} /* white */ }; int vis_drawing, vis_col, pri_drawing, pri_col; BITMAP *buffer; extern BITMAP *bg_pic; void gfx_init(void) { allegro_init(); install_keyboard(); install_mouse(); set_palette(agipal); set_window_title("AGD client " VERSION); set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 400, 0, 0); buffer = create_bitmap(SCREEN_W, SCREEN_H); clear_to_color(buffer, AGI_BLACK); } void agi_putpixel(BITMAP *bmp, int x, int y, int color) { int vx; vx = (x << 1); if(vx > 319) return; if(y > 199) return; bmp->line[y][vx] = color; bmp->line[y][vx+1] = color; } void do_pixel(int x, int y) { if(vis_drawing) agi_putpixel(bg_pic, x, y, vis_col); /* if(pri_drawing) agi_putpixel(curr_pri, x, y, pri_col);*/ } unsigned char agi_getpixel(BITMAP *bmp, int x, int y, int vis) { int vx; vx = (x<<1); if(vx > 319 || y > 199) if(vis) return AGI_WHITE; else return AGI_RED; return bmp->line[y][vx]; } int round(float aNumber, float dirn) { float num; if(dirn < 0) num = 0.501; else num = 0.499; return ((int)((aNumber - floor(aNumber) <= num) ? floor(aNumber) : ceil(aNumber))); } void agi_line(BITMAP *bmp, int x1, int y1, int x2, int y2, int color) { int height, width; float x, y, addX, addY; height = (y2 - y1); width = (x2 - x1); addX = (height==0? height:(float)width/abs(height)); addY = (width==0? width:(float)height/abs(width)); if (abs(width) > abs(height)) { y = y1; addX = (width == 0? 0 : (width/abs(width))); for (x=x1; x!=x2; x+=addX) { agi_putpixel(bmp, round(x, addX), round(y, addY), color); y+=addY; } agi_putpixel(bmp, x2,y2, color); } else { x = x1; addY = (height == 0? 0 : (height/abs(height))); for (y=y1; y!=y2; y+=addY) { agi_putpixel(bmp, round(x, addX), round(y, addY), color); x+=addX; } agi_putpixel(bmp, x2,y2, color); } } int ok_to_fill(unsigned char x, unsigned char y) { if(!vis_drawing && !pri_drawing) return 0; if(vis_col == AGI_WHITE) return 0; if(!pri_drawing) return agi_getpixel(bg_pic, x, y, 1) == AGI_WHITE; /* if(pri_drawing && !vis_drawing) return agi_getpixel(curr_pri, x, y, 0) == AGI_RED;*/ return agi_getpixel(bg_pic, x, y, 1) == AGI_WHITE; } #define QUEUE_SIZE 4000 #define EMPTY 0xFF unsigned char buf[QUEUE_SIZE+1]; int rpos = QUEUE_SIZE, spos; void qstore(unsigned char c) { if(spos+1 == rpos || (spos+1 == QUEUE_SIZE && !rpos)) return; buf[spos] = c; spos++; if(spos == QUEUE_SIZE) spos = 0; /* loop back */ } unsigned char qretrieve(void) { if(rpos == QUEUE_SIZE) rpos = 0; /* loop back */ if(rpos == spos) return EMPTY; rpos++; return buf[rpos-1]; } void agi_fill(BITMAP *bmp, int x, int y, int color) { unsigned char x1, y1; rpos = spos = 0; qstore(x); qstore(y); while(1) { x1 = qretrieve(); y1 = qretrieve(); if((x1 == EMPTY) || (y1 == EMPTY)) break; else if(ok_to_fill(x1, y1)) { agi_putpixel(bmp, x1, y1, vis_col); if(ok_to_fill(x1, y1-1) && (y1!=0)) { qstore(x1); qstore(y1-1); } if(ok_to_fill(x1-1, y1) && (x1!=0)) { qstore(x1-1); qstore(y1); } if(ok_to_fill(x1+1, y1) && (x1!=159)) { qstore(x1+1); qstore(y1); } if(ok_to_fill(x1, y1+1) && (y1!=167)) { qstore(x1); qstore(y1+1); } } } } long file_length(FILE *file) { long tmp; fseek(file, 0, SEEK_END); tmp = ftell(file); fseek(file, 0, SEEK_SET); return tmp; } void draw_ycorner(unsigned char **data) { (*data) += 2; while(*(*data)++ < 0xF0); } void draw_xcorner(unsigned char **data) { (*data) += 2; while(*(*data)++ < 0xF0); } void draw_absline(unsigned char **data) { unsigned char x1, y1, x2, y2; x1 = *((*data)++); y1 = *((*data)++); agi_putpixel(bg_pic, x1, y1, vis_col); while(1) { x2 = *((*data)++); if(x2 >= 0xF0) break; y2 = *((*data)++); if(y2 >= 0xF0) break; agi_line(bg_pic, x1, y1, x2, y2, vis_col); x1 = x2; y1 = y2; } (*data)--; } void draw_relline(unsigned char **data) { (*data) += 2; while(1) { if(*(*data) >= 0xF0) break; (*data)++; } } void fill(unsigned char **data) { unsigned char x1, y1; while(1) { x1 = *((*data)++); if(x1 >= 0xF0) break; y1 = *((*data)++); if(y1 >= 0xF0) break; agi_fill(bg_pic, x1, y1, vis_col); } (*data)--; } void draw_brush(unsigned char **data) { (*data) += 2; while(1) { if(*(*data) >= 0xF0) break; (*data)++; } } picture_t *load_picture(char *filename) { FILE *f; picture_t *ret; f = fopen(filename, "rb"); if(!f) { printf("can't open PICTURE %s for reading\n", filename); return NULL; } ret = xmalloc(sizeof(picture_t)); ret->len = file_length(f); ret->data = xmalloc(sizeof(unsigned char) * ret->len); if(fread(ret->data, 1, ret->len, f) < 0) { perror("error reading PICTURE"); free(ret->data); free(ret); return NULL; } fclose(f); return ret; } void dump(unsigned char *ptr, picture_t *pic) { unsigned char *begin, *my_ptr; int i; printf("dumping at %d/%d\n", ptr-pic->data, pic->len); begin = ptr - 5; if(begin < pic->data) begin = pic->data; my_ptr = begin; for(;my_ptr<ptr+5;my_ptr++) { printf("%x ", *my_ptr); } putchar('\n'); for(i=0;i<ptr-begin;i++) printf(" "); printf("*\n"); } void draw_picture(picture_t *pic) { unsigned char *ptr; int drawing; bg_pic = create_bitmap(320, 200); clear_to_color(bg_pic, AGI_WHITE); ptr = pic->data; drawing = 1; do { switch(*ptr++) { case 0xFF: drawing = 0; break; case 0xF0: vis_col = *ptr++; vis_drawing = 1; break; case 0xF1: vis_drawing = 0; break; case 0xF2: pri_col = *ptr++; pri_drawing = 1; break; case 0xF3: pri_drawing = 0; break; case 0xF4: draw_ycorner(&ptr); break; case 0xF5: draw_xcorner(&ptr); break; case 0xF6: draw_absline(&ptr); break; case 0xF7: draw_relline(&ptr); break; case 0xF8: fill(&ptr); break; case 0xF9: ptr++; /*pattern = *ptr++;*/ break; case 0xFA: draw_brush(&ptr); break; default: printf("Unknown picture code %x at index %d of %d\n", ptr[-1], ptr-pic->data, pic->len); dump(ptr, pic); return; break; } } while((ptr < (pic->data + pic->len)) && drawing); stretch_blit(bg_pic, screen, 0, 0, 320, 168, 0, 0, 640, 336); } --- NEW FILE: gfx.h --- #ifndef _AGI_H #define _AGI_H #include <allegro.h> #define AGI_ORIGINAL_W 160 #define AGI_ORIGINAL_H 200 extern int agipix_w, agipix_h; #define AGI_BLACK 0 #define AGI_BLUE 1 #define AGI_GREEN 2 #define AGI_CYAN 3 #define AGI_RED 4 #define AGI_MAGENTA 5 #define AGI_BROWN 6 #define AGI_LGREY 7 #define AGI_DGREY 8 #define AGI_LBLUE 9 #define AGI_LGREEN 10 #define AGI_LCYAN 11 #define AGI_LRED 12 #define AGI_LMAGENTA 13 #define AGI_YELLOW 14 #define AGI_WHITE 15 extern PALETTE agipal; void agi_putpixel(BITMAP *, int, int, int); void agi_line(BITMAP *, int, int, int, int, int); typedef struct { unsigned char *data; int len; } picture_t; #endif |
From: Peep P. <so...@us...> - 2004-08-05 13:23:39
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24322 Modified Files: Makefile Log Message: Renamed agi.c to gfx.c Index: Makefile =================================================================== RCS file: /cvsroot/agd/client/Makefile,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile 3 Aug 2004 14:46:34 -0000 1.2 +++ Makefile 5 Aug 2004 13:23:28 -0000 1.3 @@ -1,4 +1,4 @@ -SRC = agi.c gui.c main.c net.c sys.c +SRC = gfx.c gui.c main.c net.c sys.c OBJ = $(SRC:.c=.o) CFLAGS = -ansi -pedantic -g |
From: Peep P. <so...@us...> - 2004-08-05 13:23:27
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24299 Removed Files: agi.c agi.h Log Message: Renamed agi.c to gfx.c --- agi.c DELETED --- --- agi.h DELETED --- |
From: Peep P. <so...@us...> - 2004-08-03 14:50:22
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1475 Added Files: net.c Log Message: Network functions. --- NEW FILE: net.c --- #include <stdlib.h> #include <allegro.h> #include "sys.h" #include "net.h" #include "gui.h" extern int cursor_y; extern gui_font_t *fonts; int fd; fd_set readfd; void net_connect() { struct sockaddr_in sin; int ret; #ifdef WIN32 WSADATA wsaData; if(WSAStartup(MAKEWORD(1, 1), &wsaData)) { fprintf(stderr, "Can't initialize Winsock!\n"); exit(1); } #endif sin.sin_family = AF_INET; sin.sin_port = htons(conf.port); printf("port: %d\n", conf.port); if(conf.host[0] > '0' && conf.host[0] < '9') { /* This is an IP address. */ if(!inet_aton(conf.host, &sin.sin_addr)) { printf("Invalid IP address '%s'.\n", conf.host); return; } } else { /* This is a hostname. */ struct hostent *he; he = gethostbyname(conf.host); if(!he) { printf("Cannot look up %s.\n", conf.host); return; } sin.sin_addr = *(struct in_addr *)he->h_addr; } fd = socket(PF_INET, SOCK_STREAM, 0); if(fd < 0) { perror("Can't open socket"); exit(1); } ret = connect(fd, (struct sockaddr *) &sin, sizeof sin); if(ret < 0) { perror("Can't connect"); exit(1); } } void net_events() { struct timeval timeout = { 0, 0 }; char buf[4096]; int ret; FD_ZERO(&readfd); FD_SET(fd, &readfd); ret = select(fd + 1, &readfd, 0, 0, &timeout); if(ret <= 0) { if(ret < 0 ) perror("select"); return; } if(FD_ISSET(fd, &readfd)) { ret = recv(fd, buf, 4096, 0); switch(ret) { case -1: printf("Error reading from server\n"); /* fallthrough */ case 0: printf("Disconnected from server.\n"); break; default: /* p = buf; while(strlen(p)) {*/ gui_label(screen, 0, buf, 0, cursor_y, SCREEN_W, SCREEN_H); cursor_y += fonts[0].b->h; break; } } } |
From: Peep P. <so...@us...> - 2004-08-03 14:50:12
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1422 Modified Files: gui.h Log Message: Some rearranges. Index: gui.h =================================================================== RCS file: /cvsroot/agd/client/gui.h,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- gui.h 9 Jan 2004 20:52:06 -0000 1.1.1.1 +++ gui.h 3 Aug 2004 14:50:03 -0000 1.2 @@ -1,24 +1,10 @@ #ifndef _GUI_H #define _GUI_H -#include "array.h" - -typedef struct { - BITMAP *b; - int char_w; -} gui_font_t; - -typedef struct { - int w, h; - int visible; - int x, y; - int properties; - char *title; - array_t widgets; -} gui_window_t; -#define GUI_WP_CLOSE 0x1 #define GUI_SWT_BUTTON 1 #define GUI_SWT_LABEL 2 +#define GUI_SWT_TEXTBOX 3 + typedef struct { int x, y; int type; @@ -42,6 +28,30 @@ typedef struct { int w, h; int visible; + char *value; +} gui_textbox_t; + +typedef struct { + BITMAP *b; + int char_w; +} gui_font_t; + +typedef struct { + int w, h; + int visible; + int x, y; + int properties; + char *title; + + subwidget_t *widgets; + int numwidg; +} gui_window_t; +/* Window properties. */ +#define GUI_WP_CLOSE 0x1 + +typedef struct { + int w, h; + int visible; } gui_widget_t; void gui_init(void); @@ -51,15 +61,17 @@ gui_window_t *gui_new_window(int w, int h, int x, int y, int properties); gui_button_t *gui_new_button(int w, int h, char *caption, void (*callback)(void)); gui_label_t *gui_new_label(int w, int h, char *text); +gui_textbox_t *gui_new_textbox(int w, int h); + void gui_add_widget(gui_window_t *win, void *widg, int type, int x, int y); void gui_draw_window(BITMAP *bmp, gui_window_t *win); int gui_text(BITMAP *bmp, int font, char *text, int x, int y, int maxwidth); void gui_button(BITMAP *bmp, int font, char *caption, int x, int y, int w, int h, int pressed); void gui_label(BITMAP *bmp, int font, char *text, int x, int y, int w, int h); -/*void gui_text(BITMAP *bmp, unsigned char gui_font_nr, char *text, int x, int y); +void gui_textbox(BITMAP *bmp, int font, char *value, int x, int y, int w, int h); +/* void gui_load_font(char *filename); -int gui_button(BITMAP *bmp, unsigned char gui_font_nr, char *text, int x, int y, int gui_active_menu); int gui_menu(BITMAP *bmp, int gui_active_menu);*/ #endif |
From: Peep P. <so...@us...> - 2004-08-03 14:49:36
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1316 Removed Files: client Log Message: Removed the binary from CVS. --- client DELETED --- |
From: Peep P. <so...@us...> - 2004-08-03 14:49:22
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1282 Modified Files: main.c Log Message: Removed gui stuff. Index: main.c =================================================================== RCS file: /cvsroot/agd/client/main.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- main.c 9 Jan 2004 20:52:06 -0000 1.1.1.1 +++ main.c 3 Aug 2004 14:49:12 -0000 1.2 @@ -1,12 +1,12 @@ #include <allegro.h> +#include <stdio.h> #include "agi.h" #include "gui.h" -#include "stdio.h" -#define VERSION "vDev" +#include "sys.h" BITMAP *buffer; static int update; -gui_window_t *welcome; +gui_window_t *login; void gfx_init(void) { @@ -25,42 +25,83 @@ printf("agipix: %d;%d\n", agipix_w, agipix_h); } -void welcome_ok_cb(void) +void login_connect_cb(void) { - welcome->visible = 0; + login->visible = 0; update = 1; - printf("click\n"); } -gui_window_t *make_welcome(void) +void login_cancel_cb(void) +{ + exit(0); +} + +gui_window_t *make_login(void) { gui_window_t *win; - gui_button_t *okbut; - gui_label_t *label; + gui_textbox_t *port_tb; - win = gui_new_window(200, 150, 200, 100, GUI_WP_CLOSE); - win->title = "AGD client"; + win = gui_new_window(200, 55, 200, 175, GUI_WP_CLOSE); + win->title = "Connect to server"; - okbut = gui_new_button(25, 15, "OK", welcome_ok_cb); - gui_add_widget(win, okbut, GUI_SWT_BUTTON, 90, 132); - label = gui_new_label(180, 50, "Welcome!\nThis is an early version of the AGD client. Nothing works yet.\nStay tuned.\n\n\tsolicit"); - gui_add_widget(win, label, GUI_SWT_LABEL, 10, 10); + gui_add_widget(win, gui_new_button(25, 15, "Connect", login_connect_cb), + GUI_SWT_BUTTON, 100, 35); + gui_add_widget(win, gui_new_button(25, 15, "Cancel", login_cancel_cb), + GUI_SWT_BUTTON, 60, 35); + + gui_add_widget(win, gui_new_label(50, 15, "Hostname:"), + GUI_SWT_LABEL, 5, 5); + gui_add_widget(win, gui_new_label(50, 15, "Port:"), + GUI_SWT_LABEL, 5, 20); + port_tb = gui_new_textbox(75, 12); + port_tb->value = "6868"; + gui_add_widget(win, port_tb, GUI_SWT_TEXTBOX, 60, 18); return win; } -int main(int argc, char **argv) +int main(int argc, char *argv[]) { - + if(argc > 1) { + if(argc > 2) + conf.port = atoi(argv[2]); + else + conf.port = NET_DEFAULT_PORT; + conf.host = argv[1]; + } + + if(!conf.host || !conf.port) { + printf("Syntax: %s <server hostname> [port]\n", argv[0]); + exit(1); + } + + net_connect(); + gfx_init(); + show_mouse(NULL); + clear_to_color(buffer, AGI_BLACK); gui_init(); + + while(!key[KEY_ESC]) { +/* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ + + net_events(); +/* blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);*/ +#if 0 + gui_draw(); + gui_events(); +#endif + } + +#if 0 + login = make_login(); - welcome = make_welcome(); update = 1; while(!key[KEY_ESC]) { if(update) { clear_to_color(buffer, AGI_CYAN); - gui_draw_window(buffer, welcome); +/* gui_draw(buffer);*/ + gui_draw_window(buffer, login); show_mouse(NULL); blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); @@ -68,9 +109,13 @@ update = 0; } - if(welcome->visible) - gui_events(welcome); + +/* gui_events();*/ + if(login->visible) + gui_events(login); } +#endif + return 0; } END_OF_MAIN() |
From: Peep P. <so...@us...> - 2004-08-03 14:48:55
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1156 Modified Files: gui.c Log Message: xmalloc; textbox Index: gui.c =================================================================== RCS file: /cvsroot/agd/client/gui.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- gui.c 9 Jan 2004 20:52:07 -0000 1.1.1.1 +++ gui.c 3 Aug 2004 14:48:46 -0000 1.2 @@ -1,9 +1,12 @@ #include <allegro.h> -#include "gui.h" #include <string.h> +#include <stdarg.h> +#include "gui.h" +#include "sys.h" static int numfonts, fontsalloced; -static gui_font_t *fonts; +/*static*/ gui_font_t *fonts; +int cursor_y; void gui_init(void) { @@ -15,7 +18,7 @@ void gui_load_font(char *filename) { if(numfonts >= fontsalloced) { - fonts = realloc(fonts, sizeof(BITMAP*) * (fontsalloced *= 2)); + fonts = xrealloc(fonts, sizeof(BITMAP*) * (fontsalloced *= 2)); } fonts[numfonts].b = load_bitmap(filename, NULL); fonts[numfonts].char_w = fonts[numfonts].b->w / 94; @@ -24,19 +27,22 @@ gui_window_t *gui_new_window(int w, int h, int x, int y, int properties) { - gui_window_t *win = malloc(sizeof(gui_window_t)); + gui_window_t *win = xmalloc(sizeof(gui_window_t)); win->w = w; win->h = h; win->visible = 1; win->x = x; win->y = y; win->properties = properties; win->title = NULL; - init_array(&win->widgets); + + win->numwidg = 0; + win->widgets = NULL; return win; } -gui_button_t *gui_new_button(int w, int h, char *caption, void (*callback)(void)) +gui_button_t *gui_new_button(int w, int h, char *caption, + void (*callback)(void)) { - gui_button_t *b = malloc(sizeof(gui_button_t)); + gui_button_t *b = xmalloc(sizeof(gui_button_t)); b->w = w; b->h = h; b->caption = caption; @@ -47,28 +53,41 @@ gui_label_t *gui_new_label(int w, int h, char *text) { - gui_label_t *l = malloc(sizeof(gui_label_t)); + gui_label_t *l = xmalloc(sizeof(gui_label_t)); l->w = w; l->h = h; l->text = text; return l; } +gui_textbox_t *gui_new_textbox(int w, int h) +{ + gui_textbox_t *tb = xmalloc(sizeof(gui_textbox_t)); + tb->w = w; + tb->h = h; + tb->value = NULL; + return tb; +} + void gui_add_widget(gui_window_t *win, void *widg, int type, int x, int y) { - subwidget_t *sw = malloc(sizeof(subwidget_t)); + subwidget_t *sw; + + win->numwidg++; + win->widgets = xrealloc(win->widgets, sizeof(subwidget_t) * win->numwidg); + sw = &win->widgets[win->numwidg-1]; sw->x = x; sw->y = y; sw->type = type; sw->widg = widg; - array_push(&win->widgets, sw); } void gui_events(gui_window_t *win) { int i; - for(i=0;i<win->widgets.length;i++) { - subwidget_t *sw = win->widgets.data[i]; + + for(i=0;i<win->numwidg;i++) { + subwidget_t *sw = &win->widgets[i]; gui_widget_t *widg = sw->widg; if(mouse_x >= win->x + sw->x && mouse_x <= win->x + sw->x + widg->w && mouse_y >= win->y + sw->y && mouse_y <= win->y + sw->y + widg->h) { @@ -130,11 +149,11 @@ } /* Contents of window */ - for(i=0;i<win->widgets.length;i++) { + for(i=0;i<win->numwidg;i++) { subwidget_t *sw; int loc_x, loc_y; - sw = win->widgets.data[i]; + sw = &win->widgets[i]; loc_x = x + 1 + sw->x; loc_y = y + titleh + 1 + sw->y; switch(sw->type) { @@ -149,6 +168,11 @@ if(loc_x + l->w < x + win->w && loc_y + l->h < y + win->h + titleh) gui_label(bmp, 0, l->text, loc_x, loc_y, l->w, l->h); } break; + case GUI_SWT_TEXTBOX: { + gui_textbox_t *tb = sw->widg; + if(loc_x + tb->w < x + win->w && loc_y + tb->h < y + win->h + titleh) + gui_textbox(bmp, 0, tb->value, loc_x, loc_y, tb->w, tb->h); + } break; } } } @@ -197,69 +221,44 @@ return 0; } -/* in sys.c or something? */ -int count_lines(char *str) -{ - int i, count; - i = count = 0; - while(str[i]) if(str[i++] == '\n') count++; - return count; -} - -char *strdup(char *text); void gui_label(BITMAP *bmp, int font, char *text, int x, int y, int w, int h) { - char *str = strdup(text); - int numlines = count_lines(str) + 1; - char *oldstr = NULL; - char **strings; - char *marker = NULL; + exploded_t *ex; int i, yy; - int numstr; - - strings = malloc(sizeof(char*)*numlines); - numstr = 0; - - strings[0] = str; - for(i=1;i<numlines;i++) - strings[i] = NULL; - - marker = str; - for(i=0;str[i];i++) { - if(str[i] == '\n') { - str[i] = '\0'; - if(marker && *marker) { - strings[numstr] = marker; - marker = NULL; - } - marker = str+i+1; - ++numstr; - } else if(str[i] == '\t') { - char *str2; - str[i] = '\0'; - str2 = malloc(strlen(marker) + 5 + strlen(str+i+1)); /* 4 for tab */ - strcpy(str2, marker); - strcat(str2, " "); - strcat(str2, str+i+1); - oldstr = str; - str = str2; - i = 0; - } - } - if(str) - strings[numstr++] = str; + + ex = explode(text, "\n"); - for(i=0,yy=y;i<numlines;i++,yy += fonts[font].b->h) { - if(strings[i]) - while(gui_text(bmp, font, strings[i], x, yy, w)) { - strings[i] += w / fonts[font].char_w; + yy = y; + for(i=0;i<ex->num;i++,yy+=fonts[font].b->h) { + if(ex->str[i]) + while(gui_text(bmp, font, ex->str[i], x, yy, w)) { + ex->str[i] += w / fonts[font].char_w; yy += fonts[font].b->h; - } } - if(oldstr) free(oldstr); - free(str); - free(strings); +} + +void gui_textbox(BITMAP *bmp, int font, char *value, int x, int y, int w, int h) +{ + int text_w, text_h; + int col_border, col_contents; + + text_w = fonts[font].char_w * strlen(value); + text_h = fonts[font].b->h; + + col_border = makecol(20, 20, 20); + col_contents = makecol(55, 55, 55); + + if(w < text_w + 4) w = text_w + 4; + if(h < text_h + 4) h = text_h + 4; + + line(bmp, x, y, x+w, y, col_border); + line(bmp, x, y, x, y+h, col_border); + line(bmp, x, y+h, x+w, y+h, col_border); + line(bmp, x+w, y, x+w, y+h, col_border); + rectfill(bmp, x+1, y+1, x+w-1, y+h-1, col_contents); +/* gui_text(bmp, font, value, x+(w/2-text_w/2)+1+pressed, y+(h/2-text_h/2)+1+pressed, w);*/ + gui_text(bmp, font, value, x + 1, y + ((h - text_h)/ 2) + 1, w); } #if 0 |
From: Peep P. <so...@us...> - 2004-08-03 14:48:02
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1047 Modified Files: agi.c Log Message: Some indentation fixes. Index: agi.c =================================================================== RCS file: /cvsroot/agd/client/agi.c,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- agi.c 9 Jan 2004 20:52:07 -0000 1.1.1.1 +++ agi.c 3 Aug 2004 14:47:53 -0000 1.2 @@ -4,27 +4,29 @@ int agipix_w, agipix_h; PALETTE agipal = { - {0, 0, 0}, /* black */ - {0,0,170}, /* blue */ - {0,170,0}, /* green */ - {0,170,170}, /* cyan */ - {170,0,0}, /* red */ - {170,0,170}, /* magenta */ - {170,85,0}, /* brown */ - {170,170,170}, /* light grey */ - {85,85,85}, /* dark grey */ - {85,85,255}, /* light blue */ - {85,255,85}, /* light green */ - {85,255,255}, /* light cyan */ - {255,85,85}, /* light red */ - {255,85,255}, /* light purple */ - {255,255,85}, /* light yellow */ - {255,255,255} /* white */ + {0, 0, 0}, /* black */ + {0, 0, 170}, /* blue */ + {0, 170, 0}, /* green */ + {0, 170, 170}, /* cyan */ + {170, 0, 0}, /* red */ + {170, 0, 170}, /* magenta */ + {170, 85, 0}, /* brown */ + {170, 170, 170}, /* light grey */ + {85, 85, 85}, /* dark grey */ + {85, 85, 255}, /* light blue */ + {85, 255, 85}, /* light green */ + {85, 255, 255}, /* light cyan */ + {255, 85, 85}, /* light red */ + {255, 85, 255}, /* light purple */ + {255, 255, 85}, /* light yellow */ + {255, 255, 255} /* white */ }; void agi_putpixel(BITMAP *bmp, int x, int y, int color) { - rectfill(bmp, (x - 1) * agipix_w, (y - 1) * agipix_h, x * agipix_w, y * agipix_h, color); + rectfill(bmp, + (x-1) * agipix_w, (y-1) * agipix_h, + x * agipix_w, y * agipix_h, color); } int round(float aNumber, float dirn) |
From: Peep P. <so...@us...> - 2004-08-03 14:47:39
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv947 Added Files: sys.c sys.h Log Message: Various utility functions. --- NEW FILE: sys.h --- #ifndef _SYS_H #define _SYS_H #define VERSION "v1.0*10-42" #define NET_DEFAULT_PORT 6868 void *xmalloc(size_t bytes); void *xrealloc(void *ptr, size_t bytes); char *xstrdup(char *s); int count_lines(char *s); typedef struct { char *host; int port; } conf_t; extern conf_t conf; typedef struct { char **str; int num; } exploded_t; exploded_t *explode(char *str, char *delim); #endif --- NEW FILE: sys.c --- #include <stdlib.h> #include "sys.h" conf_t conf; void *xmalloc(size_t bytes) { void *ptr; ptr = malloc(bytes); if(!ptr) { printf("Out of memory!\n"); exit(1); } return ptr; } void *xrealloc(void *ptr, size_t bytes) { void *new_ptr; new_ptr = realloc(ptr, bytes); if(!new_ptr) { printf("Out of memory!\n"); exit(1); } return new_ptr; } char *xstrdup(char *s) { char *p; p = xmalloc(strlen(s) + 1); return strcpy(p, s); } int count_lines(char *str) { int i, num; i = 0; if(str[0] && str[0] != '\n') num = 1; while(1) { if(str[i] == '\0') { if(str[i-1] != '\n') num++; break; } if(str[i++] == '\n') num++; } return num; } exploded_t *explode(char *str, char *delim) { char *bgn, *end; exploded_t *ret; int len; ret = xmalloc(sizeof(exploded_t)); ret->str = NULL; ret->num = 0; bgn = str; while(1) { if(!bgn) break; end = strstr(bgn, delim); if(end) len = end - bgn; else len = strlen(bgn); ret->num++; ret->str = xrealloc(ret->str, ret->num * sizeof(char*)); ret->str[ret->num-1] = xmalloc(len + 1); strncpy(ret->str[ret->num-1], bgn, len); ret->str[ret->num-1][len] = '\0'; if(!end) break; bgn = end + 1; } return ret; } |
From: Peep P. <so...@us...> - 2004-08-03 14:47:25
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv853 Added Files: net.h Log Message: Header for net.c. --- NEW FILE: net.h --- #ifndef _NET_H #define _NET_H #include <sys/time.h> #include <netdb.h> #ifdef WIN32 #include <winsock.h> #else #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #endif #endif |
From: Peep P. <so...@us...> - 2004-08-03 14:46:59
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv748 Removed Files: array.c array.h Log Message: Were pointless. --- array.c DELETED --- --- array.h DELETED --- |
From: Peep P. <so...@us...> - 2004-08-03 14:46:44
|
Update of /cvsroot/agd/client In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv716 Modified Files: Makefile Log Message: Improved. Index: Makefile =================================================================== RCS file: /cvsroot/agd/client/Makefile,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Makefile 9 Jan 2004 20:52:07 -0000 1.1.1.1 +++ Makefile 3 Aug 2004 14:46:34 -0000 1.2 @@ -1,5 +1,9 @@ -all: *.c - gcc *.c -o client `allegro-config --libs --cflags` -lm -ansi -pedantic -debug: *.c - gcc *.c -o client `allegro-config --libs --cflags` -lm -ansi -pedantic -g +SRC = agi.c gui.c main.c net.c sys.c +OBJ = $(SRC:.c=.o) +CFLAGS = -ansi -pedantic -g + +all: $(OBJ) + gcc $(OBJ) -o client `allegro-config --libs --cflags` -lm +clean: + rm $(OBJ) |
From: Peep P. <so...@us...> - 2004-08-03 13:41:51
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22097 Modified Files: net.c Log Message: Fixed select. Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- net.c 28 Jul 2004 11:57:02 -0000 1.22 +++ net.c 3 Aug 2004 13:41:43 -0000 1.23 @@ -308,12 +308,11 @@ } ret = select(greatest_sockfd + 1, &readfds, 0, 0, &timeout); - if(ret < 0) { - printf("select(): %s\n", strerror(errno)); - return; + if(ret <= 0) { + if(ret < 0) + printf("select(): %s\n", strerror(errno)); + continue; } - if(ret == 0) - return; if(FD_ISSET(listenfd, &readfds)) net_accept(); |
From: Peep P. <so...@us...> - 2004-07-28 11:57:11
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29149 Modified Files: net.c Log Message: Checking return value of select. Index: net.c =================================================================== RCS file: /cvsroot/agd/server/src/net.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- net.c 24 Jul 2004 17:51:25 -0000 1.21 +++ net.c 28 Jul 2004 11:57:02 -0000 1.22 @@ -290,6 +290,7 @@ { struct timeval timeout; int i; + int ret; list_t *l; while(1) { @@ -306,16 +307,21 @@ } } - if(select(greatest_sockfd + 1, &readfds, 0, 0, &timeout)) { - if(FD_ISSET(listenfd, &readfds)) { - net_accept(); - } + ret = select(greatest_sockfd + 1, &readfds, 0, 0, &timeout); + if(ret < 0) { + printf("select(): %s\n", strerror(errno)); + return; + } + if(ret == 0) + return; + + if(FD_ISSET(listenfd, &readfds)) + net_accept(); - LOOP_PLAYERS() - if(FD_ISSET(pl->conn.socket, &readfds)) { - pl->conn.last_active = time(NULL); - net_doread(pl); - } + LOOP_PLAYERS() + if(FD_ISSET(pl->conn.socket, &readfds)) { + pl->conn.last_active = time(NULL); + net_doread(pl); } } |
From: Peep P. <so...@us...> - 2004-07-24 18:20:13
|
Update of /cvsroot/agd/server/lib/doc/login In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2969 Added Files: 1 10 11 12 13 14 15 16 17 18 19 2 20 21 22 23 24 25 26 3 4 5 6 7 8 9 Log Message: Readded. --- NEW FILE: 11 --- .--. .--. .---. : .; :: .--': . : : :: : _ : :: : : :: :: :; :: :; : :_;:_;`.__.':___.' --- NEW FILE: 10 --- _ __ _ //\(|_;[|) --- NEW FILE: 13 --- _____ ________________ / _ \ / _____/\______ \ / /_\ \/ \ ___ | | \ / | \ \_\ \| ` \ \____|__ /\______ /_______ / \/ \/ \/ --- NEW FILE: 17 --- # ##### ##### # # # # # # ##### # # # # # # #### # # # # # --- NEW FILE: 15 --- ______ ____ ____ /\ _ \/\ _`\ /\ _`\ \ \ \L\ \ \ \L\_\ \ \/\ \ \ \ __ \ \ \L_L\ \ \ \ \ \ \ \/\ \ \ \/, \ \ \_\ \ \ \_\ \_\ \____/\ \____/ \/_/\/_/\/___/ \/___/ --- NEW FILE: 14 --- .oo .oPYo. ooo. .P 8 8 8 8 `8. .P 8 8 8 `8 oPooo8 8 oo 8 8 .P 8 8 8 8 .P .P 8 `YooP8 8ooo' ..:::::..:....8 .....:: ::::::::::::::8 ::::::: ::::::::::::::..::::::: --- NEW FILE: 24 --- ,. ,---. .-,--. / | | -' ' | \ /~~|-. | ,-' , | / ,' `-' `---| `-^--' ,-.| `-+' --- NEW FILE: 25 --- _ ____ ____ / \ / ___| _ \ / _ \| | _| | | | / ___ \ |_| | |_| | /_/ \_\____|____/ --- NEW FILE: 26 --- ,---.,---.,--. |---|| _.| | | || || | ` '`---'`--' --- NEW FILE: 12 --- .eeeeee...eeeeee..eeeeeee.. @@@@@@@@:@@@@@@@@:@@@@@@@@: %%%--%%%-%%%------%%%--%%%- &&&&&&&&+&&&++++++&&&++&&&+ ||||||||*|||*||||*|||**|||* !!!==!!!=!!!==!!!=!!!==!!!= :::##:::#::::::::#::::::::# ...@@...@@......@@.......@@ --- NEW FILE: 20 --- @@@@@@ @@@@@@@ @@@@@@@ @@! @@@ !@@ @@! @@@ @!@!@!@! !@! @!@!@ @!@ !@! !!: !!! :!! !!: !!: !!! : : : :: :: : :: : : --- NEW FILE: 21 --- ___ __________ / | / ____/ __ \ / /| |/ / __/ / / / / ___ / /_/ / /_/ / /_/ |_\____/_____/ --- NEW FILE: 22 --- _ ___ ___ /_\ / __| \ / _ \ (_ | |) | /_/ \_\___|___/ --- NEW FILE: 23 --- _______________________ ___ |_ ____/__ __ \ __ /| | / __ __ / / / _ ___ / /_/ / _ /_/ / /_/ |_\____/ /_____/ --- NEW FILE: 19 --- _____ _____ ____ | _ | __| \ | | | | | | |__|__|_____|____/ --- NEW FILE: 18 --- @@@@@@ @@@@@@@@ @@@@@@@ @@@@@@@@ @@@@@@@@@ @@@@@@@@ @@! @@@ !@@ @@! @@@ !@! @!@ !@! !@! @!@ @!@!@!@! !@! @!@!@ @!@ !@! !!!@!!!! !!! !!@!! !@! !!! !!: !!! :!! !!: !!: !!! :!: !:! :!: !:: :!: !:! :: ::: ::: :::: :::: :: : : : :: :: : :: : : --- NEW FILE: 16 --- __ _ /\ /__| \ /--\\_||_/ --- NEW FILE: 1 --- d8b 88P d88 d888b8b d888b8b d888888 d8P' ?88 d8P' ?88 d8P' ?88 88b ,88b 88b ,88b 88b ,88b `?88P'`88b`?88P'`88b`?88P'`88b )88 ,88P `?8888P --- NEW FILE: 3 --- ____ ____ ___ / T / T| \ Y o |Y __j| \ | || T || D Y | _ || l_ || | | | || || | l__j__jl___,_jl_____j --- NEW FILE: 2 --- _______ _______ _____ | _ | __| \ | | | | -- | |___|___|_______|_____/ --- NEW FILE: 5 --- _______ ______ ______ |_____| | ____ | \ | | |_____| |_____/ --- NEW FILE: 4 --- _______ _______ ______ | _ | _ | _ \ |. 1 |. |___|. | \ |. _ |. | |. | \ |: | |: 1 |: 1 / |::.|:. |::.. . |::.. . / `--- ---`-------`------' --- NEW FILE: 7 --- ____ ____ ___ |--| |__, |__> --- NEW FILE: 6 --- ____ ____ ___ |__| | __ | \ | | |__] |__/ --- NEW FILE: 9 --- ___ ___ ___ | . |/ _> | . \ | || <_/\| | | |_|_|`____/|___/ --- NEW FILE: 8 --- ___ ___________ / _ \| __ \ _ \ / /_\ \ | \/ | | | | _ | | __| | | | | | | | |_\ \ |/ / \_| |_/\____/___/ |
Update of /cvsroot/agd/server/lib/doc/login In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2623/login Removed Files: 0 1 10 100 101 102 103 104 105 106 11 12 13 14 15 155 16 17 18 19 2 20 21 22 23 24 25 26 27 28 29 3 30 31 32 33 34 35 36 37 38 39 4 40 41 42 43 44 45 46 47 48 49 5 50 51 52 53 54 55 56 57 58 59 6 60 61 62 63 64 65 66 67 68 69 7 70 71 72 73 74 75 76 77 78 79 8 80 81 82 83 84 85 86 87 88 89 9 90 91 92 93 94 95 96 97 98 99 BANNERS biggest generate.pl Log Message: Removed. --- 60 DELETED --- --- 61 DELETED --- --- 62 DELETED --- --- 63 DELETED --- --- 64 DELETED --- --- 65 DELETED --- --- 66 DELETED --- --- 67 DELETED --- --- 68 DELETED --- --- 69 DELETED --- --- 24 DELETED --- --- 25 DELETED --- --- 26 DELETED --- --- 27 DELETED --- --- 20 DELETED --- --- 21 DELETED --- --- 22 DELETED --- --- 23 DELETED --- --- 28 DELETED --- --- 29 DELETED --- --- generate.pl DELETED --- --- 0 DELETED --- --- 2 DELETED --- --- 4 DELETED --- --- 6 DELETED --- --- biggest DELETED --- --- 8 DELETED --- --- 105 DELETED --- --- 99 DELETED --- --- 98 DELETED --- --- 91 DELETED --- --- 90 DELETED --- --- 93 DELETED --- --- 92 DELETED --- --- 95 DELETED --- --- 94 DELETED --- --- 97 DELETED --- --- 96 DELETED --- --- 11 DELETED --- --- 10 DELETED --- --- 13 DELETED --- --- 12 DELETED --- --- 59 DELETED --- --- 58 DELETED --- --- 17 DELETED --- --- 16 DELETED --- --- 55 DELETED --- --- 54 DELETED --- --- 57 DELETED --- --- 56 DELETED --- --- 51 DELETED --- --- 50 DELETED --- --- 53 DELETED --- --- 52 DELETED --- --- 19 DELETED --- --- 18 DELETED --- --- 14 DELETED --- --- 155 DELETED --- --- 15 DELETED --- --- 88 DELETED --- --- 89 DELETED --- --- 82 DELETED --- --- 83 DELETED --- --- BANNERS DELETED --- --- 81 DELETED --- --- 86 DELETED --- --- 87 DELETED --- --- 84 DELETED --- --- 85 DELETED --- --- 104 DELETED --- --- 48 DELETED --- --- 49 DELETED --- --- 46 DELETED --- --- 47 DELETED --- --- 44 DELETED --- --- 45 DELETED --- --- 42 DELETED --- --- 43 DELETED --- --- 40 DELETED --- --- 41 DELETED --- --- 1 DELETED --- --- 3 DELETED --- --- 5 DELETED --- --- 7 DELETED --- --- 9 DELETED --- --- 77 DELETED --- --- 76 DELETED --- --- 75 DELETED --- --- 74 DELETED --- --- 73 DELETED --- --- 72 DELETED --- --- 71 DELETED --- --- 70 DELETED --- --- 102 DELETED --- --- 103 DELETED --- --- 100 DELETED --- --- 101 DELETED --- --- 106 DELETED --- --- 79 DELETED --- --- 78 DELETED --- --- 39 DELETED --- --- 38 DELETED --- --- 80 DELETED --- --- 33 DELETED --- --- 32 DELETED --- --- 31 DELETED --- --- 30 DELETED --- --- 37 DELETED --- --- 36 DELETED --- --- 35 DELETED --- --- 34 DELETED --- |
From: Peep P. <so...@us...> - 2004-07-24 18:09:26
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1416 Modified Files: player.lpc Log Message: * using add_command system * using process_input apply * some more player commands: tell, history, idle, upgrade, shutdown Index: player.lpc =================================================================== RCS file: /cvsroot/agd/server/lib/sys/player.lpc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- player.lpc 21 Jul 2004 12:11:21 -0000 1.1 +++ player.lpc 24 Jul 2004 18:09:16 -0000 1.2 @@ -1,11 +1,22 @@ -string _name, last_cmd; -int num_input; +string _name; +string *cmd_hist; -void create() { -/* string foo = "foobar"; - foo[4..5] = "ie"; - write("foo: " + foo + "\n");*/ - input_to("input"); +void setup_cmds() { + add_command("say"); + add_command("quit"); + add_command("tell"); + add_command("who"); + add_command("idle"); + add_command("history"); + + add_command("help"); + add_command("uptime"); + add_command("version"); + add_command("time"); + + add_command("update"); + add_command("upgrade"); + add_command("shutdown"); } void set_name(string name) { @@ -16,16 +27,43 @@ return _name; } -void write_help() { +void old_cmd(int i) { + if(i >= 0 && i < sizeof(cmd_hist)) { + do_command(cmd_hist[i]); + } else + write("Invalid number.\n"); +} + +int process_input(string str) { + if(str == ".") { + old_cmd(sizeof(cmd_hist)-1); + return 1; + } else if(str[0] == '!') { + int arg; + arg = atoi(str[1..strlen(str)]); + if(!arg && str[1] != '0') { + write("Syntax: !<number>\n"); + return 1; + } + old_cmd(arg); + return 1; + } else { + cmd_hist += ({ str }); + } + return 0; +} + +void write_prompt() { + write("> "); +} + +void net_dead() { + shout(_name + " went netdead!"); +} + +void do_help() { write("Available commands:\n" - "\tsay: Says something to everyone logged on.\n" - "\thelp: Displays this text.\n" - "\tuptime: Shows for how long the driver has been running.\n" - "\tversion: Shows AGD version information.\n" - "\tquit: Quits the game.\n" - "\ttime: Shows current time.\n" - "\twho: Shows who's playing.\n" - "\t.: Repeats last command.\n"); + " say <text>, help, uptime, version, quit, time, who, tell <person> <text>\n"); } /* Converts a time integer into a textual representation, @@ -72,7 +110,7 @@ return ret; } -object do_update(string path) { +void do_update(string path) { object ret; ret = load_object(path); if(ret) { @@ -80,63 +118,110 @@ } else { write("Failed to update " + path + "!\n"); } - return ret; } -void input(string cmd) { - if(strlen(cmd) >= 3 && cmd[0..2] == "say") { - string t = strftime(time(), "[%H:%M] "); - string text = cmd[4..strlen(cmd)]; - shout(t + capitalize(_name) + " says: "+ text +"\n"); - write(t + "You say: " + text + "\n"); - } else if(cmd == "quit") { - shout(strftime(time(), "[%H:%M] ") + capitalize(_name) + - " has quit the game.\n"); - destruct(this_object()); - } else if(cmd == "uptime") { - write("AGD " + __VERSION__ + " has been running for " + ctime(uptime()) + ".\n"); - } else if(cmd == "version") { - "/sys/master"->write_version(); - } else if(cmd == "help") { - write_help(); - } else if(strlen(cmd) >= 6 && cmd[0..5] == "update") { - string filename = cmd[6..strlen(cmd)]; - do_update(filename); - } else if(cmd == "time") { - int t = time(); - write("The current time is: " + asctime(t) + ".\n"); - } else if(cmd == "who") { - object *ppl = users(); - int i; - for(;i<sizeof(ppl);i++) { - write(i + ": " + ppl[i]->query_name() + "\n"); - } - if(sizeof(ppl) == 1) { - write("Nobody else besides you. :(\n"); - } else { - write(sizeof(ppl) + " players.\n"); - } - } else if(cmd == ".") { - if(last_cmd) { - input(last_cmd); - } else - write("No last command.\n"); - } else { - write("Unknown command. Try 'help'.\n"); - } +void do_say(string text) { + shout(capitalize(_name) + " says: " + text + "\n"); +} - if(cmd != ".") { - last_cmd = cmd; - num_input++; +void do_quit() { + shout(capitalize(_name) + " has quit the game.\n"); + destruct(); +} + +void do_uptime() { + write("AGD " + __VERSION__ + " has been running for " + ctime(uptime()) + ".\n"); +} + +void do_version() { + master()->write_version(); +} + +void do_time() { + int t = time(); + write("The current time is: " + asctime(t) + ".\n"); +} + +void do_who() { + object *ppl = users(); + int i; + + if(sizeof(ppl) == 1) { + write("Nobody else besides you. :(\n"); + return; } - input_to("input"); + + for(;i<sizeof(ppl);i++) { + write(i + ". " + ppl[i]->query_name() + "\n"); + } + + write(sizeof(ppl) + " players.\n"); } -void write_prompt() { - write(_name + /* "@" + __HOSTNAME__ + */ ":" + - num_input + "$ "); +void do_tell(string str) { + string *args; + string text; + object ob; + + args = explode(str, " "); + if(!args || sizeof(args) < 2 || !args[0] || !args[1]) { + write("Syntax: tell <person> <text>\n"); + return; + } + + ob = find_player(args[0]); + if(!ob) { + write("No such player.\n"); + return; + } + + if(this_player()->query_name() == ob->query_name()) { + write("You try to have conversation with yourself for a while, but it gets boring quickly because you usually know what you'll answer.\n"); + return; + } + + text = implode(args[1..sizeof(args)-1], " "); + tell_object(ob, capitalize(_name) + " tells you: " + text + "\n"); + write("You tell " + capitalize(args[0]) + ": " + text + "\n"); } -void net_dead() { - shout(_name + " went netdead!"); +void do_history() { + int i; + for(i=0;i<sizeof(cmd_hist);i++) { + write(i + ": " + cmd_hist[i] + "\n"); + } + write("You can invoke an old command using !<number>\n"); +} + +void do_idle(string str) { + object ob; + int t; + + ob = find_player(str); + if(!ob) { + write("No such player.\n"); + return; + } + + t = query_idle(ob); + if(t) + write(ob->query_name() + " has been idle for " + ctime(t) + ".\n"); + else + write(ob->query_name() + " is not idle.\n"); +} + +void do_upgrade() { + object ob; + ob = load_object("/sys/player"); + if(!ob) { + write("Couldn't load /sys/player.\n"); + return; + } + exec(ob); + destruct(); +} + +void do_shutdown() { + write("Ok.. shutting down.\n"); + shutdown(); } |
From: Peep P. <so...@us...> - 2004-07-24 18:08:22
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1241 Modified Files: master.lpc Log Message: * Crash doesn't use signal number * write_version() uses get_dir() * preloading * compile error handler * some tests using the flag() apply Index: master.lpc =================================================================== RCS file: /cvsroot/agd/server/lib/sys/master.lpc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- master.lpc 21 Jul 2004 12:11:21 -0000 1.1 +++ master.lpc 24 Jul 2004 18:08:13 -0000 1.2 @@ -1,20 +1,14 @@ -int biggest; - -int crash(int signal) { - if(signal == 11) { - shout("Driver shutting down - segmentation fault!\n"); - } else if(signal == 2) { - shout("Driver crashing - interrupted!\n"); - } else if(signal) { - shout("Crashing on signal " + signal + "!\n"); - } else { - shout("Driver crashing!\n"); +void crash(string msg) { + if(msg) { + shout("Driver crashing: " + msg + "!\n"); } - return 1; } void write_version() { - write(read_file("/doc/login/" + random(biggest))); + string *names; + int i; + names = get_dir("/doc/login"); + write(read_file("/doc/login/" + names[random(sizeof(names))])); write("\n\t" + __VERSION__ + " / " + __ARCH__ + "\n" + "\thttp://agd.sf.net\n\tag...@li...\n"); } @@ -26,6 +20,62 @@ return ob; } -void create() { - biggest = atoi(read_file("/doc/login/biggest")); +string ex_str, ex_del; + +void flag(string s) { + if(s == "intersection") { + string *s1 = ({ "abc", "def", "fgh", "1337" }); + string *s2 = ({ "def", "1337", "foo" }); + string *s3 = s1&s2; + int i; + for(i=0;i<sizeof(s3);i++) { + write(i + ": " + s3[i] + "\n"); + } + } else if(s[0..2] == "ex=") { + ex_str = s[3..strlen(s)]; + } else if(s[0..2] == "de=") { + ex_del = s[3..strlen(s)]; + } else if(s == "explode") { + string *str; + int i; + if(!ex_str) + ex_str = "ababababcdeabc"; + if(!ex_del) + ex_del = "b"; + write("exploding " + ex_str + " with " + ex_del + "\n"); + str = explode(ex_str, ex_del); + for(i=0;i<sizeof(str);i++) { + write(i + ": " + str[i]+"\n"); + } + } else if(s == "implode") { + string str, im_del; + string *im_str; + im_str = ({ "tell", "foo", "blahblahblah" }); + im_del = " "; + str = implode(im_str, im_del); + write("str: " + str+"\n"); + } else { + write("flag " +s+" passed to us!\n"); + } +} + +string *preload_list() { + return ({ "/sys/login", "/sys/player" }); +} + +void preload(string file) { + write("Preloading " + file + ".. "); + if(load_object(file)) { + write("ok\n"); + } else { + write("failed\n"); + shutdown(1); + } +} + +void compile_error(string file, string message) { + write(file + ":" + message); +/* catch { */ + write_file("/log/compile-errors", file + ":" + message); + /* } */ } |
From: Peep P. <so...@us...> - 2004-07-24 18:07:29
|
Update of /cvsroot/agd/server/lib/sys In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1210 Modified Files: login.lpc Log Message: Some changes to keep up with the driver. :) Index: login.lpc =================================================================== RCS file: /cvsroot/agd/server/lib/sys/login.lpc,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- login.lpc 21 Jul 2004 12:11:21 -0000 1.1 +++ login.lpc 24 Jul 2004 18:07:20 -0000 1.2 @@ -1,12 +1,11 @@ -/* For later, when we do users()->query_name() */ string query_name() { return "someone not logged in yet"; } void logon() { write("Welcome! You are connecting from " /* + - query_hostname(this_object()) + " ("*/ + - query_ip(this_object()) + /*")"*/".\n"); + query_ip_name(this_object()) + " ("*/ + + query_ip_number(this_object()) + /*")"*/".\n"); write("\nEnter your name: "); input_to("logon2"); } @@ -18,17 +17,16 @@ ob = clone_object("/sys/player"); if(!ob) { write("Uh-oh, the player object doesn't load!\n"); - destruct(this_object()); + destruct(); return; } ob->set_name(name); - t = strftime(time(), "[%H:%M] "); - shout(t + name + " has joined the game\n"); - write(t + "You have joined the game.\n"); + shout(name + " enters the game\n"); write("Use 'help' to get a list of commands.\n"); exec(ob); - destruct(this_object()); + ob->setup_cmds(); + destruct(); } void logon2(string name) { @@ -82,5 +80,5 @@ void net_dead() { /* Don't want to keep stray login objects. */ - destruct(this_object()); + destruct(); } |
From: Peep P. <so...@us...> - 2004-07-24 18:05:41
|
Update of /cvsroot/agd/server/lib/log In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv959/log Log Message: Directory /cvsroot/agd/server/lib/log added to the repository |