summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 06:09:21 +0800
committerptt <ptt@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2004-03-30 06:09:21 +0800
commit7fc05c147f265dbbb11ae8a37684779e4f5c2644 (patch)
treea9adea72a1e3b90c793d2b534f69ecdbf6a59fb0
parent36d5b89b27a3d9a1c814a8aa79e971f151d40dba (diff)
downloadpttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar.gz
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar.bz2
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar.lz
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar.xz
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.tar.zst
pttbbs-7fc05c147f265dbbb11ae8a37684779e4f5c2644.zip
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@1632 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
-rw-r--r--util/uhash_loader.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/util/uhash_loader.c b/util/uhash_loader.c
index 931a0b64..00ba2d70 100644
--- a/util/uhash_loader.c
+++ b/util/uhash_loader.c
@@ -117,15 +117,14 @@ unsigned string_hash(unsigned char *s)
return (v * 2654435769UL) >> (32 - HASH_BITS);
}
-int loadmoney(char * userid)
+int loadmoney(userec_t *user)
{
- static userec_t u;
int fd, money=0;
char path[256];
- sprintf(path,"home/%c/%s", userid[0], userid);
+ sprintf(path,"home/%c/%s", user->userid[0], user->userid);
if((fd=open(path, O_RDONLY))<0)
- return 0;
- if(lseek(fd, (off_t)((int)&u.money - (int)&u), SEEK_SET) >= 0)
+ return user->money;
+ if(lseek(fd, (off_t)((int)&(user->money) - (int)user), SEEK_SET) >= 0)
read(fd, &money, sizeof(int));
close(fd);
return money;
@@ -135,7 +134,7 @@ void add_to_uhash(int n, userec_t *user)
{
int *p, h = string_hash(user->userid);
strcpy(SHM->userid[n], user->userid);
- SHM->money[n] = loadmoney(user->userid);
+ SHM->money[n] = loadmoney(user);
//SHM->money[n] = user->money;
// Ptt: money is not accurate must load from user home