From ce697837e94da1fa7ac0a1dc83e3518c882c5f82 Mon Sep 17 00:00:00 2001 From: piaip Date: Sun, 13 Sep 2009 04:02:01 +0000 Subject: * 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 --- mbbsd/passwd.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'mbbsd/passwd.c') 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 () -- cgit v1.2.3