From 655730e5a02a053a83fdecb053034c91377f51f7 Mon Sep 17 00:00:00 2001 From: MadCamel Date: Sat, 6 Apr 2013 15:43:21 -0400 Subject: Removed sorting of character data file. It accomplished nothing except making it look pretty, and chewed an inordinate amount of CPU. Also inlined mmo_char_tostr and set things up so players end up in tulimshar if their map save location is bad. --- src/char/char.cpp | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) (limited to 'src/char/char.cpp') diff --git a/src/char/char.cpp b/src/char/char.cpp index acb52fd..c8b3e76 100644 --- a/src/char/char.cpp +++ b/src/char/char.cpp @@ -213,7 +213,7 @@ char *search_character_name (int index) //------------------------------------------------- // Function to create the character line (for save) //------------------------------------------------- -static +__inline__ static int mmo_char_tostr (char *str, struct mmo_charstatus *p) { int i; @@ -222,7 +222,7 @@ int mmo_char_tostr (char *str, struct mmo_charstatus *p) // on multi-map server, sometimes it's posssible that last_point become void. (reason???) We check that to not lost character at restart. if (p->last_point.map[0] == '\0') { - memcpy (p->last_point.map, "prontera.gat", 16); + memcpy (p->last_point.map, "001-1.gat", 10); p->last_point.x = 273; p->last_point.y = 354; } @@ -707,26 +707,6 @@ void mmo_char_sync (void) int i, j, k; int lock; FILE *fp; - int id[char_num]; - - // Sorting before save (by [Yor]) - for (i = 0; i < char_num; i++) - { - id[i] = i; - for (j = 0; j < i; j++) - { - if ((char_dat[i].account_id < char_dat[id[j]].account_id) || - // if same account id, we sort by slot. - (char_dat[i].account_id == char_dat[id[j]].account_id && - char_dat[i].char_num < char_dat[id[j]].char_num)) - { - for (k = i; k > j; k--) - id[k] = id[k - 1]; - id[j] = i; // id[i] - break; - } - } - } // Data save fp = lock_fopen (char_txt, &lock); @@ -740,7 +720,7 @@ void mmo_char_sync (void) for (i = 0; i < char_num; i++) { // create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line) - mmo_char_tostr (line, &char_dat[id[i]]); // use of sorted index + mmo_char_tostr (line, &char_dat[i]); // use of sorted index fprintf (fp, "%s\n", line); } fprintf (fp, "%d\t%%newid%%\n", char_id_count); @@ -762,7 +742,7 @@ void mmo_char_sync (void) for (i = 0; i < char_num; i++) { // create only once the line, and save it in the 2 files (it's speeder than repeat twice the loop and create twice the line) - mmo_char_tostr (line, &char_dat[id[i]]); // use of sorted index + mmo_char_tostr (line, &char_dat[i]); // use of sorted index fprintf (fp, "%s\n", line); } fprintf (fp, "%d\t%%newid%%\n", char_id_count); -- cgit v1.2.3-70-g09d2