#include "mech.h"
Include dependency graph for econ.c:
Go to the source code of this file.
Functions | |
char * | silly_atr_get (int id, int flag) |
void | silly_atr_set (int id, int flag, char *dat) |
static void | remove_entry (char *alku, char *entry) |
static void | add_entry (char *to, char *data) |
static char * | find_entry (char *s, int i, int b) |
char * | get_parts_short_name (int, int) |
void | econ_change_items (dbref d, int id, int brand, int num) |
int | econ_find_items (dbref d, int id, int brand) |
void | econ_set_items (dbref d, int id, int brand, int num) |
static void add_entry | ( | char * | to, | |
char * | data | |||
) | [static] |
Definition at line 50 of file econ.c.
Referenced by econ_change_items().
00051 { 00052 if(*to) 00053 sprintf(to + strlen(to), ",[%s]", data); 00054 else 00055 sprintf(to, "[%s]", data); 00056 }
void econ_change_items | ( | dbref | d, | |
int | id, | |||
int | brand, | |||
int | num | |||
) |
Definition at line 68 of file econ.c.
References A_ECONPARTS, add_entry(), Cargo, econ_change_items(), find_entry(), get_parts_short_name(), Good_obj, IsActuator, remove_entry(), S_ACTUATOR, silly_atr_get(), silly_atr_set(), and tprintf().
Referenced by econ_change_items(), econ_set_items(), fun_btaddstores(), fun_btremovestores(), and mech_Rfixstuff().
00069 { 00070 char *t, *u; 00071 int base = 0, i1, i2, i3; 00072 00073 if(!Good_obj(d)) 00074 return; 00075 if(brand) 00076 if(get_parts_short_name(id, brand) == get_parts_short_name(id, 0)) 00077 brand = 0; 00078 t = silly_atr_get(d, A_ECONPARTS); 00079 if((u = find_entry(t, id, brand))) { 00080 if(sscanf(u, "[%d,%d,%d]", &i1, &i2, &i3) == 3) 00081 base += i3; 00082 remove_entry(t, u); 00083 } 00084 base += num; 00085 if(base <= 0) { 00086 if(u) 00087 silly_atr_set(d, A_ECONPARTS, t); 00088 return; 00089 } 00090 if(!(IsActuator(id))) 00091 add_entry(t, tprintf("%d,%d,%d", id, brand, base)); 00092 silly_atr_set(d, A_ECONPARTS, t); 00093 if(IsActuator(id)) 00094 econ_change_items(d, Cargo(S_ACTUATOR), brand, base); 00095 /* Successfully changed */ 00096 }
int econ_find_items | ( | dbref | d, | |
int | id, | |||
int | brand | |||
) |
Definition at line 98 of file econ.c.
References A_ECONPARTS, find_entry(), get_parts_short_name(), Good_obj, and silly_atr_get().
Referenced by econ_set_items(), fun_btremovestores(), fun_btstores(), and stuff_change_sub().
00099 { 00100 char *t, *u; 00101 int i1, i2, i3; 00102 00103 if(!Good_obj(d)) 00104 return 0; 00105 if(brand) 00106 if(get_parts_short_name(id, brand) == get_parts_short_name(id, 0)) 00107 brand = 0; 00108 t = silly_atr_get(d, A_ECONPARTS); 00109 if((u = find_entry(t, id, brand))) 00110 if(sscanf(u, "[%d,%d,%d]", &i1, &i2, &i3) == 3) 00111 return i3; 00112 return 0; 00113 }
void econ_set_items | ( | dbref | d, | |
int | id, | |||
int | brand, | |||
int | num | |||
) |
Definition at line 115 of file econ.c.
References econ_change_items(), econ_find_items(), and Good_obj.
00116 { 00117 int i; 00118 00119 if(!Good_obj(d)) 00120 return; 00121 i = econ_find_items(d, id, brand); 00122 if(i != num) 00123 econ_change_items(d, id, brand, num - i); 00124 }
static char* find_entry | ( | char * | s, | |
int | i, | |||
int | b | |||
) | [static] |
Definition at line 58 of file econ.c.
References MBUF_SIZE.
Referenced by econ_change_items(), and econ_find_items().
00059 { 00060 char buf[MBUF_SIZE]; 00061 00062 sprintf(buf, "[%d,%d,", i, b); 00063 return strstr(s, buf); 00064 }
char* get_parts_short_name | ( | int | , | |
int | ||||
) |
Referenced by econ_change_items(), and econ_find_items().
static void remove_entry | ( | char * | alku, | |
char * | entry | |||
) | [static] |
Definition at line 30 of file econ.c.
Referenced by econ_change_items().
00031 { 00032 char *j; 00033 00034 if(!(j = strstr(entry, "]"))) 00035 return; 00036 j++; 00037 if(*j) { 00038 /* Move the remainder of the string, including the terminating NUL, 00039 but not including the separating comma */ 00040 j++; 00041 memmove(entry, j, strlen(j) + 1); 00042 } else { 00043 if(entry == alku) 00044 *alku = '\0'; 00045 else 00046 *(entry - 1) = '\0'; 00047 } 00048 }
char* silly_atr_get | ( | int | id, | |
int | flag | |||
) |
Definition at line 44 of file glue.hcode.c.
00045 { 00046 int i, j; 00047 static char buf[LBUF_SIZE]; 00048 00049 atr_get_str(buf, id, flag, &i, &j); 00050 return buf; 00051 #if 0 /* This would waste memory, so.. :P */ 00052 return atr_pget(id, flag, &i, &j); 00053 #endif 00054 }
void silly_atr_set | ( | int | id, | |
int | flag, | |||
char * | dat | |||
) |
Definition at line 56 of file glue.hcode.c.
Referenced by autoeject(), char_disembark(), char_eject(), do_charclear(), do_name(), econ_change_items(), load_template(), mech_Rfixstuff(), mech_Rresetstuff(), store_attrs(), store_health(), tech_addtechtime(), and tele_contents().
00057 { 00058 atr_add_raw(id, flag, dat); 00059 }