diff options
author | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-11-13 21:06:21 +0000 |
---|---|---|
committer | ultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec> | 2009-11-13 21:06:21 +0000 |
commit | 8bb31688f71af76a143220c41079d3e01be85c1a (patch) | |
tree | b3836c0c43f62110781fdec5e9dfc7863b2f740c /src/common | |
parent | dc4f74eb17589524084cd08118f6fb60cfdcbf02 (diff) | |
download | hercules-8bb31688f71af76a143220c41079d3e01be85c1a.tar.gz hercules-8bb31688f71af76a143220c41079d3e01be85c1a.tar.bz2 hercules-8bb31688f71af76a143220c41079d3e01be85c1a.tar.xz hercules-8bb31688f71af76a143220c41079d3e01be85c1a.zip |
Resolved a client hang in the scenario where the client sent loadendack before the server finished loading all data (bugreport:3700).
Improved the performance of pc_autosave() to stop scanning players after it has already found the player it wanted to save (bugreport:3717).
The 'overweight' status changes (SC_WEIGHT50/SC_WEIGHT90) will now be cleared on logout, to avoid saving them into the database (they get derived from player weight during login anyway).
Improved lock.c on windows to use C's access(0) function instead of doing fopen/fclose when testing for existence of files.
Re-added the 'static' attribute to mapindex_getmapname_ext's buffer; returning the address of a non-static local variable is undefined behavior (see r13901).
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@14144 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/lock.c | 16 | ||||
-rw-r--r-- | src/common/mapindex.c | 2 |
2 files changed, 4 insertions, 14 deletions
diff --git a/src/common/lock.c b/src/common/lock.c index e4ec36302..5cb4c3a67 100644 --- a/src/common/lock.c +++ b/src/common/lock.c @@ -11,21 +11,12 @@ #ifndef WIN32 #include <unistd.h> #else -#include <windows.h> +#include <io.h> #define F_OK 0x0 #define R_OK 0x4 #endif -#ifndef WIN32 - #define exists(filename) (!access(filename, F_OK)) -#else -// could be speed up maybe? -int exists(char *file) { - FILE *fp; - if ((fp = fopen(file,"r")) && fclose(fp) == 0) return 1; - return 0; -} -#endif +#define exists(filename) (!access(filename, F_OK)) // 書き込みファイルの保護処理 // (書き込みが終わるまで、旧ファイルを保管しておく) @@ -33,13 +24,12 @@ int exists(char *file) { // 新しいファイルの書き込み開始 FILE* lock_fopen (const char* filename, int *info) { char newfile[512]; - FILE *fp; int no = 0; // 安全なファイル名を得る(手抜き) do { sprintf(newfile, "%s_%04d.tmp", filename, ++no); - } while((fp = fopen(newfile,"r")) && (fclose(fp), no < 9999)); + } while(exists(newfile) && no < 9999); *info = no; return fopen(newfile,"w"); } diff --git a/src/common/mapindex.c b/src/common/mapindex.c index ca2ff4751..a1c86af97 100644 --- a/src/common/mapindex.c +++ b/src/common/mapindex.c @@ -47,7 +47,7 @@ const char* mapindex_getmapname(const char* string, char* output) /// Result gets placed either into 'buf' or in a static local buffer. const char* mapindex_getmapname_ext(const char* string, char* output) { - char buf[MAP_NAME_LENGTH_EXT]; + static char buf[MAP_NAME_LENGTH_EXT]; char* dest = (output != NULL) ? output : buf; size_t len; |