00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef MACROS_H
00016 #define MACROS_H
00017
00018 #ifdef notify
00019 #undef notify
00020 #endif
00021 #ifdef notify_except
00022 #undef notify_except
00023 #endif
00024 #define notify(a,b) mecha_notify(a,b)
00025 #define notify_except(a,b,c,d) mecha_notify_except(a,b,c,d)
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef DOCHECK
00039 #define DOCHECK(a,b) if (a) { notify(player, b); return; }
00040 #define DOCHECKMA(a,b) if (a) { mech_notify(mech, MECHALL, b); return; }
00041 #define DOCHECKMA0(a,b) if (a) { mech_notify(mech, MECHALL, b); return 0; }
00042 #define DOCHECKMP(a,b) if (a) { mech_notify(mech, MECHPILOT, b); return; }
00043 #define DOCHECKMP0(a,b) if (a) { mech_notify(mech, MECHPILOT, b); return 0; }
00044 #define DOCHECKMP1(a,b) if (a) { mech_notify(mech, MECHPILOT, b); return 1; }
00045 #define DOCHECK0(a,b) if (a) { notify(player, b); return 0; }
00046 #define DOCHECK1(a,b) if (a) { notify(player, b); return -1; }
00047 #define DOCHECKN(a,b) if (a) { notify(player, b); return NULL; }
00048 #define FUNCHECK(a,b) \
00049 if (a) { safe_tprintf_str(buff, bufc, b); return; }
00050 #endif
00051
00052
00053
00054
00055
00056
00057 #define Number(a,b) ((a) + (random() >> ( \
00058 ((b) - (a)) > 16777216 ? 0 : \
00059 ((b) - (a)) > 65536 ? 8 : \
00060 ((b) - (a)) > 4096 ? 16 : 20 \
00061 )) % ((b)-(a)+1))
00062
00063 #define skipws(name) while (name && *name && isspace(*name)) name++
00064 #define readint(to,from) \
00065 (!from || !*from || (!(to = atoi(from)) && strcmp(from, "0")))
00066
00067 #define Readnum(tovar,fromvar) \
00068 (!(tovar = atoi(fromvar)) && strcmp(fromvar, "0"))
00069
00070 #define SetBit(val,bit) (val |= bit)
00071 #define UnSetBit(val,bit) (val &= ~(bit))
00072 #define EvalBit(val,bit,state) \
00073 do {if (state) SetBit(val,bit); else UnSetBit(val,bit);} while (0)
00074 #define ToggleBit(val,bit) \
00075 do { if (!(val & bit)) SetBit(val,bit);else UnSetBit(val,bit); } while (0)
00076
00077 #define WizPo(p,fun) (fun(Owner(p)) && Inherits(p))
00078
00079 #define Wiz(p) WizPo(p,Wizard)
00080 #define WizR(p) WizPo(p,WizRoy)
00081 #define WizP(p) WizPo(p,Security)
00082
00083 #define hush_teleport(p,t) move_via_teleport(p,t,1,7)
00084 #define loud_teleport(p,t) move_via_teleport(p,t,1,0)
00085
00086 #if 0
00087
00088 #define ValidLuckPlayer(mech) ((In_Character(mech->mynum) && In_Character(Location(mech->mynum))) ? MechPilot(mech) : -1)
00089 #define NRoll(mech) luck_die_mod(ValidLuckPlayer(mech), -1)
00090 #define PRoll(mech) luck_die_mod(ValidLuckPlayer(mech), 1)
00091
00092 #define NRoll2(mech,mech2) \
00093 ((!mech2 || mech == mech2) ? NRoll(mech) : luck_die_mod_base(-1, player_luck(ValidLuckPlayer(mech)) - player_luck(ValidLuckPlayer(mech2))))
00094
00095 #define PRoll2(mech,mech2) \
00096 ((!mech2 || mech == mech2) ? PRoll(mech) : luck_die_mod_base(1, player_luck(ValidLuckPlayer(mech)) - player_luck(ValidLuckPlayer(mech2))))
00097
00098
00099 #define NPRoll(player) \
00100 luck_die_mod_base(-1, player_luck(player))
00101 #endif
00102
00103 #define can_pass_lock(guy,lockobj,lockname) could_doit(guy,lockobj,lockname)
00104
00105
00106 #endif