From: Peep P. <so...@us...> - 2004-06-07 15:41:05
|
Update of /cvsroot/agd/server/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7936 Modified Files: dfuns.c Log Message: Doesn't use array_t; throw() dfun Index: dfuns.c =================================================================== RCS file: /cvsroot/agd/server/src/dfuns.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- dfuns.c 1 Apr 2004 19:10:53 -0000 1.18 +++ dfuns.c 7 Jun 2004 15:40:52 -0000 1.19 @@ -8,7 +8,6 @@ #include "sys.h" #include "compile_options.h" #include "list.h" -#include "array.h" #include "lpc.h" #include "object.h" #include "compile.h" @@ -20,61 +19,55 @@ extern list_t all_objects; extern time_t startup_time; /* for uptime() */ -extern array_t global_ids; void (**dfptr)(void); void dfuns_init(void) { int i, j, k; - array_t *args; + int *args; + int numarg; #include "dfdecl.h" - init_array(&global_ids); - dfptr = xmalloc(sizeof(void(*)(void)) * NUM_DF); for(i=0;i<NUM_DF;i++) { dfptr[i] = decl[i].fun; - args = type_xmalloc(array_t); - init_array(args); + numarg = 0; + args = NULL; for(j=0;j<decl[i].arglen;j++) { - if(!j) - j++; /* Feels like a hack. Any better ways? */ + if(j == 0) + j = 1; + /*if(!j)j++;*/ /* Feels like a hack. Any better ways? */ /* FIXME - implement variants in define_name */ for(k=0;k<decl[i].args[j];k++,j++) { if(k == 0) { /* remove this line if variants are implemented */ - array_push(args, (void *) decl[i].args[j+k]); + numarg++; + args = xrealloc(args, sizeof(int) * numarg); + args[numarg-1] = decl[i].args[j+k]; } } } - - define_id(decl[i].name, ID_DFUN, decl[i].ret, args); + define_id(decl[i].name, ID_DFUN, decl[i].ret, args, numarg); } } -/* Returns length of string, for now. If we need to account for errors - later, we'll do it later. */ -int do_write(char *s) +void do_write(char *s) { - int len; - - len = strlen(s); if(this_player) - net_send(s, len+1, this_player); + net_send(s, strlen(s)+1, this_player); else - fprintf(stderr, "%s", s); - return len; + printf("] %s", s); } -void shout(char *s, object_t *exclude) +void shout(char *s) { list_t *p; for(p = &all_objects; p; p = p->next) { object_t *ob = p->data; - if(ob != exclude) { + if(ob->iaob && ob != this_player->ob) { tell_object(ob, s); } } @@ -82,10 +75,9 @@ void df_write(void) { - int ret; - ret = do_write(fp->u.s); + do_write(fp->u.s); pop_stack(); - push_int(ret); + push_void(); } void df_input_to(void) @@ -131,11 +123,12 @@ void df_shout(void) { - shout(fp[0].u.s, fp[1].u.ob); - pop_stack(); pop_stack(); + shout(fp[0].u.s); + pop_stack(); push_void(); } +#if 0 void df_platform(void) { push_string(PLATFORM, ST_STATIC); @@ -145,6 +138,7 @@ { push_string(PACKAGE_VERSION, ST_STATIC); } +#endif void df_destruct(void) { @@ -337,7 +331,7 @@ } /* Filesystem. */ -df_read_file(void) +void df_read_file(void) { FILE *f; char *path; @@ -358,7 +352,7 @@ file_size = 0; while(fgets(buf, 256, f)) { int len = strlen(buf); - file_str = realloc(file_str, file_size + len + 1); + file_str = xrealloc(file_str, file_size + len + 1); p = file_str + file_size; file_size += len; strcpy(p, buf); @@ -369,3 +363,10 @@ push_string(file_str, ST_MALLOC); } +/* Misc. */ +void df_throw(void) +{ + runtime(fp->u.s); + pop_stack(); + push_void(); +} |