diff options
author | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-13 12:02:01 +0800 |
---|---|---|
committer | piaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204> | 2009-09-13 12:02:01 +0800 |
commit | ce697837e94da1fa7ac0a1dc83e3518c882c5f82 (patch) | |
tree | 7f09b889ab5d54b9f478f40d5c205d9ee5355595 /mbbsd/passwd.c | |
parent | e3996173b492a380965b21be3a515b0f39ffa721 (diff) | |
download | pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar.gz pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar.bz2 pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar.lz pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar.xz pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.tar.zst pttbbs-ce697837e94da1fa7ac0a1dc83e3518c882c5f82.zip |
* fix: money was not synchronized...
* also enhanced more check with explicit reload
git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4835 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/passwd.c')
-rw-r--r-- | mbbsd/passwd.c | 30 |
1 files changed, 28 insertions, 2 deletions
diff --git a/mbbsd/passwd.c b/mbbsd/passwd.c index 658e7dce..667b69a5 100644 --- a/mbbsd/passwd.c +++ b/mbbsd/passwd.c @@ -30,6 +30,9 @@ passwd_sync_update(int num, userec_t * buf) if (passwd_update(num, buf) != 0) return -1; + if (num == usernum) + cuser.money = moneyof(num); + return 0; } @@ -40,6 +43,10 @@ passwd_sync_query(int num, userec_t * buf) return -1; buf->money = moneyof(num); + + if (num == usernum) + cuser.money = moneyof(num); + return 0; } @@ -49,7 +56,7 @@ static int pwcuInitCUser(userec_t *u) { assert(usernum > 0 && usernum <= MAX_USERS); - if (passwd_query(usernum, u) != 0) + if (passwd_sync_query(usernum, u) != 0) return -1; assert(strncmp(u->userid, cuser.userid, IDLEN) == 0); if (strncmp(u->userid, cuser.userid, IDLEN) != 0) @@ -62,7 +69,7 @@ pwcuFinalCUser(userec_t *u) { assert(usernum > 0 && usernum <= MAX_USERS); assert(strcmp(u->userid, cuser.userid) == 0); - if (passwd_update(usernum, u) != 0) + if (passwd_sync_update(usernum, u) != 0) return -1; return 0; } @@ -503,6 +510,10 @@ pwcuExitSave () PWCU_START(); + // XXX if PWCU_START uses sync_query, then money is + // already changed... however, maybe not a problem here, + // since every deumoney() should write difference. + // save variables for dirty check uflag = u.uflag; uflag2= u.uflag2; @@ -569,6 +580,21 @@ pwcuReload () return r; } +int +pwcuReloadMoney () +{ + cuser.money=moneyof(usernum); + return 0; +} + +int +pwcuDeMoney (int money) +{ + deumoney(usernum, money); + cuser.money = moneyof(usernum); + return 0; +} + // Initialization void pwcuInitZero () |