#include "copyright.h"
#include "config.h"
#include "mudconf.h"
#include "htab.h"
#include "externs.h"
#include "alloc.h"
#include "attrs.h"
#include "db.h"
#include "pcache.h"
#include "rbtree.h"
Include dependency graph for player_c.c:
Go to the source code of this file.
Functions | |
int | compare_pcache (dbref left, dbref right) |
void | pcache_init (void) |
static void | pcache_reload1 (dbref player, PCACHE *pp) |
PCACHE * | pcache_find (dbref player) |
void | pcache_reload (dbref player) |
static void | pcache_save (PCACHE *pp) |
void | pcache_trim (void) |
void | pcache_sync (void) |
int | a_Queue (dbref player, int adj) |
void | s_Queue (dbref player, int val) |
int | QueueMax (dbref player) |
int | Pennies (dbref obj) |
void | s_Pennies (dbref obj, int howfew) |
int a_Queue | ( | dbref | player, | |
int | adj | |||
) |
Definition at line 153 of file player_c.c.
References OwnsOthers, pcache_find(), and player_cache::queue.
Referenced by do_top(), halt_que(), nfy_que(), and setup_que().
00154 { 00155 PCACHE *pp; 00156 00157 if(OwnsOthers(player)) { 00158 pp = pcache_find(player); 00159 if(pp) 00160 pp->queue += adj; 00161 return pp->queue; 00162 } 00163 return 0; 00164 }
Definition at line 47 of file player_c.c.
References player_cache::cflags, Good_obj, player_cache::next, OwnsOthers, pcache_head, pcache_reload1(), pcache_tree, PF_REF, player_cache::player, player_cache::queue, rb_find(), and rb_insert().
Referenced by a_Queue(), pcache_reload(), Pennies(), QueueMax(), s_Pennies(), and s_Queue().
00048 { 00049 PCACHE *pp; 00050 00051 if(!Good_obj(player) || !OwnsOthers(player)) 00052 return NULL; 00053 00054 pp = (PCACHE *) rb_find(pcache_tree, (void *)player); 00055 if(pp) { 00056 pp->cflags |= PF_REF; 00057 return pp; 00058 } 00059 pp = malloc(sizeof(PCACHE)); 00060 pp->queue = 0; 00061 pp->cflags = PF_REF; 00062 pp->player = player; 00063 pcache_reload1(player, pp); 00064 pp->next = pcache_head; 00065 pcache_head = pp; 00066 rb_insert(pcache_tree, (void *)player, (void *)pp); 00067 return pp; 00068 }
void pcache_init | ( | void | ) |
Definition at line 22 of file player_c.c.
References compare_pcache(), pcache_head, pcache_tree, and rb_init().
Referenced by main().
00023 { 00024 pcache_tree = rb_init((void *)compare_pcache, NULL); 00025 pcache_head = NULL; 00026 }
void pcache_reload | ( | dbref | player | ) |
Definition at line 70 of file player_c.c.
References pcache_find(), and pcache_reload1().
Referenced by atr_add_raw(), and atr_clr().
00071 { 00072 PCACHE *pp; 00073 00074 pp = pcache_find(player); 00075 if(!pp) 00076 return; 00077 pcache_reload1(player, pp); 00078 }
Definition at line 28 of file player_c.c.
References A_MONEY, A_QUEUEMAX, atr_get_raw(), player_cache::money, mudconf, player_cache::qmax, confdata::queuemax, and Wizard.
Referenced by pcache_find(), and pcache_reload().
00029 { 00030 char *cp; 00031 00032 cp = atr_get_raw(player, A_MONEY); 00033 if(cp && *cp) 00034 pp->money = atoi(cp); 00035 else 00036 pp->money = 0; 00037 00038 cp = atr_get_raw(player, A_QUEUEMAX); 00039 if(cp && *cp) 00040 pp->qmax = atoi(cp); 00041 else if(!Wizard(player)) 00042 pp->qmax = mudconf.queuemax; 00043 else 00044 pp->qmax = -1; 00045 }
static void pcache_save | ( | PCACHE * | pp | ) | [static] |
Definition at line 80 of file player_c.c.
References A_MONEY, A_QUEUEMAX, atr_add_raw(), player_cache::cflags, player_cache::money, PF_DEAD, PF_MONEY_CH, PF_QMAX_CH, player_cache::player, and player_cache::qmax.
Referenced by pcache_sync(), and pcache_trim().
00081 { 00082 IBUF tbuf; 00083 00084 if(pp->cflags & PF_DEAD) 00085 return; 00086 if(pp->cflags & PF_MONEY_CH) { 00087 sprintf(tbuf, "%d", pp->money); 00088 atr_add_raw(pp->player, A_MONEY, tbuf); 00089 } 00090 if(pp->cflags & PF_QMAX_CH) { 00091 sprintf(tbuf, "%d", pp->qmax); 00092 atr_add_raw(pp->player, A_QUEUEMAX, tbuf); 00093 } 00094 pp->cflags &= ~(PF_MONEY_CH | PF_QMAX_CH); 00095 }
void pcache_sync | ( | void | ) |
Definition at line 125 of file player_c.c.
References pcache_head, and pcache_save().
Referenced by do_shutdown(), dump_database(), and fork_and_dump().
00126 { 00127 PCACHE *pp; 00128 00129 pp = pcache_head; 00130 while (pp) { 00131 pcache_save(pp); 00132 pp = pp->next; 00133 } 00134 }
void pcache_trim | ( | void | ) |
Definition at line 97 of file player_c.c.
References player_cache::cflags, player_cache::next, pcache_head, pcache_save(), pcache_tree, PF_DEAD, PF_REF, player_cache::queue, and rb_delete().
Referenced by dispatch().
00098 { 00099 PCACHE *pp, *pplast, *ppnext; 00100 return; 00101 00102 pp = pcache_head; 00103 pplast = NULL; 00104 while (pp) { 00105 if(!(pp->cflags & PF_DEAD) && (pp->queue || (pp->cflags & PF_REF))) { 00106 pp->cflags &= ~PF_REF; 00107 pplast = pp; 00108 pp = pp->next; 00109 } else { 00110 ppnext = pp->next; 00111 if(pplast) 00112 pplast->next = ppnext; 00113 else 00114 pcache_head = ppnext; 00115 if(!(pp->cflags & PF_DEAD)) { 00116 pcache_save(pp); 00117 rb_delete(pcache_tree, (void *)pp->player); 00118 } 00119 free(pp); 00120 pp = ppnext; 00121 } 00122 } 00123 }
int Pennies | ( | dbref | obj | ) |
Definition at line 198 of file player_c.c.
References A_MONEY, atr_get_raw(), player_cache::money, OwnsOthers, pcache_find(), and safe_atoi.
Referenced by canpayfees(), check_pennies(), create_guest(), db_write_object(), debug_examine(), destroy_obj(), do_chown(), do_clone(), do_examine(), do_kill(), do_poor(), do_score(), fun_money(), give_money(), giveto(), mmdb_write_object(), move_object(), payfor(), shutdownsock(), xml_db_write_mux(), and xml_db_write_object().
00199 { 00200 char *cp; 00201 00202 PCACHE *pp; 00203 00204 if(OwnsOthers(obj)) { 00205 pp = pcache_find(obj); 00206 if(pp) 00207 return pp->money; 00208 } 00209 cp = atr_get_raw(obj, A_MONEY); 00210 return (safe_atoi(cp)); 00211 }
int QueueMax | ( | dbref | player | ) |
Definition at line 177 of file player_c.c.
References statedata::db_top, mudconf, mudstate, OwnsOthers, pcache_find(), player_cache::qmax, and confdata::queuemax.
Referenced by setup_que().
00178 { 00179 PCACHE *pp; 00180 int m; 00181 00182 m = 0; 00183 if(OwnsOthers(player)) { 00184 pp = pcache_find(player); 00185 if(pp) { 00186 if(pp->qmax >= 0) { 00187 m = pp->qmax; 00188 } else { 00189 m = mudstate.db_top + 1; 00190 if(m < mudconf.queuemax) 00191 m = mudconf.queuemax; 00192 } 00193 } 00194 } 00195 return m; 00196 }
void s_Pennies | ( | dbref | obj, | |
int | howfew | |||
) |
Definition at line 213 of file player_c.c.
References A_MONEY, atr_add_raw(), player_cache::cflags, player_cache::money, OwnsOthers, pcache_find(), and PF_MONEY_CH.
Referenced by check_pennies(), create_guest(), create_obj(), db_make_minimal(), db_read(), destroy_obj(), do_fixdb(), do_poor(), do_toad(), giveto(), mmdb_db_read(), and payfor().
00214 { 00215 IBUF tbuf; 00216 00217 PCACHE *pp; 00218 00219 if(OwnsOthers(obj)) { 00220 pp = pcache_find(obj); 00221 if(pp) { 00222 pp->money = howfew; 00223 pp->cflags |= PF_MONEY_CH; 00224 } 00225 } 00226 sprintf(tbuf, "%d", howfew); 00227 atr_add_raw(obj, A_MONEY, tbuf); 00228 }
void s_Queue | ( | dbref | player, | |
int | val | |||
) |
Definition at line 166 of file player_c.c.
References OwnsOthers, pcache_find(), and player_cache::queue.
Referenced by halt_que().
00167 { 00168 PCACHE *pp; 00169 00170 if(OwnsOthers(player)) { 00171 pp = pcache_find(player); 00172 if(pp) 00173 pp->queue = val; 00174 } 00175 }