Greetings, I wrote a little code to go through the pfile and get the names of every guildleader, then sort them by guilds and put this list in a file (it lags up a bit to search thru the pfile so I just have it generate this file whenever there's a change in guildleaders). It works except for one thing, this guildlist file that it generates always has some random symbols around the 12th line in the file. For example: {Aiel Leader} Leara, (Wise One, Taardad) ¸{ý {Warder Leader} Lan, (Dai'Shan, Gaidin) The first is line 11 (how its supposed to be) but line 12 has the weird symbol. Sometimes these symbols occur on a completely different line or person or position. And these symbols also appear to be completely random. We've been using this code for about a month now and other then that, there are no problems however every once in a while these random symbol would crash the mud and keep it from booting until they are removed. Can't seem to figure this one out. Here's the function that generates the file: ----- void gl_list_update(void) { CHAR_DATA *tch; CHAR_DATA *cbuf = NULL; CHAR_FILE_U tmp_store; FILE *fl; char buf[MAX_INPUT_LENGTH], gltitle[MAX_INPUT_LENGTH], tbuf[120]; int indentcounter = 0, player_i = 0, j, i = 0, g = 1, temp; extern int top_of_p_table; extern struct player_index_element *player_table; extern struct guildstruct { char *guild; int nr; } guilds_polite[]; extern int get_clan_pointer(int guildnr, int clannr); extern int get_guild_pointer(int guildnr); extern int get_rank_pointer(int guildnr, int ranknr); int maxgls = (GLD_LAST * 4); struct sort_list { int guild; char *name; } glsort [maxgls]; *buf = '\0'; sprintf(buf, "`$ Current Guild Leaders for All Guilds:\r\n"); sprintf(buf, "%s -~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-`7\r\n", buf); // Here is is where it goes thru the pfile and finds these people. for (j = 0; j <= top_of_p_table; j++) { *buf2 = '\0'; *gltitle = '\0'; CREATE(cbuf, CHAR_DATA, 1); clear_char(cbuf); if ((player_i = load_char((player_table + j)->name, &tmp_store)) > -1) { store_to_char(&tmp_store, cbuf); tch = cbuf; } else { free(cbuf); return; } // Here it creates the lines that are displayed if ((GET_TRUST(tch) < LVL_IMMORT) && GET_GUILD(tch) && PRF_FLAGGED(tch, PRF_GLEADER)) { sprintf(gltitle, "`4{`^%s Leader`4}`6", guilds_polite[get_guild_pointer(GET_GUILD(tch))].guild); for (indentcounter=strlen(guilds_polite[get_guild_pointer(GET_GUILD(tch))].guild); indentcounter<18; indentcounter++) strcat(buf2," "); strcat(buf2,gltitle); sprintf(tbuf, "(%s", ranks[get_rank_pointer(GET_GUILD(tch), GET_RANK(tch))].rank); if(GET_CLAN(tch)) sprintf(tbuf, "%s, %s) ", tbuf, clans[get_clan_pointer(GET_GUILD(tch), GET_CLAN(tch))].clan); else sprintf(tbuf, "%s) ", tbuf); sprintf(buf2, "%s `6%s`7,`# %s`7\r\n", buf2, GET_NAME(tch), tbuf); i++; // Here is stores these lines to be sorted. The bug occurs even if I don't sort though. glsort[i].guild = GET_GUILD(tch); glsort[i].name = str_dup(buf2); } free(tch); } temp = i; // Here it sorts em. while (g < GLD_LAST) { while (i > 0) { if (glsort[i].guild == g) strcat(buf, glsort[i].name); i--; } i = temp; g++; } // Here it appends the bottom to the list sprintf(buf, "%s `1{`!Forsaken Leader`1}`6 Shai'tan`7, `!(The Dark One)\r\n", buf);i++; sprintf(buf, "%s`%% %d `5Guild Leaders found.\r\n", buf, i); sprintf(buf, "%s `$-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-._.-~-`7\r\n", buf); // And here it writes em. if ((fl = fopen("text/gl_list", "w"))) { fprintf(fl, "%s", buf); fclose(fl); fwrite(buf, sizeof(char), strlen(buf), fl); sprintf(buf, "GL list written to /lib/text/gl_list"); log(buf); } else { sprintf(buf, "Error opening /lib/text/gl_list"); log(buf); } } ----- If anyone has any idea whats causing it I would appreciate the help. Allan | Pheonix +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 04/10/01 PDT