src/hcode/btech/p.econ_cmds.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void SetCargoWeight (MECH *mech)
int loading_bay_whine (dbref player, dbref cargobay, MECH *mech)
void mech_Rfixstuff (dbref player, void *data, char *buffer)
void list_matching (dbref player, char *header, dbref loc, char *buf)
void mech_manifest (dbref player, void *data, char *buffer)
void mech_stores (dbref player, void *data, char *buffer)
void mech_Raddstuff (dbref player, void *data, char *buffer)
void mech_Rremovestuff (dbref player, void *data, char *buffer)
void mech_loadcargo (dbref player, void *data, char *buffer)
void mech_unloadcargo (dbref player, void *data, char *buffer)
void mech_Rresetstuff (dbref player, void *data, char *buffer)


Function Documentation

void list_matching ( dbref  player,
char *  header,
dbref  loc,
char *  buf 
)

Definition at line 138 of file econ_cmds.c.

References A_ECONPARTS, BRANDCOUNT, BT_PART_WEIGHTS, c, CM_CENTER, CM_LINE, CM_NOTOG, CM_NUMBER, CM_ONE, CM_TWO, CreateMenuEntry_Killer(), CreateMenuEntry_Simple, find_matching_long_part(), GetPartWeight(), KillCoolMenu(), LBUF_SIZE, NUM_ITEMS, object_count, part_name_long(), SendError, short_sorted, ShowCoolMenu(), silly_atr_get(), tprintf(), UNPACK_PART, and x.

00139 {
00140         int pile[BRANDCOUNT + 1][NUM_ITEMS];
00141         int pile2[BRANDCOUNT + 1][NUM_ITEMS];
00142         char *t, *ch;
00143         int i1, i2, i3, id, brand;
00144         int x, i;
00145 
00146 #ifdef BT_PART_WEIGHTS
00147         char tmpstr[LBUF_SIZE];
00148         int sw = 0;
00149 #endif /* BT_PART_WEIGHTS */
00150         coolmenu *c = NULL;
00151         int found = 0;
00152 
00153         bzero(pile, sizeof(pile));
00154         bzero(pile2, sizeof(pile2));
00155         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00156         CreateMenuEntry_Simple(&c, header, CM_ONE | CM_CENTER);
00157         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00158         /* Then, we go on a mad rampage ;-) */
00159         t = silly_atr_get(loc, A_ECONPARTS);
00160         while (*t) {
00161                 if(*t == '[')
00162                         if((sscanf(t, "[%d,%d,%d]", &i1, &i2, &i3)) == 3)
00163                                 pile[i2][i1] += i3;
00164                 t++;
00165         }
00166         i = 0;
00167         if(buf)
00168                 while (find_matching_long_part(buf, &i, &id, &brand))
00169                         pile2[brand][id] = pile[brand][id];
00170         for(i = 0; i < object_count; i++) {
00171                 UNPACK_PART(short_sorted[i]->index, id, brand);
00172                 if((buf && (x = pile2[brand][id])) || ((!buf &&
00173                                                                                                 (x = pile[brand][id])))) {
00174 #ifndef BT_PART_WEIGHTS
00175                         ch = part_name_long(id, brand);
00176 #else
00177                         sw = GetPartWeight(id);
00178                         sprintf(tmpstr, "%s (%.1ft)", part_name_long(id, brand),
00179                                         (sw * x) / 1024.0);
00180                         ch = tmpstr;
00181 #endif /* BT_PART_WEIGHTS */
00182                         if(!ch) {
00183                                 SendError(tprintf
00184                                                   ("#%d in %d encountered odd thing: %d %d/%d's.",
00185                                                    player, loc, pile[brand][id], id, brand));
00186                                 continue;
00187                         }
00188                         /* x = amount of things */
00189                         CreateMenuEntry_Killer(&c, ch, CM_TWO | CM_NUMBER | CM_NOTOG,
00190                                                                    0, x, x);
00191                         found++;
00192                 }
00193         }
00194         if(!found)
00195                 CreateMenuEntry_Simple(&c, "None", CM_ONE);
00196         CreateMenuEntry_Simple(&c, NULL, CM_ONE | CM_LINE);
00197         ShowCoolMenu(player, c);
00198         KillCoolMenu(c);
00199 }

int loading_bay_whine ( dbref  player,
dbref  cargobay,
MECH mech 
)

Definition at line 82 of file econ_cmds.c.

References A_MECHSKILLS, c, MechX, MechY, notify, notify_printf(), and silly_atr_get().

Referenced by mech_loadcargo(), and mech_stores().

00083 {
00084         char *c;
00085         int i1, i2, i3 = 0;
00086 
00087         c = silly_atr_get(cargobay, A_MECHSKILLS);
00088         if(c && *c)
00089                 if(sscanf(c, "%d %d %d", &i1, &i2, &i3) >= 2)
00090                         if(MechX(mech) != i1 || MechY(mech) != i2) {
00091                                 notify(player, "You're not where the cargo is!");
00092                                 if(i3)
00093                                         notify_printf(player,
00094                                                                   "Try looking around %d,%d instead.", i1,
00095                                                                   i2);
00096                                 return 1;
00097                         }
00098         return 0;
00099 }

void mech_loadcargo ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 333 of file econ_cmds.c.

References CARGO_TECH, cch, correct_speed(), DOCHECK, In_Character, loading_bay_whine(), Location, MECH::mapindex, MECH_USUALO, MechSpecials, MechSpeed, MECH::mynum, and stuff_change_sub().

00334 {
00335         MECH *mech = (MECH *) data;
00336 
00337         cch(MECH_USUALO);
00338         DOCHECK(!(MechSpecials(mech) & CARGO_TECH),
00339                         "This unit cannot haul cargo!");
00340         DOCHECK(fabs(MechSpeed(mech)) > 0.0, "You're moving too fast!");
00341         DOCHECK(Location(mech->mynum) != mech->mapindex ||
00342                         In_Character(Location(mech->mynum)), "You aren't inside hangar!");
00343         if(loading_bay_whine(player, Location(mech->mynum), mech))
00344                 return;
00345         stuff_change_sub(player, buffer, mech->mynum, mech->mapindex, 1, 1);
00346         correct_speed(mech);
00347 }

void mech_manifest ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 207 of file econ_cmds.c.

References Location, and MY_DO_LIST.

00208 {
00209         while (isspace(*buffer))
00210                 buffer++;
00211         MY_DO_LIST(Location(player));
00212 }

void mech_Raddstuff ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 323 of file econ_cmds.c.

References Location, and stuff_change_sub().

00324 {
00325         stuff_change_sub(player, buffer, Location(player), -1, 1, 0);
00326 }

void mech_Rfixstuff ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 101 of file econ_cmds.c.

References A_ECONPARTS, BRANDCOUNT, econ_change_items(), get_parts_long_name(), IsCrap, loc, Location, notify_printf(), NUM_ITEMS, silly_atr_get(), and silly_atr_set().

Referenced by eliminate_empties().

00102 {
00103         int loc = Location(player);
00104         int pile[BRANDCOUNT + 1][NUM_ITEMS];
00105         char *t;
00106         int ol, nl, items = 0, kinds = 0;
00107         int i1, i2, i3, id, brand;
00108 
00109         if(!data)
00110                 loc = atoi(buffer);
00111         bzero(pile, sizeof(pile));
00112         t = silly_atr_get(loc, A_ECONPARTS);
00113         ol = strlen(t);
00114         while (*t) {
00115                 if(*t == '[')
00116                         if((sscanf(t, "[%d,%d,%d]", &i1, &i2, &i3)) == 3)
00117                                 if(!IsCrap(i1))
00118                                         pile[i2][i1] += i3;
00119                 t++;
00120         }
00121         silly_atr_set(loc, A_ECONPARTS, "");
00122         for(id = 0; id < NUM_ITEMS; id++)
00123                 for(brand = 0; brand <= BRANDCOUNT; brand++)
00124                         if(pile[brand][id] > 0 && get_parts_long_name(id, brand)) {
00125                                 econ_change_items(loc, id, brand, pile[brand][id]);
00126                                 kinds++;
00127                                 items += pile[brand][id];
00128                         }
00129         t = silly_atr_get(loc, A_ECONPARTS);
00130         nl = strlen(t);
00131         notify_printf(player,
00132                                   "Fixing done. Original length: %d. New length: %d.", ol,
00133                                   nl);
00134         notify_printf(player, "Items in new: %d. Unique items in new: %d.",
00135                                   items, kinds);
00136 }

void mech_Rremovestuff ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 328 of file econ_cmds.c.

References Location, and stuff_change_sub().

00329 {
00330         stuff_change_sub(player, buffer, Location(player), -1, -1, 0);
00331 }

void mech_Rresetstuff ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 360 of file econ_cmds.c.

References A_ECONPARTS, Location, notify, SendEcon, silly_atr_set(), and tprintf().

00361 {
00362         notify(player, "Inventory cleaned!");
00363         silly_atr_set(Location(player), A_ECONPARTS, "");
00364         SendEcon(tprintf("#%d reset #%d's stuff.", player, Location(player)));
00365 }

void mech_stores ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 214 of file econ_cmds.c.

References cch, DOCHECK, In_Character, loading_bay_whine(), Location, MECH::mapindex, MECH_USUAL, MY_DO_LIST, and MECH::mynum.

00215 {
00216         MECH *mech = (MECH *) data;
00217 
00218         cch(MECH_USUAL);
00219         DOCHECK(Location(mech->mynum) != mech->mapindex ||
00220                         In_Character(Location(mech->mynum)),
00221                         "You aren't inside a hangar!");
00222         if(loading_bay_whine(player, Location(mech->mynum), mech))
00223                 return;
00224         while (isspace(*buffer))
00225                 buffer++;
00226         MY_DO_LIST(Location(mech->mynum));
00227 }

void mech_unloadcargo ( dbref  player,
void *  data,
char *  buffer 
)

Definition at line 349 of file econ_cmds.c.

References CARGO_TECH, cch, correct_speed(), DOCHECK, MECH::mapindex, MECH_USUALSO, MechSpecials, MECH::mynum, and stuff_change_sub().

Referenced by auto_com_event().

00350 {
00351         MECH *mech = (MECH *) data;
00352 
00353         cch(MECH_USUALSO);
00354         DOCHECK(!(MechSpecials(mech) & CARGO_TECH),
00355                         "This unit cannot haul cargo!");
00356         stuff_change_sub(player, buffer, mech->mynum, mech->mapindex, -1, 1);
00357         correct_speed(mech);
00358 }

void SetCargoWeight ( MECH mech  ) 

Definition at line 40 of file econ_cmds.c.

References A_ECONPARTS, AeroFuel, AeroFuelMax, AeroFuelOrig, FlyingT, FUELTANK, GetPartType, GetPartWeight(), I2Special, IsBomb, IsSpecial, MECH::mynum, NUM_CRITICALS, NUM_ITEMS, NUM_SECTIONS, SetCarriedCargo, silly_atr_get(), and Special2I.

Referenced by bomb_drop(), correct_speed(), FuelCheck(), mech_startup_event(), and mech_udisembark().

00041 {
00042         int pile[NUM_ITEMS];
00043         int sw, weight = 0;                     /* in 1/10 tons */
00044         int i, j, k;
00045         char *t;
00046         int i1, i2, i3;
00047 
00048         t = silly_atr_get(mech->mynum, A_ECONPARTS);
00049         bzero(pile, sizeof(pile));
00050         while (*t) {
00051                 if(*t == '[')
00052                         if((sscanf(t, "[%d,%d,%d]", &i1, &i2, &i3)) == 3)
00053                                 pile[i1] += ((IsBomb(i1)) ? 4 : 1) * i3;
00054                 t++;
00055         }
00056         if(FlyingT(mech))
00057                 for(i = 0; i < NUM_SECTIONS; i++)
00058                         for(j = 0; j < NUM_CRITICALS; j++) {
00059                                 if(IsBomb((k = GetPartType(mech, i, j))))
00060                                         pile[k]++;
00061                                 else if(IsSpecial(k))
00062                                         if(Special2I(k) == FUELTANK)
00063                                                 pile[I2Special(FUELTANK)]++;
00064                         }
00065         /* We've 'so-called' pile now */
00066         for(i = 0; i < NUM_ITEMS; i++)
00067                 if(pile[i]) {
00068                         sw = GetPartWeight(i);
00069                         weight += sw * pile[i];
00070                 }
00071         if(FlyingT(mech)) {
00072                 AeroFuelMax(mech) =
00073                         AeroFuelOrig(mech) + 2000 * pile[I2Special(FUELTANK)];
00074                 if(AeroFuel(mech) > AeroFuelOrig(mech))
00075                         weight += AeroFuel(mech) - AeroFuelOrig(mech);
00076         }
00077         SetCarriedCargo(mech, weight);
00078 }


Generated on Mon May 28 04:25:40 2007 for BattletechMUX by  doxygen 1.4.7