--- deliantra/server/common/init.C 2006/08/13 17:16:00 1.1 +++ deliantra/server/common/init.C 2006/08/29 08:01:35 1.2 @@ -1,6 +1,6 @@ /* * static char *rcsid_init_c = - * "$Id: init.C,v 1.1 2006/08/13 17:16:00 elmex Exp $"; + * "$Id: init.C,v 1.2 2006/08/29 08:01:35 root Exp $"; */ /* @@ -143,28 +143,28 @@ /* If this file doesn't exist, not a big deal */ sprintf(filename,"%s/%s/.emergency",settings.datadir, settings.mapdir); if ((fp = fopen(filename, "r"))!=NULL) { - while (fgets(tmpbuf, MAX_BUF-1, fp)) { - if (tmpbuf[0] == '#') continue; /* ignore comments */ - - if (online == 0) { - tmpbuf[strlen(tmpbuf)-1] = 0; /* kill newline */ - settings.emergency_mapname = strdup_local(tmpbuf); - } - else if (online == 1) { - settings.emergency_x = atoi(tmpbuf); - } - - else if (online == 2) { - settings.emergency_y = atoi(tmpbuf); - } - online++; - if (online>2) break; - } - fclose(fp); - if (online<=2) - LOG(llevError,"Online read partial data from %s\n", filename); - LOG(llevDebug,"Emergency mappath reset to %s (%d, %d)\n", settings.emergency_mapname, - settings.emergency_x, settings.emergency_y); + while (fgets(tmpbuf, MAX_BUF-1, fp)) { + if (tmpbuf[0] == '#') continue; /* ignore comments */ + + if (online == 0) { + tmpbuf[strlen(tmpbuf)-1] = 0; /* kill newline */ + settings.emergency_mapname = strdup_local(tmpbuf); + } + else if (online == 1) { + settings.emergency_x = atoi(tmpbuf); + } + + else if (online == 2) { + settings.emergency_y = atoi(tmpbuf); + } + online++; + if (online>2) break; + } + fclose(fp); + if (online<=2) + LOG(llevError,"Online read partial data from %s\n", filename); + LOG(llevDebug,"Emergency mappath reset to %s (%d, %d)\n", settings.emergency_mapname, + settings.emergency_x, settings.emergency_y); } } @@ -232,15 +232,15 @@ void init_globals(void) { if (settings.logfilename[0] == 0) { - logfile = stderr; + logfile = stderr; } else if ((logfile=fopen(settings.logfilename, "a"))==NULL) { - fprintf(stderr,"Unable to open %s as the logfile - will use stderr instead\n", - settings.logfilename); - logfile = stderr; + fprintf(stderr,"Unable to open %s as the logfile - will use stderr instead\n", + settings.logfilename); + logfile = stderr; } else { - setvbuf(logfile, NULL, _IOLBF, 0); + setvbuf(logfile, NULL, _IOLBF, 0); } exiting = 0; first_player=NULL; @@ -312,7 +312,7 @@ void init_dynamic (void) { archetype *at = first_archetype; while (at) { - if (at->clone.type == MAP) { + if (at->clone.type == MAP) { if (at->clone.race) { strcpy (first_map_ext_path, at->clone.race); } @@ -320,8 +320,8 @@ strcpy (first_map_path, EXIT_PATH (&at->clone)); return; } - } - at = at->next; + } + at = at->next; } LOG(llevDebug,"You Need a archetype called 'map' and it have to contain start map\n"); exit (-1); @@ -341,8 +341,8 @@ sprintf(filename, "%s/clockdata", settings.localdir); if ((fp = fopen(filename, "w")) == NULL) { - LOG(llevError, "Cannot open %s for writing\n", filename); - return; + LOG(llevError, "Cannot open %s for writing\n", filename); + return; } fprintf(fp, "%lu", todtick); fclose(fp); @@ -368,9 +368,9 @@ LOG(llevDebug, "Reading clockdata from %s...", filename); if ((fp = fopen(filename, "r")) == NULL) { LOG(llevError, "Can't open %s.\n", filename); - todtick = 0; - write_todclock(); - return; + todtick = 0; + write_todclock(); + return; } fscanf(fp, "%lu", &todtick); LOG(llevDebug, "todtick=%lu\n", todtick); @@ -402,65 +402,65 @@ LOG(llevDebug, "Reading attack messages from %s...", filename); if ((fp = open_and_uncompress(filename, 0, &comp)) == NULL) { LOG(llevError, "Can't open %s.\n", filename); - return; + return; } level = 0; while (fgets(buf, MAX_BUF, fp)!=NULL) { if (*buf=='#') continue; - if((cp=strchr(buf,'\n'))!=NULL) + if((cp=strchr(buf,'\n'))!=NULL) *cp='\0'; - cp=buf; - while(*cp==' ') /* Skip blanks */ - cp++; - - if (strncmp(cp, "TYPE:", 5)==0) { - p = strtok(buf, ":"); - p = strtok(NULL, ":"); - if (mode == 1) { - attack_mess[mess][level].level = -1; - attack_mess[mess][level].buf1 = NULL; - attack_mess[mess][level].buf2 = NULL; - attack_mess[mess][level].buf3 = NULL; - } - level = 0; - mess = atoi(p); - mode = 1; - continue; - } - if (mode==1) { - p = strtok(buf, "="); - attack_mess[mess][level].level = atoi(buf); - p = strtok(NULL, "="); - if (p != NULL) - attack_mess[mess][level].buf1 = strdup_local(p); - else - attack_mess[mess][level].buf1 = strdup_local(""); - mode = 2; - continue; - } else if (mode==2) { - p = strtok(buf, "="); - attack_mess[mess][level].level = atoi(buf); - p = strtok(NULL, "="); - if (p != NULL) - attack_mess[mess][level].buf2 = strdup_local(p); - else - attack_mess[mess][level].buf2 = strdup_local(""); - mode = 3; - continue; - } else if (mode==3) { - p = strtok(buf, "="); - attack_mess[mess][level].level = atoi(buf); - p = strtok(NULL, "="); - if (p != NULL) - attack_mess[mess][level].buf3 = strdup_local(p); - else - attack_mess[mess][level].buf3 = strdup_local(""); - mode = 1; - level++; - total++; - continue; - } + cp=buf; + while(*cp==' ') /* Skip blanks */ + cp++; + + if (strncmp(cp, "TYPE:", 5)==0) { + p = strtok(buf, ":"); + p = strtok(NULL, ":"); + if (mode == 1) { + attack_mess[mess][level].level = -1; + attack_mess[mess][level].buf1 = NULL; + attack_mess[mess][level].buf2 = NULL; + attack_mess[mess][level].buf3 = NULL; + } + level = 0; + mess = atoi(p); + mode = 1; + continue; + } + if (mode==1) { + p = strtok(buf, "="); + attack_mess[mess][level].level = atoi(buf); + p = strtok(NULL, "="); + if (p != NULL) + attack_mess[mess][level].buf1 = strdup_local(p); + else + attack_mess[mess][level].buf1 = strdup_local(""); + mode = 2; + continue; + } else if (mode==2) { + p = strtok(buf, "="); + attack_mess[mess][level].level = atoi(buf); + p = strtok(NULL, "="); + if (p != NULL) + attack_mess[mess][level].buf2 = strdup_local(p); + else + attack_mess[mess][level].buf2 = strdup_local(""); + mode = 3; + continue; + } else if (mode==3) { + p = strtok(buf, "="); + attack_mess[mess][level].level = atoi(buf); + p = strtok(NULL, "="); + if (p != NULL) + attack_mess[mess][level].buf3 = strdup_local(p); + else + attack_mess[mess][level].buf3 = strdup_local(""); + mode = 1; + level++; + total++; + continue; + } } LOG(llevDebug, "got %d messages in %d categories.\n", total, mess+1); close_and_delete(fp, comp);