summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorMadCamel <madcamel@gmail.com>2013-04-06 15:43:21 -0400
committerBen Longbons <b.r.longbons@gmail.com>2013-04-13 21:55:21 -0700
commit655730e5a02a053a83fdecb053034c91377f51f7 (patch)
tree4179474ba95e01f0e22f03fb00866599414354c6 /src/char
parent656b408655a676d770c8e5ef1030accc7653680d (diff)
downloadtmwa-655730e5a02a053a83fdecb053034c91377f51f7.tar.gz
tmwa-655730e5a02a053a83fdecb053034c91377f51f7.tar.bz2
tmwa-655730e5a02a053a83fdecb053034c91377f51f7.tar.xz
tmwa-655730e5a02a053a83fdecb053034c91377f51f7.zip
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.
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.cpp28
1 files changed, 4 insertions, 24 deletions
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);