unit PublicMBTypes; // VERSION 7.0 interface uses Classes,mAWAPI; const MBEVAL_VERSION = 3.0; // evaluation module error codes EVALERR_DIVBYZERO= -1; // divide by zero EVALERR_NEGDICE = -2; // negative number of dice EVALERR_ZERODIE = -3; // invalid die (0 or negative) EVALERR_NULLSTR = -4; // null string entered EVALERR_PARENS = -5; // mismatched parens EVALERR_END = -6; // unexpected end of expression EVALERR_UNKNOPER = -7; // unknown operator EVALERR_NONUM = -8; // number missing EVALERR_UNKNFUNC = -9; // unknown function name EVALERR_NOMANT = -10; // number has exponent with no mantissa EVALERR_NOEXP = -11; // exponent missing EVALERR_SQRT = -12; // square root calculation error EVALERR_PARMLOW = -13; // too few arguments to a function EVALERR_PARMHIGH = -14; // too many arguments to a function (right bracket expected) EVALERR_ARGS = -15; // too many arguments in user defined function EVALERR_PARM = -16; // invalid parm format in user function EVALERR_PARMNO = -17; // parm out of range in macro EVALERR_NOPAREN = -18; // parenthesis expected EVALERR_ZERONEGEXP = -19; // pow function domain error (x=0,y<0) EVALERR_ZEROPOW = -20; // pow function domain error (x=0,y=0) EVALERR_NEGNOINT = -21; // pow function domain error (x<0,y !int) EVALERR_OVERFLOW = -22; // pow function overflow error EVALERR_NOOPENUDF = -23; // error opening user func file EVALERR_FORMAT = -24; // invalid user func EVALERR_EXCEEDMAX = -25; // memory allocation error loading user funcs EVALERR_QUOTES = -26; // quotes expected EVALERR_COMMA = -27; // comma expected EVALERR_BRACKETS = -28; // mismatched brackets EVALERR_NOBRACKET = -29; // bracket expected EVALERR_INVALSTR = -30; // invalid string (can't be converted to a number) EVALERR_STRING = -31; // string given where number expected EVALERR_NOSTRING = -32; //string expected EVALERR_MAXVARIABLES = -33; // attempt to define too many variables EVALERR_VARNOTFOUND = -34; // variable name not found EVALERR_INVALVARNAME = -35; // attempted to define invalid variable name EVALERR_INVALTIMESTR = -36; // invalid string string given as argument EVALERR_INVALDATESTR = -37; // invalid date string given as argument EVALERR_ENDBEFORESTART = -38; // "end" can't be before "start" in $seg function EVALERR_MASK = -39; // invalid mask string EVALERR_INTSIZE = -40; // failed to convert short to long int EVALERR_ALREADYASSIGNED = -41; // variable name already assigned to function EVALERR_ALREADYUSERASSIGNED = -42; // variable name already assigned to user macro EVALERR_ARGUMENTS = -43; // couldn't allocate memory for user macro args EVALERR_NEGATIVEINDEX = -44; // negative number used to specify an index EVALERR_NEGATIVELEN = -45; // negative number used to specify a length EVALERR_STRTOOLARGE = -46; // string too large EVALERR_NOOPENVARLIST = -47; // can't open variable list file EVALERR_IO = -48; // I/O error EVALERR_CHARNOTFOUND = -49; // expected character not found EVALERR_FMT = -50; // $fmt function error EVALERR_LOOP = -51; // error in @loop EVALERR_HEX = -52; // invalid hexidecimal string EVALERR_VARNAME = -53; // function or variable name expected EVALERR_OPER = -54; // memory allocation failed creating TOperation EVALERR_INVALIDOP = -55; // invalid operation EVALERR_REPACK = -56; // repack failed (macro name not found) EVALERR_NILEXPR = -57; // nil expression EVALERR_NOMACROARGS = -58; // macro args missing EVALERR_NOASN = -59; // assignment operator expected EVALERR_FUNCNOTFOUND = -60; // func name not found EVALERR_POINTER = -61; // pointer error EVALERR_STRMEMORY = -62; // TEvalStrRet allocation error EVALERR_ZEROINDEX= -63; EVALERR_INVALIDSTRINDEX= -64; EVALERR_INVALIDASNNAME = -65; // invalid variable name in assignment EVALERR_NOUSERLIST = -66; // no user list found EVALERR_BADVLINDEX = -67; EVALERR_VLISTMEM = -68; EVALERR_SCANF = -69; EVALERR_PACKOPER = -70; // failed to allocate memory in PackOper EVALERR_ALLOCVAR = -71; // failed to allocate memory for numeric var EVALERR_ALLOCSTRVAR = -72; // failed to allocate memory for string var EVALERR_NOTIMPLEMENTED = -73; // function not implemented (for debugging) NUMERRORCODES = 73; // magsbot error codes (note some are unused due to changes in later versions) MBERR_SDK = -NUMERRORCODES-1; // sdk error MBERR_INVALIDACT = -NUMERRORCODES-2; // action name was not alphabetic MBERR_INVALIDEVENT = -NUMERRORCODES-3; // event name was not alphabetic MBERR_UNKNACT = -NUMERRORCODES-4; // didn't recognize action name MBERR_NOTPRESENT = -NUMERRORCODES-5; // avatar name not on nearby list MBERR_UNKNCHATTYPE = -NUMERRORCODES-6; // invalid chat type used in speak (internal error only) MBERR_INSTANCE = -NUMERRORCODES-7; // UNUSED! MBERR_LOCATION = -NUMERRORCODES-8; // UNUSED! MBERR_WORLD = -NUMERRORCODES-9; // UNUSED! MBERR_SENDCHAT = -NUMERRORCODES-10; // couldn't sendchat (sdk error) MBERR_FILEIO = -NUMERRORCODES-11; // file i/o error MBERR_TIMER = -NUMERRORCODES-12; // invalid timer # in start/stop timer MBERR_DLLFUNC = -NUMERRORCODES-13; // dll function not found MBERR_DLLFAILED = -NUMERRORCODES-14; // dll failed (system error) MBERR_EXE = -NUMERRORCODES-15; // executable failed to run (system error) MBERR_ALREADYEXISTS = -NUMERRORCODES-16; // UNUSED! MBERR_INVALIDROW = -NUMERRORCODES-17; // specified nonexistant beh table row (insert,add,del) MBERR_DLLLOAD = -NUMERRORCODES-18; // DLL failed to load (system error), startup MBERR_ADDR = -NUMERRORCODES-19; // address function (IP) failed MBERR_NOBUTTON = -NUMERRORCODES-20; // specified nonexisitent button MBERR_ADDBUTTON = -NUMERRORCODES-21; // couldn't add new button to action listview MBERR_UNKNATTR = -NUMERRORCODES-22; // AW attribute not found MBERR_NOCITIZENNAME= -NUMERRORCODES-23; MBERR_NOCITIZENNUM = -NUMERRORCODES-24; MBERR_BONE = -NUMERRORCODES-25; MBERR_AWINITFAILED = -NUMERRORCODES-26; MBERR_INVALIDINST = -NUMERRORCODES-27; MBERR_ALREADYCONNECTED = -NUMERRORCODES-28; MBERR_INACTIVEINST = -NUMERRORCODES-29; MBERR_NEWINSTFAILED = -NUMERRORCODES-30; // @newinstance failed MBERR_SETINSTFAILED = -NUMERRORCODES-31; MBERR_SURVEYING = -NUMERRORCODES-32; //tried to start a survey when already underway MBERR_NEARBYLIST = -NUMERRORCODES-33; // no nearby list for current instance! MBERR_INVALIDADDR = -NUMERRORCODES-34; // invalid IP address MBERR_THREAD = -NUMERRORCODES-35; // thread creation failed MBERR_RECORD = -NUMERRORCODES-36; // already recording MBERR_PLAYBACK = -NUMERRORCODES-37; MBERR_MEMORY = -NUMERRORCODES-38; // can't alloc new variable MBERR_QUEUE = -NUMERRORCODES-39; MBERR_VARIANT = -NUMERRORCODES-40; // error converting variant type MBERR_PROPDUMP = -NUMERRORCODES-41; // error reading propdump MBERR_PDFORMAT = -NUMERRORCODES-42; // wrong propdump format MBERR_INVALIDATTRINDEX = -NUMERRORCODES-43; MBERR_BADVARNAME = -NUMERRORCODES-44; MBERR_NOINDEX = -NUMERRORCODES-45; MBERR_READONLY = -NUMERRORCODES-46; // unused, formerly used in $worldattrib MBERR_WORLDATTRIB = -NUMERRORCODES-47; MBERR_CLIENT = -NUMERRORCODES-48; MBERR_CLIENTNOTFOUND = -NUMERRORCODES-49; MBERR_ACTQUEUE = -NUMERRORCODES-50; MBERR_SURVEYPARMS = -NUMERRORCODES-51; MBERR_SURVEYSTOP = -NUMERRORCODES-52; MBERR_QWAIT = -NUMERRORCODES-53; MBERR_INVALOBJLIST = -NUMERRORCODES-54; // invalid objnum in objlist MBERR_DATABASE = -NUMERRORCODES-55; MBERR_FLOODING = -NUMERRORCODES-56; MBERR_HOSTNAME = -NUMERRORCODES-57; MBERR_ADDCATEGORY = -NUMERRORCODES-58; MBERR_NOCATEGORY = -NUMERRORCODES-59; MBERR_EJECTTYPE = -NUMERRORCODES-60; MBERR_BADCATEGORYINDEX = -NUMERRORCODES-61; MBERR_BEHAVIOR = -NUMERRORCODES-62; // invalid behavior file (header missing) MBERR_BUTTONADDFAILED = -NUMERRORCODES-63; MBERR_BEHAVIORADDFAILED = -NUMERRORCODES-64; MBERR_INSTANCEINFO = -NUMERRORCODES-65; MBERR_QUERYINGTERRAIN = -NUMERRORCODES-66; MBERR_TERRAINPARMS = -NUMERRORCODES-67; MBERR_TERRAINQUERYSTOP = -NUMERRORCODES-68; MBERR_TERRAINFILE = -NUMERRORCODES-69; MBERR_NODATA = -NUMERRORCODES-70; // couldn't get terrain data from buffer MBERR_ARRAYINDEX = -NUMERRORCODES-71; // out of range in node data MBERR_BUFFERINDEX = -NUMERRORCODES-72; // out of range in terrain buffer MBERR_ABEXCEPTION = -NUMERRORCODES-73; // exception in action button MBERR_CREATEDIR = -NUMERRORCODES-74; // couldn't create folder MBERR_SETDIR = -NUMERRORCODES-75; // couldn't set directory folder MBERR_FILEDELETE = -NUMERRORCODES-76; // couldn't delete file MBERR_FILERENAME = -NUMERRORCODES-77; // couldn't rename file MBERR_ALLOCBUFFER = -NUMERRORCODES-78; // couldn't allocate terrain buffer MBERR_GETHTTP = -NUMERRORCODES-79; MBERR_SENDHTTP = -NUMERRORCODES-80; MBERR_SERVER = -NUMERRORCODES-81; // server failed to start MBERR_INVALIDQ = -NUMERRORCODES-82; MBERR_SERVERSEND = -NUMERRORCODES-83; // server failed to send MBERR_AVTRACKING = -NUMERRORCODES-84; MBERR_BADBOUNDSLIST = -NUMERRORCODES-85; MBERR_TERRAINBUFFER = -NUMERRORCODES-86; MBERR_ZONEINFO = -NUMERRORCODES-87; MBERR_FTPTYPE = -NUMERRORCODES-88; MBERR_BADTHREADINDEX = -NUMERRORCODES-89; MBERR_WINMSG = -NUMERRORCODES-90; MBERR_PLAYSOUND = -NUMERRORCODES-91; MBERR_OLVERSION = -NUMERRORCODES-92; MBERR_PDVERSION = -NUMERRORCODES-93; MBERR_POSTHTTP = -NUMERRORCODES-94; MBERR_SETOBJDATA = -NUMERRORCODES-95; // failed to allocate objdata vlist MBERR_FREEMEM = -NUMERRORCODES-96; MBERR_MEMBLOCK = -NUMERRORCODES-97; // failed to allocate object data memblock record MBERR_OBJDATA = -NUMERRORCODES-98; // failed to allocate object data MBERR_NOOBJDATA = -NUMERRORCODES-99; // datastr not given in @objectadd, etc. MBERR_TERRAINBUFSET = -NUMERRORCODES-100; MBERR_TERRAINSET = -NUMERRORCODES-101; MBERR_NOMEMBLOCK = -NUMERRORCODES-102; MBERR_FREEOBJDATA = -NUMERRORCODES-103; MBERR_NUMERRORCODES = 103; MAXTTOKENLEN = 4; MAXEVALSTR = 1024; MAXVARNAME = 100; // argument types for functions atUndefined=#0; atNumeric='@'; atString='$'; atOptionNum='n'; // optional numeric argument (must follow any mandatory arguments) atOptionString='s'; // optional string argument (must follow any mandatory arguments) atVarName='v'; atGlobalVarName='g'; atProcName='p'; atBracket='|'; atOptionAny='a'; atExpression='e'; atConditional='?'; // numeric, and suspend error report for next arg if false, // suspend error for arg after next if true //////////////////////////////////////////////////////////////////////////////// // (from AWActions.pas) MILLISECOND = 0.0000000115741; // 1 ms in terms of Delphi's "Time" function // endcode tells how the action sequence ended. // endcode is initialized to INCOMPLETE before processing the action; // if endcode is still INCOMPLETE after the entire sequence ends, then // there was an error. if endcode is DONE then the sequence ended successfully; // if endcode is BREAK then the sequence ended due to a BREAK action. ENDCODE_INCOMPLETE = -1; ENDCODE_DONE = 0; ENDCODE_BREAK = 1; //////////////////////////////////////////////////////////////////////////////// type TDLLEvent = record iEventType: integer; LocalVarList: TList; AWAttrList: TList; end; TToken = record sz: array [0..MAXTTOKENLEN] of Char; ch:Char; len: integer; end; PDouble = ^double; PInteger = ^integer; TEvalStrRet = array of char; // NOTE: when convert to string, convert to PChar first // to avoid having null terminator #0 added to string TEvalVarName = array [0..MAXVARNAME+1] of Char; PEvalVarName = ^TEvalVarName; TGetUserProcPtrFunc = function (sName: string; var pPtr: Pointer; pp: Pointer): integer; TErrDlgFunc = procedure (s: string; HelpCtx: LongInt); TUserList = record sName: string; VarList: TList; end; PUserList = ^TUserList; TVariable = record sName: string; vValue: variant; end; PVar = ^TVariable; TDefFuncRec=record f: Pointer; // function (or packed expr if packed macro def) s: string; // name t: string; // arg types, e.g. '@$$' etc end; PDefFuncRec = ^TDefFuncRec; TNumEvalFunc = function(var EvalVarList: TList; avArgs: Pointer; var vRet: variant): integer; PNumEvalFunc = ^TNumEvalFunc; TStrEvalFunc = function(var EvalVarList: TList; avArgs: Pointer; var sz: TEvalStrRet): integer; PStrEvalFunc = ^TStrEvalFunc; TExprPtr = Pointer; TMemBlock = record pch: PChar; L: integer; end; PMemBlock = ^TMemBlock; TPointerType = ( p_nil, p_func, p_macro, p_arg, p_var, p_oper, p_vname, p_gvname, p_proc ); // the difference between p_var and p_vname is how they are evaluated; // a p_var expression returns the value of the variable, // a p_vname expression returns a pointer to the variable //////////////////////////////////////////////////////////////////////////////// // (from AWActions.pas) TActFlags=record ahInstance: AWhInst; iEndCode,iSource,iPage: integer; bDefer: boolean; bQBreak: boolean; iQueue: integer; // indicates queue used for this action sequence bEcho,bEndCheck,bContCheck,bEndOnReact,bCheck: boolean; end; TAWAction = class(TObject) aArgs: TList; sKeyWord: string; NextAct: TAWAction; sArgTypes: string; iExecuting: integer; function ReadArgs(var psz: PChar): integer; virtual; function Arg(i: integer): string; function ActToStr: string; virtual; function Repack: integer; virtual; function ActDup: TAWAction; virtual; procedure DoAction(var EvalVarList: TList; var ActFlags: TActFlags); virtual; constructor Create; destructor Destroy; override; end; TAWActionType = class of TAWAction; TActRec = record t: TAWActionType; s: string; a: string; end; //////////////////////////////////////////////////////////////////////////////// // AvTracking TAvTrack=record sName: string; iSession, iAvX,iAvY,iAvZ,iAvYaw,iAvPitch,iAvState, iAvType,iAvGesture: integer; sAvZone: string; end; PAvTrack=^TAvTrack; TZone=record sName,sGroup: string; N,S,W,E,B,T: integer; bVertical: boolean; bActive: boolean; iPriority: integer; end; PZone = ^TZone; //////////////////////////////////////////////////////////////////////////////////////// // In AWActions // (these are the default methods for the TAWAction type, but put into // functions that could be exported to your DLL. in this way, if the // default methods change in future versions of Magsbot, your DLL will // still work without having to be updated.) function TAWAct_ReadArgs(var Act: TAWAction; var psz: PChar): integer; external 'MBot.exe'; function TAWAct_Arg(var Act: TAWAction; i: integer): string; external 'MBot.exe'; function TAWAct_ActToStr(var Act: TAWAction): string; external 'MBot.exe'; function TAWAct_Repack(var Act: TAWAction): integer; external 'MBot.exe'; function TAWAct_ActDup(var Act: TAWAction): TAWAction; external 'MBot.exe'; procedure TAWAct_DoAction(var Act: TAWAction; var EvalVarList: TList; var ActFlags: TActFlags); external 'MBot.exe'; procedure TAWAct_Create(var Act: TAWAction); external 'MBot.exe'; procedure TAWAct_Destroy(var Act: TAWAction); external 'MBot.exe'; ///////////////////////////////////////////////////////////////////// // from Misc type CellInfo = RECORD pz,px,cz,cx,dz,dx,cellz,cellx,y0: integer; end; implementation ///////////////////////////////////////////////////////////////////// // from AWActions function TAWAction.ReadArgs(var psz: PChar): integer; begin Result:=TAWAct_ReadArgs(Self,psz); end; function TAWAction.Arg(i: integer): string; begin Result:=TAWAct_Arg(Self,i); end; function TAWAction.ActToStr: string; begin Result:=TAWAct_ActToStr(Self); end; function TAWAction.Repack: integer; begin Result:=TAWAct_Repack(Self); end; function TAWAction.ActDup: TAWAction; begin Result:=TAWAct_ActDup(Self); end; procedure TAWAction.DoAction(var EvalVarList: TList; var ActFlags: TActFlags); begin TAWAct_DoAction(Self,EvalVarList,ActFlags); end; constructor TAWAction.Create; begin inherited Create; TAWAct_Create(Self); end; destructor TAWAction.Destroy; begin TAWAct_Destroy(Self); inherited Destroy; end; end.