diff --git a/edit.bat b/edit.bat index 2bac241..749e473 100644 --- a/edit.bat +++ b/edit.bat @@ -1,5 +1,2 @@ start src/Stickman.dpr start src/typestuff.pas -start src/multiplayer.pas -start src/fegyverek.pas -start src/fizika.pas diff --git a/src/BotGroups.pas b/src/BotGroups.pas index 505cf21..92b25e8 100644 --- a/src/BotGroups.pas +++ b/src/BotGroups.pas @@ -97,7 +97,7 @@ TBot = class // procedure doLogic; procedure passInfo(_playerHalott: boolean; _playerFegyv: Byte; _playerPos: TD3DXVector3; _playerMatWorld: TD3DXMatrix; _bots: array of TBot); - procedure collideProjectile(loves: TLoves); + function collideProjectile(loves: TLoves): boolean; //returns true when shot by player end; TBotArray = array of TBot; @@ -624,12 +624,14 @@ procedure TBot.shootPoint(_pos: TD3DXVector3); state.canShootCd := ownProps.baseLovesCooldown; end; -procedure TBot.collideProjectile(loves: TLoves); +function TBot.collideProjectile(loves: TLoves): boolean; var isGun, amGun, isHit: boolean; matWorld, matWorld2 :TD3DMatrix; muks: TMuksoka; begin + result := FALSE; + if state.isDead > -1 then exit; if state.isInvul > -1 then exit; @@ -664,6 +666,7 @@ procedure TBot.collideProjectile(loves: TLoves); putRagdoll(state.pos, loves.pos); if loves.kilotte <> -2 then begin + result := TRUE; _addHudMessage(lang[110], $FF0000); hudMessages[low(hudMessages)].fade:=200; end; diff --git a/src/Defines.inc b/src/Defines.inc new file mode 100644 index 0000000..1ecdd14 --- /dev/null +++ b/src/Defines.inc @@ -0,0 +1,2 @@ +{.$DEFINE undebug} //Remove dot for release, add dot for dev +{.$DEFINE nochecksumcheck} \ No newline at end of file diff --git a/src/DynamicArray.pas b/src/DynamicArray.pas new file mode 100644 index 0000000..7a81ca1 --- /dev/null +++ b/src/DynamicArray.pas @@ -0,0 +1,247 @@ +unit DynamicArray; + +interface + uses + SysUtils, + Variants, + // + Typestuff; + + type TVariantArray = array of Variant; + + type TDynamicArray = class (TObject) + private + _items: TVariantArray; + _isFrozen: boolean; + _isPermaFrozen: boolean; + procedure init; + public + constructor Create(); overload; + constructor Create(items: TVariantArray); overload; + // + function push(item: Variant): Integer; //index + function pop: Variant; + function items: TVariantArray; + function at(index: Integer): Variant; + function head: Variant; + function tail: TVariantArray; + function size: Integer; + function isEmpty: boolean; + function isFrozen: boolean; + function isPermaFrozen: boolean; + function find(comparator: TComparatorFunction): Variant; + function findIndex(comparator: TComparatorFunction): Integer; + function difference(other: TDynamicArray): TDynamicArray; + procedure clear; + procedure map(mutator: TMutatorFunction); + procedure merge(other: TDynamicArray); + procedure freeze(isPermanent: boolean = false); + procedure unFreeze; + function toJSON(): string; + end; + +implementation + +procedure TDynamicArray.init; +begin + setlength(_items, 0); + _isFrozen := false; + _isPermaFrozen := false; +end; + +constructor TDynamicArray.Create; +begin + inherited Create; + + init; +end; + +constructor TDynamicArray.Create(items: TVariantArray); +begin + inherited Create; + + init; + + setlength(_items, length(items)); + _items := copy(items, low(items), length(items)); +end; + +function TDynamicArray.push(item: Variant): Integer; //index +begin + result := -1; + + if _isFrozen or _isPermaFrozen then exit; + + setlength(_items, succ(length(_items))); + _items[high(_items)] := item; + + result := high(_items); +end; + +function TDynamicArray.pop: Variant; +begin + result := Null; + + if _isFrozen or _isPermaFrozen then exit; + + if length(_items) <= 0 then exit; + + result := _items[high(_items)]; + setlength(_items, pred(length(_items))); +end; + +function TDynamicArray.items: TVariantArray; +begin + result := _items; +end; + +function TDynamicArray.at(index: Integer): Variant; +begin + result := Null; + + if length(_items) <= 0 then exit; + if index >= length(_items) then exit; + if index <= 0 then exit; + + result := _items[index]; +end; + +function TDynamicArray.head: Variant; +begin + result := Null; + + if length(_items) <= 0 then exit; + + result := _items[low(_items)]; +end; + +function TDynamicArray.tail: TVariantArray; +begin + setlength(result, 0); + + if length(_items) <= 1 then exit; + + result := copy(_items, 1, length(_items) - 1); +end; + +function TDynamicArray.size: Integer; +begin + result := length(_items); +end; + +function TDynamicArray.isEmpty: boolean; +begin + result := length(_items) <= 0; +end; + +function TDynamicArray.isFrozen: boolean; +begin + result := _isFrozen = true; +end; + +function TDynamicArray.isPermaFrozen: boolean; +begin + result := _isPermaFrozen = true; +end; + +function TDynamicArray.find(comparator: TComparatorFunction): Variant; +var + i: Integer; +begin + result := Null; + + if length(_items) <= 1 then exit; + + for i := low(_items) to high(_items) do + begin + if comparator(_items[i], intToStr(i)) then + begin + result := _items[i]; + exit; + end; + end; + +end; + +function TDynamicArray.findIndex(comparator: TComparatorFunction): Integer; +var + i: Integer; +begin + result := -1; + + if length(_items) > 1 then + for i := low(_items) to high(_items) do + begin + if comparator(_items[i], intToStr(i)) then + begin + result := i; + exit; + end; + end; + +end; + +function TDynamicArray.difference(other: TDynamicArray): TDynamicArray; +begin + result := TDynamicArray.Create; + + if length(_items) <= 1 then exit; + + //TODO: return items in self but not in other +end; + +procedure TDynamicArray.clear; +begin + if _isFrozen or _isPermaFrozen then exit; + + setlength(_items, 0); +end; + +procedure TDynamicArray.map(mutator: TMutatorFunction); +var + i: Integer; +begin + if _isFrozen or _isPermaFrozen then exit; + + for i := low(_items) to high(_items) do + _items[i] := mutator(_items[i], intToStr(i)); + +end; + +procedure TDynamicArray.merge(other: TDynamicArray); +begin + if _isFrozen or _isPermaFrozen then exit; + + //TODO: append items to end +end; + +procedure TDynamicArray.freeze(isPermanent: boolean = false); +begin + _isFrozen := true; + _isPermaFrozen := _isPermaFrozen or isPermanent; +end; + +procedure TDynamicArray.unFreeze; +begin + if _isPermaFrozen then exit; + + _isFrozen := false; +end; + +function TDynamicArray.toJSON(): string; +var + i: Integer; +begin + result := '['; + + for i := low(_items) to high(_items) do + begin + if i > low(_items) then result := result + ', '; + + result := result + variantToStr(_items[i]); + end; + + result := result + ']'; +end; + +end. diff --git a/src/MutableObject.pas b/src/MutableObject.pas new file mode 100644 index 0000000..380c0e8 --- /dev/null +++ b/src/MutableObject.pas @@ -0,0 +1,319 @@ +unit MutableObject; + +interface + + uses Typestuff, SysUtils, Variants; + + type TKeyValuePair = record + key: string; + value: Variant; + end; + + //TODO: TImmutableObject + + type TMutableObject = class (TObject) + private + __values: array of TKeyValuePair; + __isFrozen: boolean; + __isPermaFrozen: boolean; + public + function assign(key: string; value: Variant; strict: boolean = false): Variant; + function unset(key: string; strict: boolean = false): Variant; + function get(key: string; strict: boolean = false): Variant; + function size(): Cardinal; + function has(value: Variant): boolean; overload; + function has(key: string): boolean; overload; + function keys(): TStringArray; + function find(comparator: TComparatorFunction): Variant; + function findKey(comparator: TComparatorFunction): string; + function isEmpty(): boolean; + function isFrozen(): boolean; + function isPermaFrozen(): boolean; + function difference(other: TMutableObject): TMutableObject; + procedure clear(); + procedure freeze(isPermanent: boolean = false); + procedure unFreeze(); + procedure merge(other: TMutableObject); overload; + procedure merge(others: array of TMutableObject); overload; + function toJSON: string; + constructor Create(freeze: boolean = false); + end; + +implementation + +constructor TMutableObject.Create(freeze: boolean = false); +begin + inherited Create(); + + setlength(__values, 0); + __isFrozen := freeze; +end; + +function TMutableObject.size(): Cardinal; +begin + result := length(__values); +end; + +function TMutableObject.isEmpty(): boolean; +begin + result := size() = 0; +end; + +function TMutableObject.isFrozen(): boolean; +begin + result := __isFrozen = true; +end; + +function TMutableObject.isPermaFrozen(): boolean; +begin + result := __isPermaFrozen = true; +end; + +function TMutableObject.find(comparator: TComparatorFunction): Variant; +var + i: Integer; +begin + result := Null; + + for i := 0 to high(__values) do + begin + if comparator(__values[i].value, __values[i].key) then + begin + result := __values[i].value; + exit; + end; + end; +end; + +function TMutableObject.findKey(comparator: TComparatorFunction): string; +var + i: Integer; +begin + result := Null; + + for i := 0 to high(__values) do + begin + if comparator(__values[i].value, __values[i].key) then + begin + result := __values[i].key; + exit; + end; + end; +end; + +function TMutableObject.has(value: Variant): boolean; +var + i: Integer; +begin + result := false; + + for i := 0 to high(__values) do + begin + if __values[i].value = value then + begin + result := true; + exit; + end; + end; +end; + +function TMutableObject.has(key: string): boolean; +var + i: Integer; +begin + result := false; + + for i := 0 to high(__values) do + begin + if __values[i].key = key then + begin + result := true; + exit; + end; + end; +end; + +function TMutableObject.assign(key: string; value: Variant; strict: boolean = false): Variant; +var + i: Integer; + newPair: TKeyValuePair; +begin + result := Null; + + if isFrozen() then exit; + + if not has(key) then + begin + if strict then + raise Exception.Create('Invalid key: ' + key); + + newPair.key := key; + newPair.value := value; + + setlength(__values, size() + 1); + __values[high(__values)] := newPair; + + exit; + end; + + for i := 0 to high(__values) do + begin + if __values[i].key = key then + begin + __values[i].value := value; + exit; + end; + end; + +end; + +function TMutableObject.unset(key: string; strict: boolean = false): Variant; +var + i: Integer; + found: boolean; +begin + result := Null; + + if isFrozen() then exit; + + if not has(key) then + begin + if strict then + raise Exception.Create('Invalid key: ' + key); + + exit; + end; + + found := false; + for i := 0 to high(__values) do + begin + if __values[i].key = key then + begin + if found then + begin + if i = high(__values) then + break; + + __values[i] := __values[i + 1]; + end + else + begin + found := __values[i].key = key; + end; + end; + end; + + setlength(__values, size() - 1); + +end; + +function TMutableObject.get(key: string; strict: boolean = false): Variant; +var + i: Integer; +begin + result := Null; + + if not has(key) then + begin + if strict then + raise Exception.Create('Invalid key: ' + key); + + exit; + end; + + for i := 0 to high(__values) do + begin + if __values[i].key = key then + begin + result := __values[i].value; + exit; + end; + end; +end; + +function TMutableObject.keys(): TStringArray; +var + i: Integer; +begin + setlength(result, 0); + + for i := 0 to high(__values) do + begin + setlength(result, length(result) + 1); + result[high(result)] := __values[i].key; + end; +end; + +//TODO: make overloaded version with others: array of TMutableObject +function TMutableObject.difference(other: TMutableObject): TMutableObject; +begin + result := TMutableObject.Create(); + + //TODO: return new TMutableObject with keys in self but not it other +end; + +procedure TMutableObject.clear(); +begin + if isFrozen() then exit; + setlength(__values, 0); +end; + +procedure TMutableObject.freeze(isPermanent: boolean = false); +begin + __isFrozen := true; + __isPermaFrozen := __isPermaFrozen or isPermanent; +end; + +procedure TMutableObject.unFreeze(); +begin + if isPermaFrozen() then exit; + + __isFrozen := false; +end; + +procedure TMutableObject.merge(other: TMutableObject); +var + i: Integer; +begin + for i := 0 to high(other.keys()) do + begin + if not has(other.keys()[i]) then + begin + assign(other.keys()[i], other.get(other.keys()[i])); + end; + end; +end; + +procedure TMutableObject.merge(others: array of TMutableObject); +var + i: Integer; +begin + for i := 0 to high(others) do merge(others[i]); +end; + +function TMutableObject.toJSON: string; +var + i: Integer; + isString: boolean; +begin + result := '{'; + + for i := 0 to high(__values) do + begin + if i > 0 then result := result + ', '; + + isString := varType(__values[i].value) = varString; + + result := result + '"' + __values[i].key + '": '; + + if isString then result := result + '"'; + result := result + variantToStr(__values[i].value); + if isString then result := result + '"'; + end; + + result := result + '}'; +end; + +end. + + diff --git a/src/Redux.pas b/src/Redux.pas new file mode 100644 index 0000000..af0269d --- /dev/null +++ b/src/Redux.pas @@ -0,0 +1,80 @@ +unit Redux; + +interface + + uses Typestuff, MutableObject; + + type + + TActionType = string; + + TAction = record + key: TActionType; + payload: TMutableObject; + end; + + // TActionCreator = function(value: TMutableObject): TAction; + + TState = TMutableObject; + + TReducer = function(state: TState; action: TAction): TState; + + //TSubscribe = procedure(callback: TProcedure); + + //TDispatch = procedure(action: TAction); + + //TGetState = function: TState; + + TStore = class + private + __state: TState; + __reducer: TReducer; + __listeners: TCallbackArray; + public + function getState(): TState; + procedure subscribe(callback: TCallback); + procedure dispatch(action: TAction); reintroduce; + constructor Create(initialState: TState; reducer: TReducer); + end; + + //TODO: function makeCombinedStore(stores: array of stores): TStore; + +var + appStore: TStore; + +implementation + +constructor TStore.Create(initialState: TState; reducer: TReducer); +begin + inherited Create; + + __state := initialState; + __reducer := reducer; +end; + +function TStore.getState(): TState; +begin + result := __state; +end; + +procedure TStore.subscribe(callback: TCallback); +begin + setlength(__listeners, length(__listeners) + 1); + __listeners[high(__listeners)] := callback; +end; + +procedure TStore.dispatch(action: TAction); +var + i: Integer; +begin + __reducer(getState(), action); + + //TODO: optimize with key<->listener dict + for i := 0 to high(__listeners) do + begin + __listeners[i](); + end; +end; + +end. + diff --git a/src/Scripts.pas b/src/Scripts.pas new file mode 100644 index 0000000..80701e4 --- /dev/null +++ b/src/Scripts.pas @@ -0,0 +1,1636 @@ +unit Scripts; + +interface + +uses + D3DX9, + SysUtils, + Windows, + MMSystem, + // + IdHTTP, + IdMultipartFormData, + // + Typestuff, + Multiplayer, + Props, + newsoundunit, + qjson; + +type + TScriptsHandler = class; + + TScript = record + name: string; + instructions: TStringArray; + end; + + T3dLabel = record + pos: TD3DXVector3; + rad: single; + text: string; + end; + + TVecVar = record + pos: TD3DXVector3; + name: string; + end; + + TNumVar = record + num: single; + name: string; + end; + + TStrVar = record + text: string; + name: string; + end; + + TBind = record + key: char; + script: string; + end; + + TTimedscript = record + time: cardinal; + script: string; + end; + + TScriptArray = array of TScript; + TBindArray = array of TBind; + TTimedscriptArray = array of TTimedscript; + TVecVarArray = array of TVecVar; + TNumVarArray = array of TNumVar; + TStrVarArray = array of TStrVar; + + TCommand = string; + TCommandHandler = function(args: TStringArray; out handler: TScriptsHandler): boolean; + TCommandHandlerArray = array of TCommandHandler; + + TArgsParserResult = record + args: TStringArray; + handled: boolean; + end; + + TScriptsHandler = class (TObject) + private + _scripts: TScriptArray; + _timedscripts: TTimedscriptArray; + _commandHandlers: TCommandHandlerArray; + // + _vecVars: TVecVarArray; + _numVars: TNumVarArray; + _strVars: TStrVarArray; + // + _actualscript: string; + _actualscriptline: integer; + _scriptdepth: integer; + _scriptevaling: array[0..50] of boolean; + public + _binds: TBindArray; //TODO: make private (waiting for more unit refacts) + published + constructor Create(config: TQJSON); + procedure handletimedscripts; + // + function explodeLine(line: string; args: TStringArray): TStringArray; + function parseGlobals(args: TStringArray): TArgsParserResult; + function parseControls(args: TStringArray): TArgsParserResult; + function parseAssignments(args: TStringArray): TArgsParserResult; + function parseDeclarations(args: TStringArray): TArgsParserResult; + function parseCommands(args: TStringArray; line: string): TArgsParserResult; + // + function compute(words: TStringArray): TSingleArray; + function computeVecs(words: TStringArray): TD3DXVector3; + function computeNums(words: TStringArray): single; + function getVecVar(name: string): TD3DXVector3; + function getNumVar(name: string): single; + procedure varCompare(args: TStringArray); + // + function varToString(input: string): string; + procedure scripterror(text: string); + procedure evalScript(name: string); + procedure evalScriptLine(line: string); + end; + +var + scriptsHandler: TScriptsHandler; + + +implementation + +function getLangCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function bindCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function unbindCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function unbindAllCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function triggerEnableCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function triggerDisableCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function fastinfoCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function fastinfoRedCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function printCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function chatmostCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function displayCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function closedisplayCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function scriptCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function timeoutCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function particleStopCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function particleStartCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function particlePositionCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function propHideCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function propShowCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function dynamizateCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function dynamicSpeedCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function propPositionCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function propRotationCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function botWaveCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function botSkirmishCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function botStartBattleCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function botStopBattleCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function explodeCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +//function respawnCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function soundCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +function fegyvskinCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; +//function watercraftCMD(args: TStringArray; out handler: TScriptsHandler): boolean; forward; + + + +constructor TScriptsHandler.Create(config: TQJSON); +var + n, m, i, j: Integer; +begin + //init arrays + setlength(_scripts, 0); + setlength(_binds, 0); + setlength(_timedscripts, 0); + setlength(_vecVars, 0); + setlength(_numVars, 0); + setlength(_strVars, 0); + setlength(_commandHandlers, 0); + + //parse JSON + n := config.GetNum(['scripts']); + setlength(_scripts, n); + for i := 0 to n - 1 do + with _scripts[i] do + begin + m := config.GetNum(['scripts', i]); + setlength(instructions, m); + name := config.GetKey(['scripts'], i); + + for j := 0 to m - 1 do + instructions[j] := config.GetString(['scripts', i, j]); + end; + + //TODO: niceify + setlength(_commandHandlers, 30); + _commandHandlers[0] := getLangCMD; + _commandHandlers[1] := bindCMD; + _commandHandlers[2] := unbindCMD; + _commandHandlers[3] := unbindAllCMD; + _commandHandlers[4] := triggerEnableCMD; + _commandHandlers[5] := triggerDisableCMD; + _commandHandlers[6] := fastinfoCMD; + _commandHandlers[7] := fastinfoRedCMD; + _commandHandlers[8] := printCMD; + _commandHandlers[9] := chatmostCMD; + _commandHandlers[10] := displayCMD; + _commandHandlers[11] := closedisplayCMD; + _commandHandlers[12] := scriptCMD; + _commandHandlers[13] := timeoutCMD; + _commandHandlers[14] := particleStopCMD; + _commandHandlers[15] := particleStartCMD; + _commandHandlers[16] := particlePositionCMD; + _commandHandlers[17] := propHideCMD; + _commandHandlers[18] := propShowCMD; + _commandHandlers[19] := dynamizateCMD; + _commandHandlers[20] := dynamicSpeedCMD; + _commandHandlers[21] := propPositionCMD; + _commandHandlers[22] := propRotationCMD; + _commandHandlers[23] := botWaveCMD; + _commandHandlers[24] := botSkirmishCMD; + _commandHandlers[25] := botStartBattleCMD; + _commandHandlers[26] := botStopBattleCMD; + _commandHandlers[27] := explodeCMD; + _commandHandlers[28] := soundCMD; + _commandHandlers[29] := fegyvskinCMD; + + _scriptdepth := 0; +end; + +procedure TScriptsHandler.scripterror(text: string); +begin + writeln(logfile, text, ' in ', _actualscript, ' : ', _actualscriptline); +end; + +procedure TScriptsHandler.handletimedscripts; +var + i, j, n:integer; + now:cardinal; +begin + n:=length(_timedscripts); + now:=GetTickCount; + + for i:=0 to n - 1 do + begin + if _timedscripts[i].time < now then + begin + evalscript(_timedscripts[i].script); + end; + end; + + for i:=0 to length(_timedscripts) - 1 do + begin + if _timedscripts[i].time < now then + begin + for j:=i to length(_timedscripts) - 2 do + _timedscripts[j]:=_timedscripts[j + 1]; + SetLength(_timedscripts, length(_timedscripts) - 1); + end; + end; +end; + +function TScriptsHandler.varToString(input: string): string; +var + i, n:integer; + varname:string; +begin + result:=input; + if length(input) < 2 then exit; + if input[1] = '%' then + begin + varname:=copy(input, 2, length(input) - 1); + n:=Length(_numVars); + for i:=0 to n - 1 do + if _numVars[i].name = varname then + begin + result:=FormatFloat('0.####', _numVars[i].num); + exit; + end; + end + else + if input[1] = '!' then + begin + varname:=copy(input, 2, length(input) - 1); + n:=Length(_vecVars); + for i:=0 to n - 1 do + if _vecVars[i].name = varname then + begin + result:=FloatToStr(_vecVars[i].pos.x) + ', ' + FloatToStr(_vecVars[i].pos.y) + ', ' + FloatToStr(_vecVars[i].pos.z); + exit; + end; + end + else + if input[1] = '$' then + begin + if input = '$_' then begin result:= ' ';exit; end; + if input = '$NL' then begin result:=AnsiString(#13#10);exit; end; + varname:=copy(input, 2, length(input) - 1); + n:=Length(_strVars); + for i:=0 to n - 1 do + if _strVars[i].name = varname then + begin + result:=_strVars[i].text; + exit; + end; + end; +end; + +function TScriptsHandler.explodeLine(line: string; args: TStringArray): TStringArray; +var + i, j, len: integer; +begin + result := args; + + len:=Length(line); + j:=0; + SetLength(result, 1); + + for i:=1 to len do begin + if (line[i] = ' ') then + begin + if ((Length(result[j]) > 0)) then + begin + inc(j); + SetLength(result, j + 1); + end; + end + else + begin + result[j]:=result[j] + line[i]; + end; + end; +end; + +function TScriptsHandler.parseGlobals(args: TStringArray): TArgsParserResult; +var + i, j, argnum: integer; +begin + result.args := args; + result.handled := false; + + argnum := length(result.args); + + for i:=1 to high(result.args) do + begin + if result.args[i] = '!playerpos' then + begin + result.handled := true; + setLength(result.args, Length(result.args) + 2); + argnum:=argnum + 2; + for j:=argnum - 1 downto i + 1 do + begin + result.args[j]:=result.args[j - 2]; + result.args[i]:=FloatToStr(cpx^); + result.args[i + 1]:=FloatToStr(cpy^); + result.args[i + 2]:=FloatToStr(cpz^); + end; + + continue; + end; + + if result.args[i] = '$weapon' then + begin + result.handled := true; + case myfegyv of + FEGYV_MPG:result.args[i] := 'FEGYV_MPG'; + FEGYV_M82A1:result.args[i] := 'FEGYV_M82A1'; + FEGYV_M4A1:result.args[i] := 'FEGYV_M4A1'; + FEGYV_QUAD:result.args[i] := 'FEGYV_QUAD'; + FEGYV_NOOB:result.args[i] := 'FEGYV_NOOB'; + FEGYV_LAW:result.args[i] := 'FEGYV_LAW'; + FEGYV_X72:result.args[i] := 'FEGYV_X72'; + FEGYV_MP5A3:result.args[i] := 'FEGYV_MP5A3'; + FEGYV_H31_T:result.args[i] := 'FEGYV_H31_T'; + FEGYV_H31_G:result.args[i] := 'FEGYV_H31_G'; + FEGYV_HPL:result.args[i] := 'FEGYV_HPL'; + FEGYV_BM3:result.args[i] := 'FEGYV_BM3'; + FEGYV_BM3_2, FEGYV_BM3_3:; + end; + + continue; + end; + + if result.args[i] = '$team' then + begin + result.handled := true; + case myfegyv of + FEGYV_MPG, FEGYV_QUAD, FEGYV_NOOB, FEGYV_X72, FEGYV_H31_T, FEGYV_HPL:result.args[i] := 'TECH'; + else + result.args[i] := 'GUN'; + end; + + continue; + end; + + if result.args[i] = '%teamn' then + begin + result.handled := true; + case myfegyv of + FEGYV_MPG, FEGYV_QUAD, FEGYV_NOOB, FEGYV_X72, FEGYV_H31_T, FEGYV_HPL:result.args[i] := '0'; + else + result.args[i] := '1'; + end; + + continue; + end; + + end; //for +end; + +function TScriptsHandler.parseControls(args: TStringArray): TArgsParserResult; +begin + result.args := args; + result.handled := false; + + if (result.args[0] = 'if') then + begin + result.handled := true; + if not _scriptevaling[_scriptdepth] then + begin + inc(_scriptdepth); + _scriptevaling[_scriptdepth]:=false; + end + else + varCompare(copy(result.args, 1, length(result.args) - 1)); + + exit; + end; + + if (result.args[0] = 'else') then + begin + result.handled := true; + if _scriptdepth > 0 then + _scriptevaling[_scriptdepth] := not _scriptevaling[_scriptdepth] and _scriptevaling[_scriptdepth - 1] + else + scripterror('Unexpected else'); + + exit; + end; + + if (result.args[0] = 'endif') then + begin + result.handled := true; + if _scriptdepth > 0 then + dec(_scriptdepth) + else + scripterror('Unexpected endif'); + + exit; + end; +end; + +function TScriptsHandler.parseAssignments(args: TStringArray): TArgsParserResult; +var + i, j: integer; + t, tmp: string; +begin + result.args := args; + result.handled := false; + + if (length(result.args) <= 1) then exit; + + t:=result.args[0][1]; + + if (t = '!') and (result.args[1] = '=') then + begin + result.handled := true; + for i:=0 to length(_vecvars) - 1 do + if result.args[0] = '!' + _vecvars[i].name then + _vecvars[i].pos:=computevecs(copy(result.args, 2, length(result.args) - 2)); + + exit; + end; + + if (t = '%') and (result.args[1] = '=') then + begin + result.handled := true; + for i:=0 to length(_numVars) - 1 do + if result.args[0] = '%' + _numVars[i].name then + _numVars[i].num:=computenums(copy(result.args, 2, length(result.args) - 2)); + + exit; + end; + + if (t = '$') and (result.args[1] = '=') then + begin + result.handled := true; + for i:=0 to length(_strVars) - 1 do + if result.args[0] = '$' + _strVars[i].name then + begin + tmp:= ''; + for j:=2 to length(result.args) - 1 do + begin + tmp:=tmp + varToString(result.args[j]); + //if j 'var') or (length(result.args) <= 1) then exit; + + if (result.args[1][1] = '%') then + begin + result.handled := true; + setlength(_numVars, length(_numVars) + 1); + _numVars[length(_numVars) - 1].name := copy(result.args[1], 2, length(result.args[1]) - 1); + + exit; + end; + + if (result.args[1][1] = '!') then + begin + result.handled := true; + setlength(_vecVars, length(_vecVars) + 1); + _vecVars[length(_vecVars) - 1].name := copy(result.args[1], 2, length(result.args[1]) - 1); + + exit; + end; + + if (result.args[1][1] = '$') then + begin + result.handled := true; + setlength(_strVars, length(_strVars) + 1); + _strVars[length(_strVars) - 1].name := copy(result.args[1], 2, length(result.args[1]) - 1); + + exit; + end; +end; + +function TScriptsHandler.parseCommands(args: TStringArray; line: string): TArgsParserResult; +var + i: integer; + res: boolean; +begin + result.args := args; + result.handled := false; + + for i := 0 to high(_commandHandlers) do + begin + res := _commandHandlers[i](result.args, self); + result.handled := result.handled or res; + end; +end; + +function TScriptsHandler.getVecVar(name: string): TD3DXVector3; +var + i, n:integer; +begin + n:=length(_vecVars); + result:=D3DXVector3Zero; + for i:=0 to n - 1 do + if _vecVars[i].name = name then + begin + result:=_vecVars[i].pos; + exit; + end; + + //why isnt this script error lel debug loife + multisc.chats[addchatindex].uzenet := 'No such vector variable: ' + name; + addchatindex:=addchatindex + 1; +end; + +function TScriptsHandler.getNumVar(name: string): single; +var + i, n:integer; +begin + n:=length(_numVars); + result:=0; + for i:=0 to n - 1 do + if _numVars[i].name = name then + begin + result:=_numVars[i].num; + exit; + end; + + //why isnt this script error lel debug loife part 2 + multisc.chats[addchatindex].uzenet := 'No such numeric variable: ' + name; + addchatindex:=addchatindex + 1; +end; + +procedure TScriptsHandler.varCompare(args: TStringArray); +var + argnum, i, j:integer; + v1, v2:single; + truth:boolean; + op:string; + a, b:TStringArray; +begin + argnum:=length(args); + + //find the comparator + for i:=0 to high(args) do + begin + + if ((args[i] <> '=') or (args[i] <> '>') or (args[i] <> '<') or + (args[i] <> '!=') or (args[i] <> '>=') or (args[i] <> '<=')) then + begin + continue; + end; + + op := args[i]; + setlength(a, i); + setlength(b, argnum - i - 1); + + for j:=0 to i - 1 do + a[j] := args[j]; + + for j:=0 to argnum - i - 2 do + b[j] := args[i + 1 + j]; + + v1:=compute(a)[0]; + v2:=compute(b)[0]; + + truth := false; + + if (op = '=') and (v1 = v2) then truth := true; + if (op = '<') and (v1 < v2) then truth := true; + if (op = '>') and (v1 > v2) then truth := true; + if (op = '!=') and (v1 <> v2) then truth := true; + if (op = '<=') and (v1 <= v2) then truth := true; + if (op = '>=') and (v1 >= v2) then truth := true; + + inc(_scriptdepth); + _scriptevaling[_scriptdepth] := truth; + + exit; + end;//for + +end; + +function TScriptsHandler.computeVecs(words: TStringArray): TD3DXVector3; +var + tmp:TSingleArray; + tmp2:TStringArray; + i, n:integer; +begin + n:=length(words); + setLength(tmp2, n); + + for i:=0 to n - 1 do + tmp2[i]:=words[i]; + + tmp:=compute(tmp2); + result:=D3DXVector3(tmp[0], tmp[1], tmp[2]); +end; + +function TScriptsHandler.computeNums(words: TStringArray): single; +var + tmp:TSingleArray; + tmp2:TStringArray; + i, n:integer; +begin + n:=length(words); + setLength(tmp2, n); + + for i:=0 to n - 1 do + tmp2[i]:=words[i]; + + tmp:=compute(tmp2); + result:=tmp[0]; +end; + +function TScriptsHandler.compute(words: TStringArray): TSingleArray; +var + i, j, n:integer; + tmp:TD3DXVector3; + error:Integer; + numnum, varnum:integer; + nums, vars:array[0..2] of single; + operator:char; + value:single; + r:TSingleArray; +begin + // ! vector variable + // % number variable + // what the fuck is string wow thx Hector + + setlength(words, length(words) + 1); + words[high(words)] := '//'; + + n := length(words); + + for i := 0 to high(words) do + if words[i][1] = '!' then + begin + tmp := getVecVar(copy(words[i], 2, length(words[i]) - 1)); + + setlength(words, n + 2); + n := n + 2; + + if i <> n - 2 then + for j := n - 1 downto i + 3 do + words[j] := words[j - 2]; + + words[i] := FloatToStr(tmp.x); + words[i + 1] := FloatToStr(tmp.y); + words[i + 2] := FloatToStr(tmp.z); + + end else + if words[i][1] = '%' then + words[i] := FloatToStr(getNumVar(copy(words[i], 2, length(words[i]) - 1))); + + //variables processed, lets count + numnum:=0; + varnum:=0; + operator:= ' '; + + for i:=0 to n - 1 do + begin + val(words[i], value, error); + + if error = 0 then + begin //number! + inc(numnum); //count numbers in a row + + if numnum > 3 then + begin + scripterror('Unexpected fourth number: ' + words[i]); + exit; + end; + + nums[numnum - 1]:=value; + + end + else + begin + + if (operator <> ' ') then //operators + begin + if (numnum = 1) and (varnum = 1) then + begin + if operator = '+' then vars[0]:=vars[0] + nums[0]; + if operator = '-' then vars[0]:=vars[0] - nums[0]; + if operator = '*' then vars[0]:=vars[0] * nums[0]; + if operator = '/' then vars[0]:=vars[0] / nums[0]; + end else + if (numnum = 3) and (varnum = 1) then + begin + if operator = '+' then + begin + scripterror('Single and vector addition');exit end; + if operator = '-' then + begin + scripterror('Single and vector substraction');exit end; + if operator = '*' then + begin + vars[0]:=vars[0] * nums[0];vars[1]:=vars[0] * nums[1];vars[2]:=vars[0] * nums[2]; end; + if operator = '/' then + begin + vars[0]:=vars[0] / nums[0];vars[1]:=vars[0] / nums[1];vars[2]:=vars[0] / nums[2]; end; + end else + if (numnum = 1) and (varnum = 3) then + begin + if operator = '+' then + begin + scripterror('Single and vector addition');exit end; + if operator = '-' then + begin + scripterror('Single and vector substraction');exit end; + if operator = '*' then + begin + vars[0]:=vars[0] * nums[0];vars[1]:=vars[1] * nums[0];vars[2]:=vars[2] * nums[0]; end; + if operator = '/' then + begin + scripterror('Vector and single division');exit end; + end else + if (numnum = 3) and (varnum = 3) then + begin + if operator = '+' then + begin + vars[0]:=vars[0] + nums[0];vars[1]:=vars[1] + nums[1];vars[2]:=vars[2] + nums[2]; end; + if operator = '-' then + begin + vars[0]:=vars[0] - nums[0];vars[1]:=vars[1] - nums[2];vars[2]:=vars[2] - nums[2]; end; + if operator = '*' then + begin + vars[0]:=vars[0] * nums[0];vars[1]:=vars[1] * nums[1];vars[2]:=vars[2] * nums[2]; end; + if operator = '/' then + begin + vars[0]:=vars[0] / nums[0];vars[1]:=vars[1] / nums[1];vars[2]:=vars[2] / nums[2]; end; + end else + + //if a tree falls in the forest... + end + else + begin + if (numnum = 1) then begin vars[0]:=nums[0];varnum:=1 end else + if (numnum = 3) then begin vars[0]:=nums[0];vars[1]:=nums[1];vars[2]:=nums[2];varnum:=3 end; + end; + + if (words[i] = '+') or (words[i] = '-') or (words[i] = '*') then + begin + if (numnum = 0) or (numnum = 2) then + begin + scripterror('Unexpected operator: ' + words[i]); + exit; + end; + + operator:=words[i][1]; + numnum:=0; + + end + else + if (words[i] = '//') then //end + begin + SetLength(r, 3); + r[0]:=vars[0]; + r[1]:=vars[1]; + r[2]:=vars[2]; + result:=r; + end + else + begin + scripterror('Syntax error: ' + words[i]); + exit; + end; + end; + + end; + +end; + + +procedure TScriptsHandler.evalScript(name:string); +var + i, j, n, m:integer; +begin + laststate := 'TScriptsHandler.evalScript 1'; + + if name = '' then exit; + + _scriptdepth:=0; + laststate := 'TScriptsHandler.evalScript 2'; + _scriptevaling[_scriptdepth]:=true; + laststate := 'TScriptsHandler.evalScript 3'; + + n:=Length(_scripts); + for i:=0 to n - 1 do + begin + if _scripts[i].name = name then + begin + m:=Length(_scripts[i].instructions); + _actualscript:=name; + for j:=0 to m - 1 do + begin + _actualscriptline:=j + 1; + evalscriptline(_scripts[i].instructions[j]); + end; + + _scriptdepth:=0; + _scriptevaling[_scriptdepth]:=true; + + exit; + end; + end; +end; + +procedure TScriptsHandler.evalscriptline(line: string); +var + args: TStringArray; + parserResult: TArgsParserResult; +begin + DecimalSeparator:= '.'; //for reading json in commands + setlength(args, 0); + + //split to words + args := explodeLine(line, args); + + //shits fucked + if length(args) <= 0 then exit; + + //plugging in + parserResult := parseGlobals(args); + if parserResult.handled then exit; + args := parserResult.args; + + //wow, its something + parserResult := parseControls(args); + if parserResult.handled then exit; + args := parserResult.args; + + //sneaky short circuit + if not _scriptevaling[_scriptdepth] then exit; + + //assignments + parserResult := parseAssignments(args); + if parserResult.handled then exit; + args := parserResult.args; + + //new vars + parserResult := parseDeclarations(args); + if parserResult.handled then exit; + args := parserResult.args; + + //commands + parserResult := parseCommands(args, line); + if parserResult.handled then exit; + + //unhandled + multisc.chats[addchatindex].uzenet:= 'Unhandled scriptline: ' + line; + addchatindex:=addchatindex + 1; +end; + +//SCRIPT ENGINE AND DEBUG TOOLS + +function getLangCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i, j: integer; + t, tmp: string; +begin + result := false; + + if (args[0] = 'getlang') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + t:=args[1][1]; + if (t = '$') then + for i:=0 to Length(_strvars) - 1 do + if args[1] = '$' + _strvars[i].name then //container found + begin + tmp:= ''; + j:=trunc(computenums(copy(args, 2, length(args) - 2))); + if sizeof(lang) < j then + _strvars[i].text:=lang[j]; + + exit; + end; + + end; + end; +end; + +function bindCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; +begin + result := false; + + if (args[0] = 'bind') then + begin + result := true; + + with handler do + begin + + if Length(args) < 3 then begin scripterror('Not enough paramater for bind');exit; end; + if (args[1] = 'closedisplay') then + displaycloseevent := args[2] + else + begin + for i:=0 to Length(_binds) - 1 do + if _binds[i].key = args[1][1] then + begin + _binds[i].script:=args[2]; + exit; + end; + SetLength(_binds, Length(_binds) + 1); + _binds[Length(_binds) - 1].key:=args[1][1]; + _binds[Length(_binds) - 1].script:=args[2]; + end; + end; + end; +end; + +function unbindCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i, j: integer; +begin + result := false; + + if (args[0] = 'unbind') then + begin + result := true; + + with handler do + begin + + if Length(args) < 2 then begin scripterror('Not enough paramater for unbind');exit; end; + if (args[1] = 'closedisplay') then + displaycloseevent:= '' + else + begin + for i:=0 to Length(_binds) - 1 do + if _binds[i].key = args[1][1] then + begin + for j:=i to Length(_binds) - 2 do + _binds[j]:=_binds[j + 1]; + SetLength(_binds, length(_binds) - 1); + end; + end; + exit; + end; + end; +end; + +function unbindAllCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'unbindall') then + begin + result := true; + + with handler do + begin + + SetLength(_binds, 0); + exit; + end; + end; +end; + +function triggerEnableCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'trigger_enable') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + for i:=0 to Length(triggers) - 1 do + if triggers[i].name = tmp then + triggers[i].active:=true; + exit; + end; + end; +end; + +function triggerDisableCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; + v1: single; +begin + result := false; + + if (args[0] = 'trigger_disable') and (Length(args) > 2) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + for i:=0 to Length(triggers) - 1 do + if triggers[i].name = tmp then + begin + triggers[i].active:=false; + v1:=computenums(copy(args, 2, length(args) - 2)); + if v1 = 0 then + triggers[i].restart:=0 + else + triggers[i].restart:=gettickcount + trunc(v1); + end; + exit; + end; + end; +end; + +//big hud message in the center +function fastinfoCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'fastinfo') then + begin + result := true; + + with handler do + begin + + for i:=1 to Length(args) - 1 do + tmp:=tmp + ' ' + varToString(args[i]); + + addHudMessage(tmp, 255, betuszin); + exit; + end; + end; +end; + +//big RED hud message in the center +function fastinfoRedCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'fastinfored') then + begin + result := true; + + with handler do + begin + + for i:=1 to Length(args) - 1 do + tmp:=tmp + ' ' + varToString(args[i]); + + addHudMessage(tmp, $FF0000); + exit; + end; + end; +end; + +//chat message +function printCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'print') then + begin + result := true; + + with handler do + begin + + for i:=1 to Length(args) - 1 do + tmp:=tmp + ' ' + varToString(args[i]); + + multisc.chats[addchatindex].uzenet:=tmp; + addchatindex:=addchatindex + 1; + exit; + end; + end; +end; + +//global chat message +function chatmostCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'chatmost') then + begin + result := true; + + with handler do + begin + + tmp := ''; + for i:=1 to Length(args) - 1 do + tmp := tmp + ' ' + varToString(args[i]); + + Multisc.Chat(tmp); + exit; + end; + end; +end; + +//window display +function displayCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'display') then + begin + result := true; + + with handler do + begin + + for i:=1 to Length(args) - 1 do + tmp:=tmp + ' ' + varToString(args[i]); + + labeltext:=tmp; + labelactive:=true; + exit; + end; + end; +end; + +//window display - close +function closedisplayCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'closedisplay') then + begin + result := true; + + with handler do + begin + + labelactive:=false; + exit; + end; + end; +end; + +//script call +function scriptCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'script') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + evalScript(args[1]); + exit; + end; + end; +end; + +//script call - "async" +function timeoutCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'timeout') and (Length(args) > 2) then + begin + result := true; + + with handler do + begin + + SetLength(_timedscripts, length(_timedscripts) + 1); + with _timedscripts[length(_timedscripts) - 1] do + begin + script:=args[1]; + time:=gettickcount + trunc(computenums(copy(args, 2, length(args) - 2))); + end; + + exit; + end; + end; +end; + +// SCRIPT ENGINE AND DEBUG TOOLS END +// PARTICLES AND PROPS + +//stop particle system +function particleStopCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + v1: single; +begin + result := false; + + if (args[0] = 'particle_stop') and (Length(args) > 2) then + begin + result := true; + + with handler do + begin + + for i:=0 to Length(particlesSyses) - 1 do + if particlesSyses[i].name = args[1] then + begin + particlesSyses[i].disabled:=true; + v1:=computenums(copy(args, 2, length(args) - 2)); + if v1 = 0 then + particlesSyses[i].restart:=0 + else + particlesSyses[i].restart:=gettickcount + trunc(v1); + end; + exit; + end; + end; +end; + +//start particle system +function particleStartCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; +begin + result := false; + + if (args[0] = 'particle_start') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + for i:=0 to Length(particlesSyses) - 1 do + if particlesSyses[i].name = args[1] then + particlesSyses[i].disabled:=false; + + exit; + end; + end; +end; + +function particlePositionCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + i: integer; + tmp: string; +begin + result := false; + + if (args[0] = 'particle_position') and (Length(args) > 4) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + for i:=0 to length(particlesSyses) - 1 do + if particlesSyses[i].name = tmp then + particlesSyses[i].from:=computevecs(copy(args, 2, length(args) - 2)); + + exit; + end; + end; +end; + +//prop hide +function propHideCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'prop_hide') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + propsystem.setVisibility(args[1], false); + exit; + end; + end; +end; + +//prop show +function propShowCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'prop_show') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + propsystem.setVisibility(args[1], true); + exit; + end; + end; +end; + +function dynamizateCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + tmp: string; +begin + result := false; + + if (args[0] = 'dynamizate') and (Length(args) > 1) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + propsystem.dynamizate(tmp).speed:=D3DXVector3(0, 0.5, 0); + exit; + end; + end; +end; + +function dynamicSpeedCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + tmp: string; +begin + result := false; + + if (args[0] = 'dynamic_speed') and (Length(args) > 4) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + propsystem.getdynamic(tmp).speed:=computevecs(copy(args, 2, length(args) - 2)); + + exit; + end; + end; +end; + +function propPositionCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + tmp: string; +begin + result := false; + + if (args[0] = 'prop_position') and (Length(args) > 4) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + propsystem.getprop(tmp).pos:=computevecs(copy(args, 2, length(args) - 2)); + + exit; + end; + end; +end; + +function propRotationCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +var + tmp: string; +begin + result := false; + + if (args[0] = 'prop_rotation') and (Length(args) > 2) then + begin + result := true; + + with handler do + begin + + tmp:=varToString(args[1]); + propsystem.getprop(tmp).rot:=computenums(copy(args, 2, length(args) - 2)); + + exit; + end; + end; +end; + +//PARTICLES AND PROPS END +//BOT BATTLE STUFF + +//wave +function botWaveCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'wave') and (Length(args) > 1)then + begin + result := true; + + with handler do + begin + + wave:= strtoint(args[1]); + exit; + end; + end; +end; + +//skirmish +function botSkirmishCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'skirmish') then + begin + result := true; + + with handler do + begin + + skirmish:= true; + exit; + end; + end; +end; + +//startbattle +function botStartBattleCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'startbattle') then + begin + result := true; + + with handler do + begin + + battle:=true; + exit; + end; + end; +end; + +//stopbattle +function botStopBattleCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'stopbattle') then + begin + result := true; + + with handler do + begin + + battle:=false; + exit; + end; + end; +end; + +//BOT BATTLE STUFF END +//MISC COMMANDS AND TEST TOOLS + +//law explosion +function explodeCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'explode') then + begin + result := true; + + with handler do + begin + + AddLAW(D3DXVector3Zero, computevecs(copy(args, 1, length(args) - 1)), -1); + exit; + end; + end; +end; + +//TODO: respawn (waiting for more unit refacts) +{ +function TScriptsHandler.respawnCMD(args: TStringArray): boolean; +begin + result := false; + + if (args[0] = 'respawn') then + begin + result := true; + + respawn; + exit; + end; +end; +} + +//sounds +function soundCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'sound') and (Length(args) > 4) then + begin + result := true; + + with handler do + begin + + playsound(StrToInt(args[1]), false, integer(timegettime) + random(10000), true, D3DXVector3(StrToFloat(args[2]), StrToFloat(args[3]), StrToFloat(args[4]))); + exit; + end; + end; +end; + +//fegyvskin load +function fegyvskinCMD(args: TStringArray; out handler: TScriptsHandler): boolean; +begin + result := false; + + if (args[0] = 'fegyvskin') then + begin + result := true; + + with handler do + begin + + //evalscriptline('display fegyvskin'); + case myfegyv of + FEGYV_MPG: myfegyv_skin := fegyvskins[5]; + FEGYV_M82A1: myfegyv_skin := fegyvskins[1]; + FEGYV_M4A1: myfegyv_skin := fegyvskins[0]; + FEGYV_QUAD: myfegyv_skin := fegyvskins[6]; + FEGYV_NOOB: myfegyv_skin := fegyvskins[7]; + FEGYV_LAW: myfegyv_skin := fegyvskins[2]; + FEGYV_X72: myfegyv_skin := fegyvskins[8]; + FEGYV_MP5A3: myfegyv_skin := fegyvskins[3]; + FEGYV_H31_T: myfegyv_skin := FEGYV_H31_T; + FEGYV_H31_G: myfegyv_skin := FEGYV_H31_G; + FEGYV_HPL: myfegyv_skin := fegyvskins[9]; + FEGYV_BM3: myfegyv_skin := fegyvskins[4]; + end; + + exit; + end; + end; +end; + +//TODO: spawn airboat/submarine (waiting for more unit refacts) +{ +function TScriptsHandler.watercraftCMD(args: TStringArray): boolean; +begin + result := false; + + if (args[0] = 'watercraft') and (Length(args) > 3) then + begin + result := true; + + if myfegyv > 127 then + SpawnVehicle(computevecs(copy(args, 1, argnum - 1)), 2, 'airboat') + else + SpawnVehicle(computevecs(copy(args, 1, argnum - 1)), 1, 'submarine'); + + exit; + end; +end; +} + +//MISC COMMANDS AND TEST TOOLS END + +end. diff --git a/src/Sentry.pas b/src/Sentry.pas new file mode 100644 index 0000000..1185575 --- /dev/null +++ b/src/Sentry.pas @@ -0,0 +1,171 @@ +unit Sentry; + +{$I Defines.inc} + +interface + + uses + SysUtils, + MMSystem, + Windows, + // + Typestuff, + MutableObject; + + const + MAX_BREADCRUMBS = 50; + + type TSentryMetadata = record + isDev: boolean; + version: Integer; + checksum: Cardinal; + end; + + type TSentryBreadcrumb = record + timestamp: string; + msg: string; + data: TMutableObject; + end; + + type TSentry = class (TOBject) + private + _output: Textfile; + _metadata: TSentryMetadata; + _breadcrumbs: array of TSentryBreadcrumb; + published + constructor Create; + procedure addBreadcrumb(crumb: TSentryBreadcrumb); + procedure reportError(err: Exception; msg: string); + end; + + function makeBreadcrumb(msg: string): TSentryBreadcrumb; overload; + function makeBreadcrumb(msg: string; data: TMutableObject): TSentryBreadcrumb; overload; + +var + sentryModule: TSentry; + +implementation + +function metadataToJSON(metadata: TSentryMetadata): string; forward; +function breadcrumbToJSON(crumb: TSentryBreadcrumb): string; forward; + +function makeBreadcrumb(msg: string): TSentryBreadcrumb; overload; +begin + result.timestamp := formatdatetime('YYYY-MM-DD hh:mm:ss', now); + result.msg := msg; + result.data := TMutableObject.Create(true); +end; + +function makeBreadcrumb(msg: string; data: TMutableObject): TSentryBreadcrumb; overload; +begin + result.timestamp := formatdatetime('YYYY-MM-DD hh:mm:ss', now); + result.msg := msg; + result.data := data; +end; + +constructor TSentry.Create; +begin + with _metadata do + begin + isDev := {$IFDEF undebug} false {$ELSE} true {$ENDIF}; + version := PROG_VER; + checksum := datachecksum; + end; +end; + +procedure TSentry.addBreadcrumb(crumb: TSentryBreadcrumb); +var + i: Integer; +begin + //can append + if length(_breadcrumbs) < MAX_BREADCRUMBS then + begin + setlength(_breadcrumbs, succ(length(_breadcrumbs))); + _breadcrumbs[high(_breadcrumbs)] := crumb; + + exit; + end; + + //shift + for i := low(_breadcrumbs) to pred(high(_breadcrumbs)) do + _breadcrumbs[i] := _breadcrumbs[succ(i)]; + + setlength(_breadcrumbs, MAX_BREADCRUMBS); + _breadcrumbs[high(_breadcrumbs)] := crumb; +end; + +//TODO: actual JSON writer +procedure TSentry.reportError(err: Exception; msg: string); +var + json, fname: string; + i: Integer; +begin + //open output file + fname := formatdatetime('YYYY-MM-DD_hh-mm-ss-zzz', now) + '.sentry.json'; + assignfile(_output, fname); + rewrite(_output); + + //make contents + json := '{'; + + //error and message + json := json + '"error": "' + err.message + '"'; + json := json + ', "message": "' + msg + '"'; + json := json + ', "laststate": "' + laststate + '"'; + + //metadata + json := json + ', "metadata": ' + metadataToJSON(_metadata); + + //breadcrumbs + json := json + ', "breadcrumbs": ['; + for i := low(_breadcrumbs) to high(_breadcrumbs) do + begin + if i > low(_breadcrumbs) then + json := json + ', '; + + json := json + breadcrumbToJSON(_breadcrumbs[i]); + end; + + //breadcrumbs end + json := json + ']'; + + //content end + json := json + '}'; + + //write and close output file + write(_output, json); + flush(_output); + closefile(_output); + + setlength(_breadcrumbs, 0); +end; + +function metadataToJSON(metadata: TSentryMetadata): string; +begin + result := '{'; + + if metadata.isDev then + result := result + '"mode": "dev"' + else + result := result + '"mode": "prod"'; + + result := result + ', "version": "' + intToStr(metadata.version) + '"'; + result := result + ', "datachecksum": "' + intToHex(metadata.checksum, 8) + '"'; + + result := result + '}'; +end; + + +function breadcrumbToJSON(crumb: TSentryBreadcrumb): string; +begin + result := '{'; + + result := result + '"timestamp": "' + crumb.timestamp + '"'; + result := result + ', "message": "' + crumb.msg + '"'; + if not crumb.data.isEmpty then + result := result + ', "data": ' + crumb.data.toJSON; + + result := result + '}'; +end; + +end. diff --git a/src/Stickman.dpr b/src/Stickman.dpr index 31909e2..d7f1585 100644 --- a/src/Stickman.dpr +++ b/src/Stickman.dpr @@ -5,9 +5,10 @@ * for more information. *) {$R stickman.RES} -{$DEFINE force16bitindices} //ez hibás, pár helyen, ha nincs kipontozva, meg kell majd nézni -{.$DEFINE undebug} //Remove dot for release, add dot for dev -{.$DEFINE nochecksumcheck} + +{$I Defines.inc} + +{$DEFINE force16bitindices} //ez hibás, pár helyen, ha nincs kipontozva, meg kell majd nézni {.$DEFINE speedhack} {.$DEFINE repkedomod} {.$DEFINE godmode} @@ -66,10 +67,16 @@ uses IdWinsock2, BotGroups, Selfie, - stickApi; + stickApi, + Scripts, + MutableObject, + Redux, + DynamicArray, + Sentry, + ThreadHandler; const - lvlmin = 0; //ENNEK ÍGY KÉNE MARADNIA + lvlmin = 0; //ENNEK ÃGY KÉNE MARADNIA lvlmax = 6; lvlsiz = 32; //Ennek is :( lvlsizp = lvlsiz + 1; @@ -101,7 +108,7 @@ const T_CONST = 0; T_OPERATOR = 1; - //CMAP_SIZE=1024; //lefelé betöltésnél kéne scalelni + //CMAP_SIZE=1024; //lefelé betöltésnél kéne scalelni CMAP_SIZE = 1024; CMAP_PATH = 'data/textures/map/'; @@ -112,12 +119,13 @@ const //----------------------------------------------------------------------------- var // REMOVE - + botkills: Integer = 0; + bootkillsendtim: Integer = 100 * 60 * 5; //every 5 minutes (igen az 100 es nem 1000) botGroupArr: array of TBotGroup; - selfieMaker: TSelfie; + selfieMaker: TSelfie; - CMAP1_NAME:string = 'cmap.png'; //régi terep - CMAP2_NAME:string = 'cmap2.png'; //térkép + CMAP1_NAME:string = 'cmap.png'; //régi terep + CMAP2_NAME:string = 'cmap2.png'; //térkép CMAP3_NAME:string = 'cmap3.png'; //shader terep modifierjson:TQJSON; {$IFDEF matieditor} @@ -175,10 +183,9 @@ var hogombmesh:ID3DXMesh = nil; - foliages:array of Tfoliage; //Növényzet + foliages:array of Tfoliage; //Növényzet // foliagelevels:array of integer; ojjektumrenderer:T3DORenderer; - propsystem:TPropsystem; fegyv:Tfegyv = nil; test:array[0..9] of single; VBwhere:integer; @@ -191,14 +198,6 @@ var menu:T3dMenu = nil; nohud:boolean = false; nofegyv:boolean = false; - bots_enabled:boolean = true; - - battle:boolean = false; - skirmish:boolean = false; - wave:integer = 0; - accuracy_modif:single = 0; - - safemode:boolean = false; portalbaugras:boolean = false; @@ -219,15 +218,6 @@ var portalpos:TD3DXVector3; portalstarted:boolean = false; - scripts:array of TScript; - vecVars:array of TVecVar; - numVars:array of TNumVar; - strVars:array of TStrVar; - actualscript:string; - actualscriptline:integer; - scriptdepth:integer = 0; - scriptevaling:array[0..50] of boolean; - usebutton:boolean = false; cmx, cmz:integer; @@ -242,14 +232,14 @@ var toind, allind:integer; muks:Tmuksoka; halalhorg:integer; - cpox:Psingle; ///FRÖCCCS - cpoy:Psingle; ///FRÖCCCS - cpoz:Psingle; ///FRÖCCCS + cpox:Psingle; ///FRÖCCCS + cpoy:Psingle; ///FRÖCCCS + cpoz:Psingle; ///FRÖCCCS mousesens:single; mouseacc:boolean; oopos:TD3DXVector3; wentthroughwall:boolean; - posokvoltak:array[0..4] of TD3DXVector3; //Ne MERD az MMO-n kíbvül használni mert megbaszlak! + posokvoltak:array[0..4] of TD3DXVector3; //Ne MERD az MMO-n kíbvül használni mert megbaszlak! lastzone:string; zonaellen:integer; zonabarat:integer; @@ -267,8 +257,6 @@ var coordsniper:boolean = false; fsettings:TFormatSettings; - addchatindex:integer; - {$IFDEF propeditor} debugstr:string; propsniper:boolean; @@ -307,9 +295,6 @@ var tauntvolt:boolean; labelvolt:boolean; - labelactive:boolean; - labeltext:string; - HDRarr:array[0..7, 0..7] of integer; HDRscanline:byte; HDRincit:single = 8000; @@ -349,14 +334,6 @@ var villambol:byte; // fogc,fogstart,fogend,lightIntensity:single; - noobproj, lawproj, x72proj, h31_gproj, h31_tproj:array of Tnamedprojectile; - lawmesh, noobmesh:ID3DXMesh; - rezg:single; - hatralok:single; - LAWkesleltetes:integer = -1; - mp5ptl:single; - x72gyrs:single; - effecttexture, reflecttexture:IDirect3DTexture9; waterbumpmap:IDirect3DTexture9; enableeffects:boolean; @@ -385,20 +362,10 @@ var // frust:Tfrustum; vegeffekt:integer; - - teleports:array of TTeleport; - particlesSyses:array of TParticleSys; - particlesProtos:array of TParticleSys; + labels:array of T3dLabel; - triggers:array of TTrigger; - leavetriggers:array of TLeaveTrigger; - binds:array of TBind; - timedscripts:array of TTimedscript; - sounds:array of TSoundData; - displaycloseevent:string; - opt_taunts:boolean; snowpick:single; @@ -446,235 +413,9 @@ var // re_pos:TD3DXVector3; ////////////////////////////////////////////////////////////////////////////////////////////////// - -procedure evalscriptline(line:string);forward; -procedure evalScript(name:string);forward; procedure writeChat(s:string);forward; procedure fillupmenu;forward; - -//----------------------------------------------------------------------------- -// THREADS -//----------------------------------------------------------------------------- - -//TODO: move api related threads to stickApi unit -// (requires separate script handler unit at least) - -{ -//EXAMPLE -type TPrintServerTimeThread = class(TAsync) -private - _api: TApi; - _response: TApiResponse; -protected - procedure Execute; override; -end; - -procedure TPrintServerTimeThread.Execute; -var - output: string; -begin - try - _api := TApi.Create; - _response := _api.GET(baseUrl + 'servertime'); - - if _response.success then - begin - output := _response.data.getString(['data','time']); - - evalscriptline('display ' + output); - end; - finally - Terminate; - end; -end; -} - -type TToplist = (TOP_MONTHLY, TOP_WEEKLY, TOP_DAILY, TOP_ALL); - -type TPrintTopThread = class(TAsync) -private - _api: TApi; - _response: TApiResponse; - _endpoint: string; -protected - procedure Execute; override; -public - constructor Create(startSuspended: boolean; mode: TToplist = TOP_ALL); -end; - -constructor TPrintTopThread.Create(startSuspended: boolean; mode: TToplist = TOP_ALL); -begin - inherited Create(startSuspended); - - case mode of - TOP_MONTHLY: _endpoint := 'havitop'; - TOP_WEEKLY: _endpoint := 'hetitop'; - TOP_DAILY: _endpoint := 'napitop'; - TOP_ALL: _endpoint := 'top'; - end; -end; - -procedure TPrintTopThread.Execute; -var - output: string; - nev: string; - pont: string; - line: string; - i: Cardinal; -begin - try - _api := TApi.Create; - _response := _api.GET(baseUrl + _endpoint); - - if _response.success then - begin - for i := 0 to 9 do - begin - nev := _response.data.getString(['data', i, 'nev']); - if length(nev) = 0 then nev := '-'; - - pont := _response.data.getString(['data', i, 'pont']); - if length(pont) = 0 then pont := ''; - - line := inttostr(i + 1) + '. ' + nev + ' ' + pont; - output := output + NL + line; - end; - evalscriptline('display ' + output); - end; - finally - Terminate; - end; -end; - - -type TPrintRank = class(TAsync) -private - _api: TApi; - _response: TApiResponse; - _uname: string; - _mode: string; -protected - procedure Execute; override; -public - constructor Create(startSuspended: boolean; uname: string; mode: TToplist = TOP_ALL); -end; - -constructor TPrintRank.Create(startSuspended: boolean; uname: string; mode: TToplist = TOP_ALL); -begin - inherited Create(startSuspended); - - _uname := uname; - case mode of - TOP_MONTHLY: _mode := 'havi'; - TOP_WEEKLY: _mode := 'heti'; - TOP_DAILY: _mode := 'napi'; - TOP_ALL: _mode := 'ossz'; - end; -end; - -procedure TPrintRank.Execute; -var - output: string; -begin - try - _api := TApi.Create; - _response := _api.GET(baseUrl + 'rank&nev=' + _uname + '&type=' + _mode); - - if _response.success then - begin - output := _response.data.getString(['data', 'rank']); - - evalscriptline('display ' + output); - end; - - finally - Terminate; - end; -end; - - -type TPrintKoTH = class(TAsync) -private - _api: TApi; - _response: TApiResponse; -protected - procedure Execute; override; -end; - -procedure TPrintKoTH.Execute; -var - output: string; - nev: string; - pont: string; - line: string; - i: Cardinal; -begin - try - _api := TApi.Create; - _response := _api.GET(baseUrl + 'koth'); - - if _response.success then - begin - for i := 0 to 9 do - begin - nev := _response.data.getString(['data', i, 'nev']); - if length(nev) = 0 then nev := '-'; - - pont := _response.data.getString(['data', i, 'pont']); - if length(pont) = 0 then pont := ''; - - line := inttostr(i + 1) + '. ' + nev + ' ' + pont; - output := output + NL + line; - end; - evalscriptline('display ' + output); - end; - finally - Terminate; - end; -end; - - -type TPrintToTH = class(TAsync) -private - _api: TApi; - _response: TApiResponse; -protected - procedure Execute; override; -end; - -procedure TPrintToTH.Execute; -var - output: string; - nev: string; - pont: string; - line: string; - i: Cardinal; -begin - try - _api := TApi.Create; - _response := _api.GET(baseUrl + 'toth'); - - if _response.success then - begin - for i := 0 to 9 do - begin - nev := _response.data.getString(['data', i, 'nev']); - if length(nev) = 0 then nev := '-'; - - pont := _response.data.getString(['data', i, 'pont']); - if length(pont) = 0 then pont := ''; - - line := inttostr(i + 1) + '. ' + nev + ' ' + pont; - output := output + NL + line; - end; - evalscriptline('display ' + output); - end; - finally - Terminate; - end; -end; - //----------------------------------------------------------------------------- // FUNCTIONS //----------------------------------------------------------------------------- @@ -1027,7 +768,7 @@ begin v24y:=advwove(xx, zz - (scalfac)) - advwove(xx, zz + (scalfac)); //v1-v3 v13y:=advwove(xx - (scalfac), zz) - advwove(xx + (scalfac), zz); - //Döbbenetes az egyszerûsítés + //Döbbenetes az egyszerûsítés norm.x:=v13y; norm.y:=2 * scalfac; norm.z:=v24y; @@ -1036,7 +777,7 @@ begin d3dxvec3scale(norm, norm, fastinvsqrt(lngt)); end; -//function norm(xx,zz:single;scalfac:single):Td3dvector; //ideiglenesen kivéve +//function norm(xx,zz:single;scalfac:single):Td3dvector; //ideiglenesen kivéve //var //lngt:single; //v24y,v13y:single; @@ -1184,7 +925,7 @@ begin //if scalfac>=pow2[farlvl] then //if (not useoldterrain and (opt_detail>0)) or (useoldterrain and (scalfac>=pow2[farlvl])) then if (not useoldterrain) or (useoldterrain and (scalfac >= pow2[farlvl])) then - begin //távoli vagy új + begin //távoli vagy új ux:=xx / 2048 + 0.5; uz:=zz / 2048 + 0.5; // szin:=$FFFFFF; yeeeaaaahhh @@ -1192,7 +933,7 @@ begin u2z:=zz / 2 + cos(xx / 3) / 6 + cos(xx / 10); //+perlin.complexnoise(1,xx,zz+2000,16,4,0.5)*1{+perlin.noise(xx/200+100,0.5,zz/200)*50}; end else - begin //old közeli + begin //old közeli ux:=xx / 1 + sin(zz / 2) / 2 + sin(zz / 8) + perlin.complexnoise(1, xx + 2000, zz, 16, 4, 0.5) * 3 {+perlin.noise(xx/200,0.5,zz/200+100)*50}; uz:=zz / 1 - cos(xx / 2) / 2 + cos(xx / 8) + perlin.complexnoise(1, xx, zz + 2000, 16, 4, 0.5) * 3 {+perlin.noise(xx/200+100,0.5,zz/200)*50}; u2x:=xx / 16; @@ -1293,7 +1034,7 @@ begin if (levels[lvl, alapind[i * 3 + 0]].color = fuszin) or (levels[lvl, alapind[i * 3 + 1]].color = fuszin) or (levels[lvl, alapind[i * 3 + 2]].color = fuszin) then - begin //füves a cucc + begin //füves a cucc lvlind[lvl, 0, lvlindszam[lvl, 0] + 0]:=alapind[i * 3 + 0] + lvlcucc; lvlind[lvl, 0, lvlindszam[lvl, 0] + 1]:=alapind[i * 3 + 1] + lvlcucc; lvlind[lvl, 0, lvlindszam[lvl, 0] + 2]:=alapind[i * 3 + 2] + lvlcucc; @@ -1303,7 +1044,7 @@ begin if (levels[lvl, alapind[i * 3 + 0]].color = koszin) or (levels[lvl, alapind[i * 3 + 1]].color = koszin) or (levels[lvl, alapind[i * 3 + 2]].color = koszin) then - begin //vagy köves + begin //vagy köves lvlind[lvl, 1, lvlindszam[lvl, 1] + 0]:=alapind[i * 3 + 0] + lvlcucc; lvlind[lvl, 1, lvlindszam[lvl, 1] + 1]:=alapind[i * 3 + 1] + lvlcucc; lvlind[lvl, 1, lvlindszam[lvl, 1] + 2]:=alapind[i * 3 + 2] + lvlcucc; @@ -1313,7 +1054,7 @@ begin if (levels[lvl, alapind[i * 3 + 0]].color <> fuszin) or (levels[lvl, alapind[i * 3 + 1]].color <> fuszin) or (levels[lvl, alapind[i * 3 + 2]].color <> fuszin) then - begin //vagy egyéb (homok, víz) + begin //vagy egyéb (homok, víz) lvlind[lvl, 2, lvlindszam[lvl, 2] + 0]:=alapind[i * 3 + 0] + lvlcucc; lvlind[lvl, 2, lvlindszam[lvl, 2] + 1]:=alapind[i * 3 + 1] + lvlcucc; lvlind[lvl, 2, lvlindszam[lvl, 2] + 2]:=alapind[i * 3 + 2] + lvlcucc; @@ -1330,7 +1071,7 @@ begin // zeromemory(pointer(pVertices),lvlsizp*lvlsizp*sizeof(Tcustomvertex)); g_pVB.Unlock; - //elköltöztünk + //elköltöztünk //if lvl=4 then bokrok.update(@(levels[lvl,0]),yandnormbokor); //if lvl=1 then fuvek.update(@(levels[lvl,0]),yandnormfu); @@ -1376,6 +1117,8 @@ var // start:cardinal; // sw : TStopWatch; begin + laststate := 'tryupdatefoliage start'; + // start:=GetTickCount; // for j:=lvlmin to lvlmax do @@ -1404,6 +1147,8 @@ begin // writeln(logfile, sw.ElapsedMilliseconds); // if (GetTickCount-start)<>0 then // writeln(logfile, GetTickCount-start); + + laststate := 'tryupdatefoliage end'; end; procedure updateterrain; @@ -1411,6 +1156,8 @@ var volt:boolean; i:integer; begin + laststate:='updateterrain start'; + volt:=false; for i:=lvlmax downto lvlmin do if lvlupd[i] then @@ -1419,16 +1166,22 @@ begin volt:=true; end; if volt then remakeindexbuffer; + + laststate:='updateterrain end'; end; procedure remaketerrain; var i:integer; begin + laststate:='remaketerrain start'; + for i:=lvlmax downto lvlmin do remakelvl(i); updateterrain; tryupdatefoliage(true); + + laststate:='remaketerrain end'; end; procedure stepb; @@ -1821,18 +1574,8 @@ begin end; end; - n:=stuffjson.GetNum(['scripts']); - setlength(scripts, n); - for i:=0 to n - 1 do - with scripts[i] do - begin - m:=stuffjson.GetNum(['scripts', i]); - setlength(scripts[i].instructions, m); - scripts[i].name:=stuffjson.GetKey(['scripts'], i); - - for j:=0 to m - 1 do - scripts[i].instructions[j]:=stuffjson.GetString(['scripts', i, j]); - end; + //load scripts + scriptsHandler := TScriptsHandler.Create(stuffjson); n:=stuffjson.GetNum(['triggers']); setlength(triggers, n); @@ -1932,7 +1675,7 @@ begin dnsrad:=ojjektumarr[panthepulet].rad * 1.4; end else - begin //hogy legalább ne látszódjon a modokban //így utólag nézve ez egy trágya megoldás + begin //hogy legalább ne látszódjon a modokban //így utólag nézve ez egy trágya megoldás dnsvec:=d3dxvector3(0, -100, 0); pantheonPos:=d3dxvector3(0, -100, 0); dnsrad:=1; @@ -2092,7 +1835,7 @@ begin Result:=E_FAIL; tmptex:=nil; if Failed(g_pd3dDevice.CreateTexture(CMAP_SIZE, CMAP_SIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, tmptex, nil)) then Exit; - if Failed(g_pd3dDevice.CreateTexture(CMAP_SIZE, CMAP_SIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, mt1, nil)) then Exit; //régi vagy új terep + if Failed(g_pd3dDevice.CreateTexture(CMAP_SIZE, CMAP_SIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, mt1, nil)) then Exit; //régi vagy új terep if Failed(g_pd3dDevice.CreateTexture(CMAP_SIZE, CMAP_SIZE, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, mt2, nil)) then Exit; //minimap @@ -2108,7 +1851,7 @@ begin if not ice then wacol:=D3DXColorFromDWord(stuffjson.GetInt(['color_water'])) else wacol:=D3DXColorFromDWord($FFFFFFFF); wacol.a:=1; //1 - //TODO ezekre már van változó + //TODO ezekre már van változó l1c:=D3DXColorFromDWORD(stuffjson.GetInt(['light', 'color_sun'])); l2c:=D3DXColorFromDWORD(stuffjson.GetInt(['light', 'color_shadow'])); @@ -2283,7 +2026,7 @@ begin //zz:=zz+(round(xx)mod 2)*scalfac/2; - //alap színek + //alap színek red:=grasspeak; // if yy<0 then yy:=0; if (yy > grasslevel+2.25) then @@ -2305,7 +2048,7 @@ begin if (yy < grasslevel+0.45) and (yy >= grasslevel-1.13) then red:=Lerp(sandpeak, grasspeak, clip(0, 1, (yy - (grasslevel-0.75)) / 1.58 + 0.5 * (-0.5 + Frac(perlin.complexnoise(1, xx + 2000, zz, 4, 1, 0.5) * 300)))); if yy < grasslevel-1.13 then red:=sandpeak; //16.2 14.62 if (yy < wetsandlevel+0.75) and (yy >= y_waterend) then red:=Lerp(waterend, sandpeak, (yy - y_waterend) / 1.5); //waterend = vizes homok peak - if yy < y_waterend then red:=Lerp(waterstart, waterend, (yy - y_waterstart) / y_waterstart); //y=10-nél 1 legyen + if yy < y_waterend then red:=Lerp(waterstart, waterend, (yy - y_waterstart) / y_waterstart); //y=10-nél 1 legyen if yy < y_waterstart then red:=waterstart; for m:=0 to length(bubbles) - 1 do //TODO CMAP @@ -2316,7 +2059,7 @@ begin end; - //fények + //fények tmp:=D3DXVec3dot(n, l1); if tmp < 0 then tmp:=0; // D3DXColorscale(lght1,l1c,tmp); @@ -2946,6 +2689,44 @@ begin end; end; +procedure fastinfo(const args: array of const); +begin + scriptsHandler.evalScriptLine('fastinfo ' + VariantUtils.VarRecToStr(args[0])); +end; + +procedure reportBotKills(const args: array of const); +begin + bootkillsendtim := 100 * 60 * 5; + + if (length(multisc.nev) <= 0) then exit; + if (botkills <= 0) then exit; + + sendBotKills([botkills]); + botkills := 0; +end; + +procedure initThreadHandler; +begin + sentryModule.addBreadcrumb(makeBreadcrumb('called initThreadHandler')); + + threadHandlerModule := TThreadHandler.Create; + + fastinfoSaga := TSaga.Create('fastinfo', fastinfo); + threadHandlerModule.addSaga(fastinfoSaga); + + printTopSaga := TSaga.Create('printTop', printTop); + threadHandlerModule.addSaga(printTopSaga); + + printRankSaga := TSaga.Create('printRank', printRank); + threadHandlerModule.addSaga(printRankSaga); + + printKothSaga := TSaga.Create('printKoth', printKoth); + threadHandlerModule.addSaga(printKothSaga); + + reportBotKillsSaga := TSaga.Create('reportBotKills', reportBotkills); + threadHandlerModule.addSaga(reportBotKillsSaga); +end; + function InitializeAll:HRESULT; var pIndices:PWordArray; @@ -2966,11 +2747,18 @@ var label visszobj, visszfegyv; begin + sentryModule.addBreadcrumb(makeBreadcrumb('called initializeAll')); Result:=E_FAIL; enableeffects:=true; laststate:= 'Initializing'; + //TODO: remove + //raise Exception.Create('faszom varja ki amig tolt'); + + laststate := 'Loading ThreadHandler'; + initThreadHandler; + sundir:=D3DXVector3(-1, 1.0, 0); vanLM:=(texture_res >= TEXTURE_MED) or (texture_res = TEXTURE_COLOR); @@ -2987,7 +2775,7 @@ begin gunszin:=stuffjson.GetInt(['color_gun']); techszin:=stuffjson.GetInt(['color_tech']); - setlength(weapons, 6); //minden 0 indexnél üres, mert idióta vagyok + setlength(weapons, 6); //minden 0 indexnél üres, mert idióta vagyok for i:=1 to 5 do begin setlength(weapons[i].col, 10); //getnum meg faszom... @@ -2997,7 +2785,7 @@ begin end; end; - water1col:=stuffjson.GetInt(['weapon', 'WATER', '1']); //vízbe lövünk + water1col:=stuffjson.GetInt(['weapon', 'WATER', '1']); //vízbe lövünk water2col:=stuffjson.GetInt(['weapon', 'WATER', '2']); dustcol:=stuffjson.GetInt(['weapon', 'DUST']); @@ -3105,12 +2893,14 @@ begin agkerekarr[i].y:=stuffjson.GetFloat(['vehicle', 'tech', 'wheels', 'position', i, 'y']); agkerekarr[i].z:=stuffjson.GetFloat(['vehicle', 'tech', 'wheels', 'position', i, 'z']); end; - g_pd3ddevice.GetDeviceCaps(devicecaps); - g_pd3dDevice.SetRenderState(D3DRS_ZENABLE, iTrue); + sentryModule.addBreadcrumb(makeBreadcrumb('muks init')); + g_pd3ddevice.GetDeviceCaps(devicecaps); + g_pd3dDevice.SetRenderState(D3DRS_ZENABLE, iTrue); FAKE_HDR:=D3DTOP_MODULATE; muks:=Tmuksoka.create(g_pd3ddevice); + if muks = nil then begin messagebox(0, 'TMuks.create brutal error', Pchar(lang[30]), 0); @@ -3123,15 +2913,17 @@ begin end; writeln(logfile, 'Loaded stickmen');flush(logfile); + sentryModule.addBreadcrumb(makeBreadcrumb('selfieMaker init')); selfieMaker := TSelfie.Create(muks, myfegyv, myfejcucc, D3DXVector3(cpx^, cpy^, cpz^), szogx, szogy); writeln(logfile, 'Inited selfie maker');flush(logfile); + sentryModule.addBreadcrumb(makeBreadcrumb('bots init')); initbots; writeln(logfile, 'Loaded bots');flush(logfile); setlength(posrads, 0); tmpint:=0; - for i:=0 to stuffjson.GetNum(['terrain_modifiers']) - 1 do //normális modifierek + for i:=0 to stuffjson.GetNum(['terrain_modifiers']) - 1 do //normális modifierek begin tmpbol:=stuffjson.GetBool(['terrain_modifiers', i, 'agressive']); @@ -3159,13 +2951,13 @@ begin if not loadfegyv then exit; writeln(logfile, 'Loaded fegyv');flush(logfile); - if not loadojjektumok then exit; //épületek alatti modifierek + if not loadojjektumok then exit; //épületek alatti modifierek tempmesh:=nil; j:=high(posrads); tmpint:=1; - for i:=0 to stuffjson.GetNum(['terrain_modifiers']) - 1 do //agresszív modifierek + for i:=0 to stuffjson.GetNum(['terrain_modifiers']) - 1 do //agresszív modifierek begin tmpbol:=stuffjson.GetBool(['terrain_modifiers', i, 'agressive']); @@ -3319,7 +3111,7 @@ begin begin if not LTFF(g_pd3dDevice, 'data/textures/grass.jpg', futex, TEXFLAG_COLOR, nil, false) then exit; end; - if not LTFF(g_pd3dDevice, 'data/textures/shadernoise.jpg', hnoise, 0, nil, false) then exit; //shaderes terepen fûre és homokra + if not LTFF(g_pd3dDevice, 'data/textures/shadernoise.jpg', hnoise, 0, nil, false) then exit; //shaderes terepen fûre és homokra if not LTFF(g_pd3dDevice, 'data/textures/sand_02.jpg', homtex, TEXFLAG_COLOR, nil, false) then exit; if not LTFF(g_pd3dDevice, 'data/textures/rock_12.jpg', kotex, TEXFLAG_COLOR, nil, false) then exit; end; @@ -3433,7 +3225,7 @@ begin FillupMenu; - crunchSettings; //tyúklife + crunchSettings; //tyúklife ParticleSystem_Init(g_pd3ddevice); @@ -3593,7 +3385,7 @@ begin laststate:= 'Loading sounds'; writeln(logfile, 'Loading sounds');flush(logfile); - loadsounds; // menu.DrawLoadScreen(85);-tõl 95-ig + loadsounds; // menu.DrawLoadScreen(85);-tõl 95-ig writeln(logfile, 'Initializing succeful');flush(logfile); @@ -3687,7 +3479,7 @@ begin end else - MessageBox(0, 'Benthagyott AI kód', 'Hiba', 0); + MessageBox(0, 'Benthagyott AI kód', 'Hiba', 0); D3DXMatrixMultiply(matb, matb, matWorld2); @@ -3747,7 +3539,7 @@ begin D3DXMatrixTranslation(matWorld, -0.05, 0, 0); end else - MessageBox(0, 'Benttthagyott AI kód', 'Faszom', 0); + MessageBox(0, 'Benttthagyott AI kód', 'Faszom', 0); if (ppl[mi].pos.state and MSTAT_MASK) = 8 then D3DXMatrixTranslation(matWorld, -0.2, 0.2, -0.1); @@ -3884,8 +3676,8 @@ begin virt:=nil; try virt:=virtualalloc(nil, 4, MEM_COMMIT + MEM_RESERVE, PAGE_READWRITE + PAGE_GUARD); - {guard page-es memóriadebug tesztelése} - virt^:=$13370000; {Kiakad, kivéve ha fut a CE} + {guard page-es memóriadebug tesztelése} + virt^:=$13370000; {Kiakad, kivéve ha fut a CE} cpy^:=10000000; except end; @@ -3999,7 +3791,9 @@ var bunkerek:array of TBunker; mytime:TDateTime; minute, dummy:Word; -begin +begin + laststate := 'respawn start'; + mytime:=Time; DecodeTime(mytime, dummy, minute, dummy, dummy); @@ -4079,7 +3873,7 @@ begin tmptav:=tmptav + sqrt(tavpointpoint(tmppos, ppl[p].pos.pos)); end else - begin //csapatra spawnol, meg félig ellenségre + begin //csapatra spawnol, meg félig ellenségre if not D3DXVector3Equal(ppl[p].pos.pos, D3DXVector3Zero) then if ((ppl[p].pls.fegyv xor myfegyv) >= 128) then tmptav:=tmptav + 0.5 * sqrt(tavpointpoint(tmppos, ppl[p].pos.pos)) @@ -4145,6 +3939,8 @@ begin updateterrain; tryupdatefoliage(true); + laststate := 'respawn after update'; + Dine.Reset; hanyszor:=(timegettime div 10) + 1; @@ -4155,6 +3951,8 @@ begin snowballs:=50; meghaltam:=false; + + laststate := 'respawn end'; end; @@ -4336,7 +4134,7 @@ begin // if invulntim>0 then exit; - //hollo:=D3DXVector3(0,3,0); ///BVÁÁÁÁÁÁ + //hollo:=D3DXVector3(0,3,0); ///BVÃÃÃÃÃà hollo:=D3DXVector3(0, -0.10, 0); @@ -4363,7 +4161,7 @@ begin D3DXVec3add(v2, hollo, D3DxVector3(0, 0, -300)); if shoti > 0 then - v2:=vec3add2(v2, randomvec2(random(10000), shoti * 1.6, shoti * 1.6, 0)); //3 golyó, ami messzire megy az pontosabb + v2:=vec3add2(v2, randomvec2(random(10000), shoti * 1.6, shoti * 1.6, 0)); //3 golyó, ami messzire megy az pontosabb D3DXVec3add(hollo, hollo, D3DxVector3(0, 0, -0.7)); @@ -4588,7 +4386,7 @@ begin hDebugObject:=0; Status:=NtQueryInformationProcess($FFFFFFFF, 7, hDebugObject, 4, nil); if (Status = 0) then - if (hDebugObject <> 0) then {windows féle debug handler} + if (hDebugObject <> 0) then {windows féle debug handler} setlength(ppl, 0); {$ENDIF} end; @@ -4676,7 +4474,7 @@ asm jz @josag MOV EAX,1000000 MOV mapmode,EAX - //büntetés + //büntetés @josag: end; @@ -4694,19 +4492,6 @@ begin hudInfoColor:=col; end; - -procedure addHudMessage(input:string;col:longword;f:word = 500); -var - i:byte; -begin - for i:=high(hudMessages) downto low(hudMessages) + 1 do - hudMessages[i]:=hudMessages[i - 1]; - - i:=low(hudMessages); - - hudMessages[i]:=THUDMessage.create(input, col, f); -end; - procedure stepHudMessages; var i:byte; @@ -4752,7 +4537,7 @@ begin else if dine.keyd(DIK_LMENU) and dine.keyd2(DIK_RETURN) and noborder and iswindowed then begin noborder:=false; - SetWindowLong(hWindow, GWL_STYLE, misteryNumber); //ezt valaki más kitalálja + SetWindowLong(hWindow, GWL_STYLE, misteryNumber); //ezt valaki más kitalálja MoveWindow(hWindow, 0, 0, windowrect.Right - windowrect.Left, windowrect.Bottom - windowrect.Top, false); end; @@ -4771,7 +4556,7 @@ begin nemviz:=true; end; - //Új irányítás kód + //Új irányítás kód ds:=sin(szogx); dc:=cos(szogx); px:=0;py:=0; @@ -4784,7 +4569,10 @@ begin else if dine.MousMovScrl > 0 then selfieMaker.zoomlevel := max(selfieMaker.zoomlevelMin, selfieMaker.zoomlevel - 0.1); - if dine.keyprsd(DIK_B) then selfieMaker.dab := not selfieMaker.dab; + if dine.keyprsd(DIK_B) then + begin + selfieMaker.dab := not selfieMaker.dab; + end; end; // TODO @@ -4831,7 +4619,7 @@ begin px:=px * 0.02; py:=py * 0.02; - mstat:=mstat and (MSTAT_GUGGOL + MSTAT_CSIPO); //animáció kikapcs + mstat:=mstat and (MSTAT_GUGGOL + MSTAT_CSIPO); //animáció kikapcs undebug_debugobject; end; @@ -4857,7 +4645,7 @@ begin {$ELSE} if repules then begin - cpox^:=cpox^ + 0.1 * (cpx^ - cpox^); //tehetetlenséd + cpox^:=cpox^ + 0.1 * (cpx^ - cpox^); //tehetetlenséd cpoy^:=cpoy^ + 0.1 * (cpy^ - cpoy^); cpoz^:=cpoz^ + 0.1 * (cpz^ - cpoz^); if dine.keyd(DIK_SPACE) then @@ -5141,7 +4929,7 @@ begin if not ((myfegyv = FEGYV_QUAD) and csipo) or autoban then begin labelactive:=false; - evalscript(displaycloseevent); + scriptsHandler.evalscript(displaycloseevent); if autoban then begin @@ -5968,8 +5756,8 @@ begin cp:=D3DXVector3(cpx^, cpy^, cpz^); - // PROP ÜTKÖZÉS - { ideiglenesen kivéve + // PROP ÜTKÖZÉS + { ideiglenesen kivéve for i:=0 to length(propsystem.objects)-1 do begin iri := propsystem.collision(cp,0.4,cp,i); @@ -5977,7 +5765,7 @@ begin end; {} laststate:= 'Docollisiontests 2'; - //VONAL TESZT ÉS ZÓNATESZT + //VONAL TESZT ÉS ZÓNATESZT vec1:=D3DXVector3(cpx^, cpy^ + 1, cpz^); if not autoban then for l:=0 to high(ojjektumnevek) do @@ -6034,7 +5822,7 @@ begin ojjektumarr[l].NeedKD; traverseKDTree(tmpbb, miket, ojjektumarr[l].KDData, ojjektumarr[l].KDTree, COLLISION_SOLID); ojjektumarr[l].makecurrent(miket); - //gömbök + //gömbök for k:=0 to high(gmbk) do begin if k = 10 then mdst:=fejvst else mdst:=vst; @@ -6075,9 +5863,9 @@ begin laststate:= 'Docollisiontests(false) 4'; - // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK - // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK - // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK + // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK + // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK + // AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK AUTÓK for l:=0 to high(ojjektumnevek) do for i:=0 to ojjektumarr[l].hvszam - 1 do @@ -6117,7 +5905,7 @@ begin // if colltim>=4 then if colltim >= 1 then begin - laststate:= 'Docollisiontests 6a'; //föld + laststate:= 'Docollisiontests 6a'; //föld if advwove(v1.x, v1.z) > v1.y then begin DoLAWRobbanas(i, false, true); @@ -6136,7 +5924,7 @@ begin goto lawskip; end; - laststate:= 'Docollisiontests 6c'; // épület + laststate:= 'Docollisiontests 6c'; // épület for l:=0 to high(ojjektumnevek) do for j:=0 to ojjektumarr[l].hvszam - 1 do @@ -6307,7 +6095,7 @@ begin goto x72skip; end; - if eletkor > 300 then //vagy ez vagy a cél check kell, amúgy bugos + if eletkor > 300 then //vagy ez vagy a cél check kell, amúgy bugos begin Dox72Robbanas(i, false); goto x72skip; @@ -6552,107 +6340,6 @@ begin end; //{$IFEND} -procedure AddLAW(av1, av2:TD3DXvector3;akl:integer); -begin - setlength(lawproj, length(lawproj) + 1); - with lawproj[high(lawproj)] do - begin - v1:=av1; - v2:=av2; - v3:=v2; - name:=XORHash2x12byte(v1, v2); - kilotte:=akl; - eletkor:=0; - end; -end; - -procedure AddNOOB(av1, av2:TD3DXvector3;akl:integer); -begin - setlength(noobproj, length(noobproj) + 1); - with noobproj[high(noobproj)] do - begin - v1:=av1; - v2:=av2; - v3:=v2; - name:=XORHash2x12byte(v1, v2); - kilotte:=akl; - eletkor:=0; - end; -end; - - - -procedure AddX72(av1, av2:TD3DXvector3;akl:integer); -var - tmp1, tmp2:TD3DXVector3; - szog, l:single; -begin - setlength(X72proj, length(X72proj) + 1); - with X72proj[high(X72proj)] do - begin - v1:=av1; - cel:=av2; - d3dxvec3Subtract(v2, av2, av1); - - name:=XORHash2x12byte(av1, av2); - name:=(name + 1) * (name + 2) * (name - 1) * (name - 2) * 134775813; - D3DXVec3Cross(tmp1, v2, D3DXVector3(0, 1, 0)); - D3DXVec3Cross(tmp2, v2, tmp1); - - FastVec3Normalize(tmp1); - FastVec3Normalize(tmp2); - - szog:=((name and $FFFF) / $10000) * D3DX_PI; - - d3dxvec3scale(tmp1, tmp1, cos(szog)); - d3dxvec3scale(tmp2, tmp2, -sin(szog)); - l:=d3dxvec3length(v2); - if l > 0.000001 then - d3dxvec3scale(v2, v2, 1 / l); - d3dxvec3add(v2, v2, tmp1); - d3dxvec3add(v2, v2, tmp2); - d3dxvec3scale(v2, v2, 0.005 * l); - - d3dxvec3subtract(v2, v1, v2); - - v3:=v2; - kilotte:=akl; - eletkor:=0; - end; -end; - -procedure AddH31_G(av1, av2:TD3DXvector3;akl:integer); -begin - setlength(h31_gproj, length(h31_gproj) + 1); - with h31_gproj[high(h31_gproj)] do - begin - D3DXvec3subtract(v1, av2, av1); - D3DXvec3normalize(v1, v1); - D3DXvec3add(v1, v1, av1); - v2:=av1; - v3:=v2; - name:=XORHash2x12byte(v1, v2); - kilotte:=akl; - eletkor:=0; - end; -end; - -procedure AddH31_T(av1, av2:TD3DXvector3;akl:integer); -begin - setlength(h31_tproj, length(h31_tproj) + 1); - with h31_tproj[high(h31_tproj)] do - begin - D3DXvec3subtract(v1, av2, av1); - D3DXvec3normalize(v1, v1); - D3DXvec3add(v1, v1, av1); - v2:=av1; - v3:=v2; - name:=XORHash2x12byte(v1, v2); - kilotte:=akl; - eletkor:=0; - end; -end; - procedure handleHDR; var @@ -6673,7 +6360,7 @@ begin constraintvec(vec0); vec1:=vec0;vec1.y:=vec1.y + 100; - mennyit:=3; //ennyit bök elõre + mennyit:=3; //ennyit bök elõre wide:=1.5; if ((myfegyv = FEGYV_M82A1) or (myfegyv = FEGYV_HPL)) and not csipo then @@ -6695,7 +6382,7 @@ begin begin if felesHDR then i:=a else i:=a + 2; - HDRarr[i, HDRScanline]:=round(255 * 0.6); //a 0.4 lentebbrõl a vágási határ + HDRarr[i, HDRScanline]:=round(255 * 0.6); //a 0.4 lentebbrõl a vágási határ for k:=0 to high(ojjektumnevek) do for j:=0 to ojjektumarr[k].hvszam - 1 do begin @@ -6729,11 +6416,11 @@ begin HDRincit:=5000; {$ENDIF} - // lightness:=clip(0,0.4,HDRincit/8160)/0.4; // a világosakat eldobjuk - lightness:=clip(0.01, 1, HDRincit / 8160 / 0.5); // a világosakat eldobjuk + // lightness:=clip(0,0.4,HDRincit/8160)/0.4; // a világosakat eldobjuk + lightness:=clip(0.01, 1, HDRincit / 8160 / 0.5); // a világosakat eldobjuk // hdrgoal:=1+(1-lightness)*1.8; - // hdrpref:=0.8; //todo csúszka izébe + // hdrpref:=0.8; //todo csúszka izébe hdrgoal:=clip(1, 4, (1 / lightness) * hdrpref); // writechat(formatfloat('0.####',hdrgoal)); @@ -6944,8 +6631,8 @@ begin atav:=tavpointpointsq(from, d3dxvector3(cpx^, cpy^, cpz^)); if (atav < sqr(vis * opt_particle)) and ((hanyszor and period) = period) and (not disabled) then begin - //jöhet a rajzolás - chance:=opt_particle / PARTICLE_MAX; //ez már csak fallback, ha megváltozna valami + //jöhet a rajzolás + chance:=opt_particle / PARTICLE_MAX; //ez már csak fallback, ha megváltozna valami if (opt_particle=PARTICLE_MAX) then chance:=1; @@ -7021,33 +6708,6 @@ begin menu.DrawMultilineText(labeltext, 0.3, 0.3, 0.7, 0.7, 1, $FFFFFFFF); end; -procedure handletimedscripts; -var - i, j, n:integer; - now:cardinal; -begin - n:=length(timedscripts); - now:=GetTickCount; - - for i:=0 to n - 1 do - begin - if timedscripts[i].time < now then - begin - evalscript(timedscripts[i].script); - end; - end; - - for i:=0 to length(timedscripts) - 1 do - begin - if timedscripts[i].time < now then - begin - for j:=i to length(timedscripts) - 2 do - timedscripts[j]:=timedscripts[j + 1]; - SetLength(timedscripts, length(timedscripts) - 1); - end; - end; -end; - procedure handletriggers; var i, j, n:integer; @@ -7086,15 +6746,15 @@ begin begin if (not touched) then begin - evalscriptline('$thistrigger = ' + name); - evalScript(ontouchscript); + scriptsHandler.evalscriptline('$thistrigger = ' + name); + scriptsHandler.evalScript(ontouchscript); touched:=true; end; if (usebutton) then begin - evalscriptline('$thistrigger = ' + name); - evalScript(onusescript); + scriptsHandler.evalscriptline('$thistrigger = ' + name); + scriptsHandler.evalScript(onusescript); end; end @@ -7102,8 +6762,8 @@ begin begin if touched then begin - evalscriptline('$thistrigger = ' + name); - evalscript(onleavescript); + scriptsHandler.evalscriptline('$thistrigger = ' + name); + scriptsHandler.evalscript(onleavescript); end; touched:=false; end @@ -7139,8 +6799,8 @@ begin begin if (not touched) then begin - evalscriptline('$thistrigger = ' + name); - evalScript(ontouchscript); + scriptsHandler.evalscriptline('$thistrigger = ' + name); + scriptsHandler.evalScript(ontouchscript); touched:=true; end; end @@ -7148,8 +6808,8 @@ begin begin if touched then begin - evalscriptline('$thistrigger = ' + name); - evalscript(onleavescript); + scriptsHandler.evalscriptline('$thistrigger = ' + name); + scriptsHandler.evalscript(onleavescript); end; touched:=false; end @@ -7441,7 +7101,8 @@ begin if not bots_enabled then exit; for groupIndex := low(botGroupArr) to high(botGroupArr) do for botIndex := low(botGroupArr[groupIndex].bots) to high(botGroupArr[groupIndex].bots) do - botGroupArr[groupIndex].bots[botIndex].collideProjectile(loves); + if (botGroupArr[groupIndex].bots[botIndex].collideProjectile(loves)) then + botkills := botkills + 1; end; procedure renderbots; @@ -7639,11 +7300,11 @@ begin begin tmp4:=randomvec2(animstat * 2 + j * 3, 0.3 * aauto.getseb, aauto.getseb + 0.04, 0.3 * aauto.getseb); d3dxvec3add(tmp3, aauto.getmotionvec, tmp4); - D3DXVec3Lerp(tmp3, tmp3, tmp4, Random(101) / 100); //random vs random + mozgás vektor //tmp4 vége - tmp4:=D3DXVector3(0, 0, 2 * aauto.kerekvst * ((hanyszor mod 2) - 0.5)); //ne a kerék szélén legyen, hanem a közepén + D3DXVec3Lerp(tmp3, tmp3, tmp4, Random(101) / 100); //random vs random + mozgás vektor //tmp4 vége + tmp4:=D3DXVector3(0, 0, 2 * aauto.kerekvst * ((hanyszor mod 2) - 0.5)); //ne a kerék szélén legyen, hanem a közepén D3DXVec3TransformCoord(tmp4, tmp4, aauto.kerektransformmatrix(hanyszor mod 4)); - d3dxvec3add(tmp4, tmp4, randomvec2(animstat * 2 + j * 3, 0.5 * aauto.kerekvst, 2 * aauto.kereknagy, 0.5 * aauto.kerekvst)); //egyéb random hely - tmpfloat1:=random(1001) / 1000; //méret és súly + d3dxvec3add(tmp4, tmp4, randomvec2(animstat * 2 + j * 3, 0.5 * aauto.kerekvst, 2 * aauto.kereknagy, 0.5 * aauto.kerekvst)); //egyéb random hely + tmpfloat1:=random(1001) / 1000; //méret és súly Particlesystem_add(GravityparticleCreate(tmp4, tmp3, tmpfloat1 * 0.25 + 0.012, tmpfloat1 * 0.10 + 0.005, 0.2 + tmpfloat1 * 0.1, colorlerp(col_mud, col_grass, Random(3) / 2), 0, random(100) + 170, TX_HOMALY)); end; for j:=0 to round((((Random(1000) + 1) / 1000) + opt_particle / PARTICLE_MAX) * 10) do @@ -7784,7 +7445,7 @@ begin laststate:= 'Doing Real Physics'; - //Saját fizika + //Saját fizika iranyithato:=false; docollisiontests; @@ -7825,7 +7486,7 @@ begin if eses and (opt_particle > 0) then begin ppos:=D3DXVector3(cpx^, cpy^, cpz^); - if (felho.coverage > 5) and (ppos.y < 15) and (ppos.y > 10.35) then //parton + nincs esõ + if (felho.coverage > 5) and (ppos.y < 15) and (ppos.y > 10.35) then //parton + nincs esõ begin col:=col_dust_sand; for i:=0 to 20 * opt_particle do @@ -7834,7 +7495,7 @@ begin Particlesystem_add(GravityparticleCreate(ppos, tmp, random(10) / 60 + 0.03, 0.1, 0.08, col, 0, random(100) + 170)); end; end - else if (felho.coverage <= 5) and (ppos.y >= 15) then //földön + esõ + else if (felho.coverage <= 5) and (ppos.y >= 15) then //földön + esõ begin col:=col_mud; for i:=0 to 20 * opt_particle do @@ -7843,7 +7504,7 @@ begin Particlesystem_add(GravityparticleCreate(ppos, tmp, random(5) / 60 + 0.02, 0.05, 0.18, col, 0, random(100) + 170)); end; end - else if (ppos.y<(10.1 + singtc / 10)) then //vízben + else if (ppos.y<(10.1 + singtc / 10)) then //vízben begin col:=water1col; //logic for i:=0 to 30 * opt_particle do @@ -7884,7 +7545,7 @@ begin else iranyithato:=true; if tulnagylokes then iranyithato:=false; - //PLR fizikája + //PLR fizikája {$IFNDEF repkedomod} if not iranyithato then begin @@ -7910,7 +7571,7 @@ begin if playrocks < 0 then playrocks:=0; laststate:= 'Doing Real Physics 2'; - //Egyéb plr cucc + //Egyéb plr cucc if (cpy^ < waterlevel) and ((mstat and MSTAT_MASK) > 0) and ((mstat and MSTAT_MASK) < 6) then vizben:=vizben + 0.01 @@ -7944,7 +7605,7 @@ begin handlelabels; handletriggers; handleleavetriggers; - handletimedscripts; + scriptsHandler.handletimedscripts; propsystem.updatedynamic; if multisc.atrak then @@ -8020,7 +7681,7 @@ begin begin cpx^:=(cpx^ * 19 + rongybabak[rbid].gmbk[5].x) / 20; //ingadozik minta kvantum XD - cpy^:=(cpy^ * 19 + rongybabak[rbid].gmbk[5].y) / 20; //ki kell egynlíteni + cpy^:=(cpy^ * 19 + rongybabak[rbid].gmbk[5].y) / 20; //ki kell egynlíteni cpz^:=(cpz^ * 19 + rongybabak[rbid].gmbk[5].z) / 20; cpox^:=(cpox^ * 19 + cpx^) / 20; //damp cpoy^:=(cpoy^ * 19 + cpy^) / 20; @@ -8127,7 +7788,7 @@ begin else mszogy:=mszogy + sin(animstat * 2 * D3DX_PI) / 400; if ((mstat and MSTAT_MASK) = 5) then - begin //animstat kiteljsített formában + begin //animstat kiteljsített formában mszogx:=mszogx + sin(animstat * 2 * D3DX_PI) / 50; mszogy:=mszogy + sin(animstat * 4 * D3DX_PI) / 200; end; @@ -8217,7 +7878,7 @@ end; multisc.Medal('U', 'L'); - // nézzük a beérkezett medálokat + // nézzük a beérkezett medálokat if (multisc.medallist[0] <> '') and (menu.medalanimstart = 0) then begin LTFF(g_pd3dDevice, 'data/textures/medals/' + multisc.medallist[0] + '.png', menu.medaltex, 0, nil, false); @@ -8270,7 +7931,7 @@ end; inc(colltim); inc(eletkor); tmp:=v1; - //gyorsuló + //gyorsuló v1.x:=(v1.x - v2.x) * 1.0215 + v1.x; v1.y:=(v1.y - v2.y) * 1.0215 + v1.y; @@ -8383,7 +8044,7 @@ end; end; end; - //lövedékek + //lövedékek for i:=0 to high(h31_tproj) do with h31_tproj[i] do @@ -8473,6 +8134,13 @@ end; if invulntim = 0 then showHudInfo('', 0, 0); end; + + if bootkillsendtim <> 0 then + begin + dec(bootkillsendtim); + if bootkillsendtim = 0 then + threadHandlerModule.call('reportBotKills', []); + end; // if latszonaKL>0 then dec(latszonaKL); /// UNTIL @@ -8611,7 +8279,7 @@ end; //0 TECH //12 killing spreek //18 GUN //32 killing spreek - //Haláli rádiók :P + //Haláli rádiók :P if opt_taunts and tauntvolt then begin @@ -8767,7 +8435,7 @@ end; procedure handlefizikVEGE; begin - // üres, csak könyvjelzõ; + // üres, csak könyvjelzõ; end; {$ENDIF} @@ -8847,7 +8515,7 @@ begin if cooldown < random(100) / 100 then begin - //ZÕD + //ZÕD rnd:=0; for i:=0 to 9 do begin @@ -8888,7 +8556,7 @@ begin particlesystem_Add(fenycsikcreate(v1, v2, 0.005, weapons[2].col[8], 1)); end; - //FEHÉR + //FEHÉR rnd:=0; for i:=0 to 9 do @@ -9117,11 +8785,11 @@ var {$ENDIF} begin {$IFDEF undebug} - {windows féle debug kiiktatása} + {windows féle debug kiiktatása} virt:=nil; try virt:=virtualalloc(nil, 4, MEM_COMMIT + MEM_RESERVE, PAGE_NOACCESS); - {noacces-es memóriadebug tesztelése} + {noacces-es memóriadebug tesztelése} virt^:=$13370000; cpy^:=10000000; except @@ -9180,7 +8848,7 @@ begin else stopSound(15, 25); - //Legközelebbi 3 + //Legközelebbi 3 for i:=0 to high(sorrend) do begin @@ -9237,7 +8905,7 @@ begin end; - //Rakéták + //Rakéták for i:=0 to 2 do begin @@ -9245,7 +8913,7 @@ begin sortav[i]:=100000; end; - //Legközelebbi 3 + //Legközelebbi 3 for i:=0 to high(lawproj) do begin tt:=tavpointpointsq(lawproj[i].v1, hol); @@ -9278,7 +8946,7 @@ begin else StopSound(16, i); - //Noobgolyók + //Noobgolyók for i:=0 to 2 do begin @@ -9286,7 +8954,7 @@ begin sortav[i]:=100000; end; - //Legközelebbi 6 + //Legközelebbi 6 for i:=0 to high(noobproj) do begin tt:=tavpointpointsq(noobproj[i].v1, hol); @@ -9321,7 +8989,7 @@ begin //Humi - //Legközelebbi 3 + //Legközelebbi 3 for i:=0 to 2 do begin sorrend[i]:= -1; @@ -9477,9 +9145,9 @@ begin end else StopSound(56, i); - end; //probably át kéne írni ezt négyet egy for loopba + end; //probably át kéne írni ezt négyet egy for loopba - //Player mozgás + //Player mozgás if (playrocks > 0) and (halal = 0) then begin @@ -9531,7 +9199,7 @@ begin laststate:= 'CommitDeferredSoundstuff'; CommitDeferredSoundStuff; - laststate:= 'HandleDS vége'; + laststate:= 'HandleDS vége'; end; @@ -10582,14 +10250,14 @@ begin if vegeffekt > 256 then begin menu.g_psprite.Flush; menu.g_psprite.SetTransform(identmatr); - menu.DrawText('Stickman Atlantis: Egy elveszett város Letölthetõ a honlapról!', + menu.DrawText('Stickman Atlantis: Egy elveszett város Letölthetõ a honlapról!', 0.1, 0.4, 0.9, 0.8, 1, $02000000 * cardinal(min(vegeffekt - 256, 127)) + $000066FF); nohud:=true; end; if vegeffekt > 750 then begin gobacktomenu:=true; - kickmsg:= 'Stickman Atlantis: Egy elveszett város Letölthetõ a honlapról!'; + kickmsg:= 'Stickman Atlantis: Egy elveszett város Letölthetõ a honlapról!'; hardkick:=true; end; @@ -10659,7 +10327,7 @@ begin // emberek fej feletti nevei - // és chatbubi + // és chatbubi for i:=0 to high(ppl) do begin @@ -10833,7 +10501,7 @@ begin //txt:=FloatToStr(szogy); //menu.DrawSzinesChat(txt,0.3,mag+0.05,1,0.29,$FF000000+betuszin); - txt:=#17#128 + inttostr(zonaellen) + #17#32 + ' / ' + inttostr(zonabarat); //ellenségek és barátok száma + txt:=#17#128 + inttostr(zonaellen) + #17#32 + ' / ' + inttostr(zonabarat); //ellenségek és barátok száma menu.DrawSzinesChat(txt, 0.9, mag + 0.075, 1, 0.31, $FF000000 + betuszin); @@ -10905,7 +10573,7 @@ begin menu.drawtext(mp3stationname, 0, 0.85, 0.4, 0.9, 1, $FF000000 + betuszin); //d3dxvec3length(tmp)*360) menu.drawtext(inttostr(round(tegla.pillspd * 360)) + 'Km/h ', 0, 0.9, 0.4, 1, 2, $FF000000 + betuszin); // +inttostr(tegla.shift) + ': ' + inttostr(round(tegla.fordulatszam*1000)) - // sebesség, fordulatszám + // sebesség, fordulatszám if tegla.axes[2].y < 0 then begin if latszonazR > 1 then dec(latszonazR) else @@ -11039,7 +10707,7 @@ begin { for i:=0 to 10 do menu.drawtext(inttostr(i)+':'+inttostr(microprofile[i]),0.3,0.1+i/20,0.5,0.2+i/20,0,$FFFF0000); } - //Ezt a végére, mert matrix-flush-baszakodás van benne + //Ezt a végére, mert matrix-flush-baszakodás van benne for i:=0 to high(ac) do if (ap[i].y - ap2[i].y) < 1 then ac[i]:= ''; @@ -11048,7 +10716,7 @@ begin menu.DrawChatsInGame(ac, ap, aa); - //Ez is flush-baszakodós + //Ez is flush-baszakodós if dine.keyd(DIK_TAB) then begin @@ -11135,7 +10803,7 @@ begin else if multisc.kihivszam > 0 then //multisc.kihivas <> nil begin - // 1v1 kihívós menü + // 1v1 kihívós menü dec(multisc.kihivszam); menu.DrawRect(0.70, 0.92, 0.98, 0.985, $A0000000); menu.g_psprite.Flush; @@ -12053,7 +11721,7 @@ begin g_pd3dDevice.SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); - //közel + //közel if not (cpy^ > 150) then if useoldterrain then begin @@ -12112,7 +11780,7 @@ begin g_pd3dDevice.SetRenderState(D3DRS_ALPHABLENDENABLE, iFalse); - DrawLvl((cpy^ > 150)); //táv + DrawLvl((cpy^ > 150)); //táv g_pd3dDevice.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); @@ -12136,7 +11804,7 @@ begin initojjektumok(g_pd3ddevice, FAKE_HDR); g_pd3dDevice.SetRenderState(D3DRS_CULLMODE, D3DCULL_CW); g_pd3dDevice.SetRenderState(D3DRS_TEXTUREFACTOR, $FF5050FF); - //Shaderek nélkül. + //Shaderek nélkül. g_pd3ddevice.SetTransform(D3DTS_TEXTURE1, identmatr); g_pd3ddevice.SetTransform(D3DTS_TEXTURE0, identmatr); @@ -12270,7 +11938,7 @@ begin checksum:=checksum + (Pdword(addr)^); if checksum = 0 then exit; - // Ezért überbünti jár. Viszlát stack. + // Ezért überbünti jár. Viszlát stack. asm MOV ECX,-1 MOV EDI,ESP //REP STOSD @@ -12415,7 +12083,7 @@ begin } //{ - //QPC ~1µs + //QPC ~1µs //TODO replace with StopWatch in Delphi 10 QueryPerformanceCounter(QPC_stop); elapsedTime:=(QPC_stop-QPC_start)/QPC_frequency; @@ -12454,7 +12122,7 @@ begin else (if lightIntensity > 0 then lightIntensity:=max(0, lightIntensity - 0.04)); - //hát, ez elõre kell. pont. + //hát, ez elõre kell. pont. if (opt_water > 0) and (not ice) and (waterlevel < 20) then Renderreflectiontex; @@ -12534,7 +12202,7 @@ begin begin - //KÖZELI fû + //KÖZELI fû if useoldterrain then begin @@ -12552,7 +12220,7 @@ begin g_pd3dDevice.SetTexture(0, kotex); g_pd3dDevice.SetTexture(1, noisetex); - //KÖZELI szikla + //KÖZELI szikla DrawSplat(splatinds[0], splatinds[1]); end @@ -12623,7 +12291,7 @@ begin // g_pd3dDevice.SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_CLAMP); // g_pd3dDevice.SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP); // g_pd3dDevice.SetRenderState(D3DRS_ALPHABLENDENABLE, iFalse); - //// TÁVOLI TEREP + //// TÃVOLI TEREP g_pd3dDevice.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1); g_pd3dDevice.SetIndices(g_pIBlvl2); @@ -12671,7 +12339,7 @@ begin g_pd3dDevice.SetRenderState(D3DRS_ALPHATESTENABLE, iTrue); g_pd3ddevice.SetRenderState(D3DRS_ALPHAREF, $5); - //noiseal szorzott távoli, nem kell + //noiseal szorzott távoli, nem kell // DrawLvl((cpy^>150)); g_pd3dDevice.SetRenderState(D3DRS_ALPHABLENDENABLE, iFalse); g_pd3dDevice.SetRenderState(D3DRS_ALPHATESTENABLE, iFalse); @@ -12689,7 +12357,7 @@ begin g_pd3dDevice.SetRenderState(D3DRS_AMBIENT, $FFFFFFFF); - // a bubblékat is ki kéne raj-zolni + // a bubblékat is ki kéne raj-zolni laststate:= 'Rendering Stickman and ragdolls'; @@ -12706,7 +12374,7 @@ begin setupidentmatr; laststate:= 'setupidentmatr'; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... begin if (halal = 0) and (not autoban) and (not kulsonezet) and (mapmode = 0) then if (csipo) or ((myfegyv <> FEGYV_M82A1) and (myfegyv <> FEGYV_HPL)) then @@ -12755,7 +12423,7 @@ begin g_pd3ddevice.SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_ALWAYS); g_pd3dDevice.SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2); g_pd3ddevice.Settexture(0, mt1); - //MUKSÓKÁK VÉGE + //MUKSÓKÃK VÉGE g_pd3dDevice.SetRenderState(D3DRS_LIGHTING, iTrue); g_pd3dDevice.SetRenderState(D3DRS_AMBIENT, $FF606060); @@ -12781,7 +12449,7 @@ begin g_pd3dDevice.SetRenderState(D3DRS_AMBIENT, ambientszin); - end; //Menübõl nemkéne vége + end; //Menübõl nemkéne vége laststate:= 'Rendering bunker and stuff'; @@ -12806,7 +12474,7 @@ begin //g_pd3dDevice.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_SELECTARG1); g_pd3dDevice.SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... begin setupmyfegyvmatr; if not kulsonezet then @@ -12885,7 +12553,7 @@ begin noobmesh.DrawSubset(0); end; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... begin g_pd3dDevice.SetRenderState(D3DRS_TEXTUREFACTOR, $FFFF5050); for i:=0 to high(noobproj) do @@ -12922,7 +12590,7 @@ begin for i:=0 to Length(foliages) - 1 do begin - if not (foliages[i].level > 2) and not tallgrass then continue; //fû és kikapcsolva van + if not (foliages[i].level > 2) and not tallgrass then continue; //fû és kikapcsolva van foliages[i].init; foliages[i].render; end; @@ -12978,7 +12646,7 @@ begin laststate:= 'Rendering Alpha stuff (fegyv)'; fegyv.preparealpha; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... begin if not (((myfegyv = FEGYV_M82A1) or (myfegyv = FEGYV_HPL)) and (not csipo)) then @@ -13016,7 +12684,7 @@ begin setupidentmatr; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... if not (enableeffects and (opt_postproc > 0)) then begin if (opt_radar) then begin @@ -13067,7 +12735,7 @@ begin SetupLights; SetupMatrices(false); - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... if (G_peffect <> nil) and (opt_postproc >= POSTPROC_SNIPER) then begin @@ -13117,7 +12785,7 @@ begin end; end; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... if (G_peffect <> nil) and (opt_greyscale) then if (halal <> 0) and (spectate = 0) then begin @@ -13167,7 +12835,7 @@ begin end; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... if (G_peffect <> nil) and (opt_motionblur) then if autoban or ((rezg > 0) and (robhely.y <> 0) and (robhely.x <> 0)) then if halal = 0 then @@ -13233,14 +12901,14 @@ begin g_pd3ddevice.SetRenderState(D3DRS_FOGENABLE, itrue); g_pd3dDevice.SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... renderautok(true); g_pd3dDevice.SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW); setupidentmatr; - if (menu.lap = -1) then //MENÜBÕL nem kéne... + if (menu.lap = -1) then //MENÜBÕL nem kéne... begin setupmyfegyvprojmat; if (myfegyv = FEGYV_NOOB) and not nofegyv and not kulsonezet and (not autoban) and (halal = 0) then @@ -13348,7 +13016,7 @@ end; procedure undebug_untrace; -asm //minimális tudással szemet szúr +asm //minimális tudással szemet szúr {$IFNDEF undebug} ret {$ENDIF undebug} @@ -14205,995 +13873,38 @@ begin end; -procedure evalScript(name:string); +procedure handleparancsok(var mit:String); var - i, j, n, m:integer; -begin - if name = '' then exit; - - scriptdepth:=0; - scriptevaling[scriptdepth]:=true; - - n:=Length(scripts); - for i:=0 to n - 1 do + tmp: string; + i:integer; + {$IFDEF propeditor} + j, k:integer; + {$ENDIF} begin - if scripts[i].name = name then - begin - m:=Length(scripts[i].instructions); - actualscript:=name; - for j:=0 to m - 1 do - begin - actualscriptline:=j + 1; - evalscriptline(scripts[i].instructions[j]); - end; + { + if pos(' /practice', mit) = 1 then + mit:= ' /join Practice-' + inttohex(random(35536), 4); + } + if pos(' /nohud', mit) = 1 then + nohud:= not nohud; - scriptdepth:=0; - scriptevaling[scriptdepth]:=true; + if pos(' /bot', mit) = 1 then + bots_enabled:= not bots_enabled; - exit; - end; - end; -end; + //if pos(' /activate portalevent code:12.11.16', mit) = 1 then + //portalevent.phs:=1; -function getVecVar(name:string):TD3DXVector3; -var - i, n:integer; -begin - n:=length(vecVars); - result:=D3DXVector3Zero; - for i:=0 to n - 1 do - if vecVars[i].name = name then - begin - result:=vecVars[i].pos; - exit; - end; - multisc.chats[addchatindex].uzenet:= 'No such vector variable: ' + name; - addchatindex:=addchatindex + 1; -end; + if pos(' /nofegyv', mit) = 1 then + nofegyv:= not nofegyv; -function getNumVar(name:string):single; -var - i, n:integer; -begin - n:=length(numVars); - result:=0; - for i:=0 to n - 1 do - if numVars[i].name = name then - begin - result:=numVars[i].num; - exit; - end; - multisc.chats[addchatindex].uzenet:= 'No such numeric variable: ' + name; - addchatindex:=addchatindex + 1; -end; + if pos(' /sniper', mit) = 1 then + coordsniper:=true; + if pos(' /fps', mit) = 1 then + opt_drawfps:= not opt_drawfps; -procedure scripterror(text:string); -begin - writeln(logfile, text, ' in ', actualscript, ' : ', actualscriptline); -end; - -function compute(words:TStringArray):TSingleArray; -var - i, j, n:integer; - tmp:TD3DXVector3; - error:Integer; - numnum, varnum:integer; - nums, vars:array[0..2] of single; - operator:char; - value:single; - r:TSingleArray; - begin - // ! a vektor változó - // % a szám változó - - n:=length(words) + 1; - SetLength(words, n); - words[n - 1]:= '//'; - - for i:=0 to n - 1 do - if words[i][1] = '!' then - begin - tmp:=getVecVar(copy(words[i], 2, length(words[i]) - 1)); - - SetLength(words, n + 2); - n:=n + 2; - if i <> n - 2 then - for j:=n - 1 downto i + 3 do - words[j]:=words[j - 2]; - words[i]:=FloatToStr(tmp.x); - words[i + 1]:=FloatToStr(tmp.y); - words[i + 2]:=FloatToStr(tmp.z); - - end else - if words[i][1] = '%' then - words[i]:=FloatToStr(getNumVar(copy(words[i], 2, length(words[i]) - 1))); - - //számoljunk, most hogy nincsenek változók - numnum:=0; - varnum:=0; - operator:= ' '; - for i:=0 to n - 1 do - begin - - val(words[i], value, error); - - if error = 0 then - begin //szám! - - inc(numnum); //számoljuk hány szám jön egymás után - - if numnum > 3 then - begin - scripterror('Unexpected fourth number: ' + words[i]); - exit; - end; - - nums[numnum - 1]:=value; - - end - else - begin - - if (operator<> ' ') then // az operátorok mûködése - begin - if (numnum = 1) and (varnum = 1) then - begin - if operator = '+' then vars[0]:=vars[0] + nums[0]; - if operator = '-' then vars[0]:=vars[0] - nums[0]; - if operator = '*' then vars[0]:=vars[0] * nums[0]; - if operator = '/' then vars[0]:=vars[0] / nums[0]; - end else - if (numnum = 3) and (varnum = 1) then - begin - if operator = '+' then - begin - scripterror('Single and vector addition');exit end; - if operator = '-' then - begin - scripterror('Single and vector substraction');exit end; - if operator = '*' then - begin - vars[0]:=vars[0] * nums[0];vars[1]:=vars[0] * nums[1];vars[2]:=vars[0] * nums[2]; end; - if operator = '/' then - begin - vars[0]:=vars[0] / nums[0];vars[1]:=vars[0] / nums[1];vars[2]:=vars[0] / nums[2]; end; - end else - if (numnum = 1) and (varnum = 3) then - begin - if operator = '+' then - begin - scripterror('Single and vector addition');exit end; - if operator = '-' then - begin - scripterror('Single and vector substraction');exit end; - if operator = '*' then - begin - vars[0]:=vars[0] * nums[0];vars[1]:=vars[1] * nums[0];vars[2]:=vars[2] * nums[0]; end; - if operator = '/' then - begin - scripterror('Vector and single division');exit end; - end else - if (numnum = 3) and (varnum = 3) then - begin - if operator = '+' then - begin - vars[0]:=vars[0] + nums[0];vars[1]:=vars[1] + nums[1];vars[2]:=vars[2] + nums[2]; end; - if operator = '-' then - begin - vars[0]:=vars[0] - nums[0];vars[1]:=vars[1] - nums[2];vars[2]:=vars[2] - nums[2]; end; - if operator = '*' then - begin - vars[0]:=vars[0] * nums[0];vars[1]:=vars[1] * nums[1];vars[2]:=vars[2] * nums[2]; end; - if operator = '/' then - begin - vars[0]:=vars[0] / nums[0];vars[1]:=vars[1] / nums[1];vars[2]:=vars[2] / nums[2]; end; - end else - - - end - else - begin - if (numnum = 1) then begin vars[0]:=nums[0];varnum:=1 end else - if (numnum = 3) then begin vars[0]:=nums[0];vars[1]:=nums[1];vars[2]:=nums[2];varnum:=3 end; - end; - - if (words[i] = '+') or (words[i] = '-') or (words[i] = '*') then - begin - if (numnum = 0) or (numnum = 2) then - begin - scripterror('Unexpected operator: ' + words[i]); - exit; - end; - - operator:=words[i][1]; - numnum:=0; - - end - else - if (words[i] = '//') then //vége! - begin - SetLength(r, 3); - r[0]:=vars[0]; - r[1]:=vars[1]; - r[2]:=vars[2]; - result:=r; - end - else - begin - scripterror('Syntax error: ' + words[i]); - exit; - end; - end; - end; - - end; - - function computevecs(words:array of string):TD3DXVector3; - var - tmp:TSingleArray; - tmp2:TStringArray; - i, n:integer; - begin - - n:=length(words); - setLength(tmp2, n); - for i:=0 to n - 1 do - tmp2[i]:=words[i]; - - tmp:=compute(tmp2); - Result:=D3DXVector3(tmp[0], tmp[1], tmp[2]); - end; - - function computenums(words:array of string):single; - var - tmp:TSingleArray; - tmp2:TStringArray; - i, n:integer; - begin - - n:=length(words); - setLength(tmp2, n); - for i:=0 to n - 1 do - tmp2[i]:=words[i]; - - tmp:=compute(tmp2); - Result:=tmp[0]; - end; - - function varToString(input:string):string; - var - i, n:integer; - varname:string; - begin - result:=input; - if length(input) < 2 then exit; - if input[1] = '%' then - begin - varname:=copy(input, 2, length(input) - 1); - n:=Length(numVars); - for i:=0 to n - 1 do - if numVars[i].name = varname then - begin - result:=FormatFloat('0.####', numVars[i].num); - exit; - end; - end - else - if input[1] = '!' then - begin - varname:=copy(input, 2, length(input) - 1); - n:=Length(vecVars); - for i:=0 to n - 1 do - if vecVars[i].name = varname then - begin - result:=FloatToStr(vecVars[i].pos.x) + ', ' + FloatToStr(vecVars[i].pos.y) + ', ' + FloatToStr(vecVars[i].pos.z); - exit; - end; - end - else - if input[1] = '$' then - begin - if input = '$_' then begin result:= ' ';exit; end; - if input = '$NL' then begin result:=AnsiString(#13#10);exit; end; - varname:=copy(input, 2, length(input) - 1); - n:=Length(strVars); - for i:=0 to n - 1 do - if strVars[i].name = varname then - begin - result:=strVars[i].text; - exit; - end; - end - end; - - procedure varCompare(args:array of string); - var - argnum, i, j:integer; - v1, v2:single; - truth:boolean; - op:string; - a, b:TStringArray; - begin - argnum:=length(args); - //find the comparator - for i:=0 to argnum - 1 do - if (args[i] = '=') or (args[i] = '>') or (args[i] = '<') or (args[i] = '<>') or (args[i] = '>=') or (args[i] = '<=') then - begin - op:=args[i]; - SetLength(a, i); - SetLength(b, argnum - i - 1); - - for j:=0 to i - 1 do - a[j]:=args[j]; - - for j:=0 to argnum - i - 2 do - b[j]:=args[i + 1 + j]; - - v1:=compute(a)[0]; - v2:=compute(b)[0]; - truth:=false; - - if (op = '=') then - begin if (v1 = v2) then truth:=true; end - else - if (op = '<') then - begin if (v1 < v2) then truth:=true; end - else - if (op = '>') then - begin if (v1 > v2) then truth:=true; end - else - if (op = '!=') then - begin if (v1 <> v2) then truth:=true; end - else - if (op = '<=') then - begin if (v1 <= v2) then truth:=true; end - else - if (op = '>=') then - if (v1 >= v2) then truth:=true; - - inc(scriptdepth); - scriptevaling[scriptdepth]:=truth; - - exit; - end; - end; - - procedure evalscriptline(line:string); - var - args:array of string; - len, i, j, argnum,k,l:integer; - tmp:string; - v1:single; - t:char; - vec1,vec2:TD3DXVector3; - a:TStringArray; - b:Cardinal; - testmuks:Tplayer; - HTTPClient: TIdHTTP; - postData: TIdMultipartFormDataStream; - response:string; - begin - - //bontsuk szavakra, és tegyük egy args arraybe - len:=Length(line); - j:=0; - SetLength(args, 1); - - for i:=1 to len do begin - if (line[i] = ' ') then - begin - if ((Length(args[j]) > 0)) then - begin - inc(j); - SetLength(args, j + 1); - end; - end - else - begin - args[j]:=args[j] + line[i]; - end; - end; - - DecimalSeparator:= '.'; - argnum:=Length(args); - //behelyettesítés - for i:=1 to Length(args) - 1 do - begin - if args[i] = '!playerpos' then - begin - setLength(args, Length(args) + 2); - argnum:=argnum + 2; - for j:=argnum - 1 downto i + 1 do - args[j]:=args[j - 2]; - args[i]:=FloatToStr(cpx^); - args[i + 1]:=FloatToStr(cpy^); - args[i + 2]:=FloatToStr(cpz^); - end - else - if args[i] = '$weapon' then - begin - case myfegyv of - FEGYV_MPG:args[i] := 'FEGYV_MPG'; - FEGYV_M82A1:args[i] := 'FEGYV_M82A1'; - FEGYV_M4A1:args[i] := 'FEGYV_M4A1'; - FEGYV_QUAD:args[i] := 'FEGYV_QUAD'; - FEGYV_NOOB:args[i] := 'FEGYV_NOOB'; - FEGYV_LAW:args[i] := 'FEGYV_LAW'; - FEGYV_X72:args[i] := 'FEGYV_X72'; - FEGYV_MP5A3:args[i] := 'FEGYV_MP5A3'; - FEGYV_H31_T:args[i] := 'FEGYV_H31_T'; - FEGYV_H31_G:args[i] := 'FEGYV_H31_G'; - FEGYV_HPL:args[i] := 'FEGYV_HPL'; - FEGYV_BM3:args[i] := 'FEGYV_BM3'; - FEGYV_BM3_2, FEGYV_BM3_3:; - end; - end - else - if args[i] = '$team' then - begin - case myfegyv of - FEGYV_MPG, FEGYV_QUAD, FEGYV_NOOB, FEGYV_X72, FEGYV_H31_T, FEGYV_HPL:args[i] := 'TECH'; - else - args[i] := 'GUN'; - end; - end - else - if args[i] = '%teamn' then - begin - case myfegyv of - FEGYV_MPG, FEGYV_QUAD, FEGYV_NOOB, FEGYV_X72, FEGYV_H31_T, FEGYV_HPL:args[i] := '0'; - else - args[i] := '1'; - end; - end; - end; - - //wow, tudunk valamit - - if (args[0] = 'else') then - begin - if scriptdepth > 0 then - begin - scriptevaling[scriptdepth]:= not scriptevaling[scriptdepth] and scriptevaling[scriptdepth - 1]; - end - else - scripterror('Unexpected else'); - exit; - end - else - - if (args[0] = 'endif') then - begin - if scriptdepth > 0 then - begin - dec(scriptdepth); - end - else - scripterror('Unexpected endif'); - exit; - end - else - - if (args[0] = 'if') then - begin - if not scriptevaling[scriptdepth] then - begin - inc(scriptdepth); - scriptevaling[scriptdepth]:=false; - end - else - varCompare(copy(args, 1, argnum - 1)); - - exit; - end - else - - if not scriptevaling[scriptdepth] then exit; - - if (Length(args) > 1) then - begin - t:=args[0][1]; - if (t = '!') and (args[1] = '=') then - begin - for i:=0 to Length(vecvars) - 1 do - if args[0] = '!' + vecvars[i].name then - vecvars[i].pos:=computevecs(copy(args, 2, argnum - 2)); - exit; - end - else - if (t = '%') and (args[1] = '=') then - begin - for i:=0 to Length(numVars) - 1 do - if args[0] = '%' + numVars[i].name then - numVars[i].num:=computenums(copy(args, 2, argnum - 2)); - exit; - end - else - if (t = '$') and (args[1] = '=') then - begin - for i:=0 to Length(strvars) - 1 do - if args[0] = '$' + strvars[i].name then - begin - tmp:= ''; - for j:=2 to Length(args) - 1 do - begin - tmp:=tmp + varToString(args[j]); - //if j 1) then - begin - if (args[1][1] = '%') then - begin - setLength(numVars, length(numVars) + 1); - numVars[length(numVars) - 1].name:=copy(args[1], 2, Length(args[1]) - 1); - end - else - if (args[1][1] = '!') then - begin - setLength(vecvars, length(vecvars) + 1); - vecvars[length(vecvars) - 1].name:=copy(args[1], 2, Length(args[1]) - 1); - end - else - if (args[1][1] = '$') then - begin - setLength(strvars, length(strvars) + 1); - strvars[length(strvars) - 1].name:=copy(args[1], 2, Length(args[1]) - 1); - end; - exit; - end - else - - if (args[0] = 'getlang') and (Length(args) > 1) then - begin - t:=args[1][1]; - if (t = '$') then - begin - for i:=0 to Length(strvars) - 1 do - if args[1] = '$' + strvars[i].name then //megvan mibe tesszük - begin - tmp:= ''; - j:=trunc(computenums(copy(args, 2, argnum - 2))); - if sizeof(lang) < j then - strvars[i].text:=lang[j]; - exit; - end; - - end; - end - else - - if (args[0] = 'bind') then - begin - if Length(args) < 3 then begin scripterror('Not enough paramater for bind');exit; end; - if (args[1] = 'closedisplay') then - displaycloseevent:=args[2] - else - begin - for i:=0 to Length(binds) - 1 do - if binds[i].key = args[1][1] then - begin - binds[i].script:=args[2]; - exit; - end; - SetLength(binds, Length(binds) + 1); - binds[Length(binds) - 1].key:=args[1][1]; - binds[Length(binds) - 1].script:=args[2]; - end; - exit; - end - else - - if (args[0] = 'unbind') then - begin - if Length(args) < 2 then begin scripterror('Not enough paramater for unbind');exit; end; - if (args[1] = 'closedisplay') then - displaycloseevent:= '' - else - begin - for i:=0 to Length(binds) - 1 do - if binds[i].key = args[1][1] then - begin - for j:=i to Length(binds) - 2 do - binds[j]:=binds[j + 1]; - SetLength(binds, length(binds) - 1); - end; - end; - exit; - end - else - - if (args[0] = 'unbindall') then - begin - SetLength(binds, 0); - exit; - end - else - - //nagy kiírás középre - if (args[0] = 'fastinfo') then - begin - for i:=1 to Length(args) - 1 do - tmp:=tmp + ' ' + varToString(args[i]); - - addHudMessage(tmp, 255, betuszin); - exit; - end - else - - //nagy kiírás középre - piros - if (args[0] = 'fastinfored') then - begin - for i:=1 to Length(args) - 1 do - tmp:=tmp + ' ' + varToString(args[i]); - - addHudMessage(tmp, $FF0000); - exit; - end - else - - //fenycsik - if (args[0] = 'lightbeam') then - begin - j:=stuffjson.GetNum(['lightbeams']); - //i:=0; - for i:=0 to j - 1 do - begin - if stuffjson.GetString(['lightbeams', i, 'name']) = args[1] then - begin - vec1 := D3DXVector3(stuffjson.GetFloat(['lightbeams', i, 'start', 'x']), - stuffjson.GetFloat(['lightbeams', i, 'start', 'y']), - stuffjson.GetFloat(['lightbeams', i, 'start', 'z'])); - vec2 := D3DXVector3(stuffjson.GetFloat(['lightbeams', i, 'end', 'x']), - stuffjson.GetFloat(['lightbeams', i, 'end', 'y']), - stuffjson.GetFloat(['lightbeams', i, 'end', 'z'])); - k:=stuffjson.GetInt(['lightbeams', i, 'time']); - l:=stuffjson.GetInt(['lightbeams', i, 'size']); - b:=stuffjson.GetInt(['lightbeams', i, 'color']); - Particlesystem_add(fenycsikcreate(vec1,vec2,l,b,k)); - exit; - end; - end; - - exit; - end - else - - //chat kiírás - if (args[0] = 'print') then - begin - for i:=1 to Length(args) - 1 do - tmp:=tmp + ' ' + varToString(args[i]); - - multisc.chats[addchatindex].uzenet:=tmp; - addchatindex:=addchatindex + 1; - exit; - end - else - - //ablakos kiírás - if (args[0] = 'display') then - begin - for i:=1 to Length(args) - 1 do - tmp:=tmp + ' ' + varToString(args[i]); - - labeltext:=tmp; - labelactive:=true; - exit; - end - else - - if (args[0] = 'closedisplay') then - begin - labelactive:=false; - exit; - end; - - //részecske rendszer kikapcs - if (args[0] = 'particle_stop') and (Length(args) > 2) then - begin - for i:=0 to Length(particlesSyses) - 1 do - if particlesSyses[i].name = args[1] then - begin - particlesSyses[i].disabled:=true; - v1:=computenums(copy(args, 2, argnum - 2)); - if v1 = 0 then - particlesSyses[i].restart:=0 - else - particlesSyses[i].restart:=gettickcount + trunc(v1); - end; - exit; - end - else - - //részecske rendszer bekapcs - if (args[0] = 'particle_start') and (Length(args) > 1) then - begin - for i:=0 to Length(particlesSyses) - 1 do - if particlesSyses[i].name = args[1] then - particlesSyses[i].disabled:=false; - exit; - end - else - - //prop elrejtés - if (args[0] = 'prop_hide') and (Length(args) > 1) then - begin - propsystem.setVisibility(args[1], false); - exit; - end - else - - //prop elõhozás - if (args[0] = 'prop_show') and (Length(args) > 1) then - begin - propsystem.setVisibility(args[1], true); - exit; - end - else - - if (args[0] = 'trigger_enable') and (Length(args) > 1) then - begin - tmp:=varToString(args[1]); - for i:=0 to Length(triggers) - 1 do - if triggers[i].name = tmp then - triggers[i].active:=true; - exit; - end - else - - if (args[0] = 'trigger_disable') and (Length(args) > 2) then - begin - tmp:=varToString(args[1]); - for i:=0 to Length(triggers) - 1 do - if triggers[i].name = tmp then - begin - triggers[i].active:=false; - v1:=computenums(copy(args, 2, argnum - 2)); - if v1 = 0 then - triggers[i].restart:=0 - else - triggers[i].restart:=gettickcount + trunc(v1); - end; - exit; - end - else - - if (args[0] = 'dynamizate') and (Length(args) > 1) then - begin - tmp:=varToString(args[1]); - propsystem.dynamizate(tmp).speed:=D3DXVector3(0, 0.5, 0); - exit; - end - else - - if (args[0] = 'dynamic_speed') and (Length(args) > 4) then - begin - tmp:=varToString(args[1]); - propsystem.getdynamic(tmp).speed:=computevecs(copy(args, 2, argnum - 2)); - - exit; - end - else - - if (args[0] = 'prop_position') and (Length(args) > 4) then - begin - tmp:=varToString(args[1]); - propsystem.getprop(tmp).pos:=computevecs(copy(args, 2, argnum - 2)); - - exit; - end - else - - if (args[0] = 'prop_rotation') and (Length(args) > 2) then - begin - tmp:=varToString(args[1]); - propsystem.getprop(tmp).rot:=computenums(copy(args, 2, argnum - 2)); - - exit; - end - else - - if (args[0] = 'particle_position') and (Length(args) > 4) then - begin - tmp:=varToString(args[1]); - for i:=0 to length(particlesSyses) - 1 do - if particlesSyses[i].name = tmp then - particlesSyses[i].from:=computevecs(copy(args, 2, argnum - 2)); - - exit; - end - else - - //law robbanás - if (args[0] = 'explode') then - begin - AddLAW(D3DXVector3Zero, computevecs(copy(args, 1, argnum - 1)), -1); - exit; - end - else - - //wave - if (args[0] = 'wave') and (Length(args) > 1)then - begin - wave:= strtoint(args[1]); - exit; - end - else - - //skirmish - if (args[0] = 'skirmish') then - begin - skirmish:= true; - exit; - end - else - - //startbattle - if (args[0] = 'startbattle') then - begin - battle:=true; - exit; - end - else - - //stopbattle - if (args[0] = 'stopbattle') then - begin - battle:=false; - exit; - end - else - - //fegyvskin load - if (args[0] = 'fegyvskin') then - begin - //evalscriptline('display fegyvskin'); - case myfegyv of - FEGYV_MPG: myfegyv_skin := fegyvskins[5]; - FEGYV_M82A1: myfegyv_skin := fegyvskins[1]; - FEGYV_M4A1: myfegyv_skin := fegyvskins[0]; - FEGYV_QUAD: myfegyv_skin := fegyvskins[6]; - FEGYV_NOOB: myfegyv_skin := fegyvskins[7]; - FEGYV_LAW: myfegyv_skin := fegyvskins[2]; - FEGYV_X72: myfegyv_skin := fegyvskins[8]; - FEGYV_MP5A3: myfegyv_skin := fegyvskins[3]; - FEGYV_H31_T: myfegyv_skin := FEGYV_H31_T; - FEGYV_H31_G: myfegyv_skin := FEGYV_H31_G; - FEGYV_HPL: myfegyv_skin := fegyvskins[9]; - FEGYV_BM3: myfegyv_skin := fegyvskins[4]; - end; - exit; - end - else - - //global uzenet - if (args[0] = 'chatmost') then - begin - tmp := ''; - for i:=1 to Length(args) - 1 do - tmp := tmp + ' ' + varToString(args[i]); - - Multisc.Chat(tmp); - exit; - end - else - - if (args[0] = 'respawn') then - begin - respawn; - exit; - end - else - { - //submit api communication - if (args[0] = 'submit') then - begin - if (args[1] = 'atlantisevent') then - begin - HTTPClient := TidHTTP.Create(nil); - try - postData := TIdMultiPartFormDataStream.Create; - try - postData.AddFormField('form[nev]', multisc.nev); - postData.AddFormField('form[kills]', intToStr(multisc.kills - multisc.killsbeforedeath)); - response := HTTPClient.Post('http://stickman.hu/api?mode=atlantisevent', postData); - finally - postData.Free; - end; - finally - HTTPClient.Free; - end; - end; - exit; - end - else - - //spawn airboat/submarine - if (args[0] = 'watercraft') and (Length(args) > 3) then - begin - if myfegyv > 127 then - SpawnVehicle(computevecs(copy(args, 1, argnum - 1)), 2, 'airboat') - else - SpawnVehicle(computevecs(copy(args, 1, argnum - 1)), 1, 'submarine'); - exit; - end - else - } - //hang - if (args[0] = 'sound') and (Length(args) > 4) then - begin - playsound(StrToInt(args[1]), false, integer(timegettime) + random(10000), true, D3DXVector3(StrToFloat(args[2]), StrToFloat(args[3]), StrToFloat(args[4]))); - exit; - end - else - - //script - if (args[0] = 'script') and (Length(args) > 1) then - begin - evalScript(args[1]); - exit; - end - else - - if (args[0] = 'timeout') and (Length(args) > 2) then - begin - SetLength(timedscripts, length(timedscripts) + 1); - with timedscripts[length(timedscripts) - 1] do - begin - script:=args[1]; - time:=gettickcount + trunc(computenums(copy(args, 2, argnum - 2))); - end; - exit; - end - else - - multisc.chats[addchatindex].uzenet:= 'Unhandled scriptline: ' + line; - addchatindex:=addchatindex + 1; - - end; - -procedure handleparancsok(var mit:String); -var - tmp: string; - i:integer; - {$IFDEF propeditor} - j, k:integer; - {$ENDIF} - begin - { - if pos(' /practice', mit) = 1 then - mit:= ' /join Practice-' + inttohex(random(35536), 4); - } - if pos(' /nohud', mit) = 1 then - nohud:= not nohud; - - if pos(' /bot', mit) = 1 then - bots_enabled:= not bots_enabled; - - //if pos(' /activate portalevent code:12.11.16', mit) = 1 then - //portalevent.phs:=1; - - if pos(' /nofegyv', mit) = 1 then - nofegyv:= not nofegyv; - - if pos(' /sniper', mit) = 1 then - coordsniper:=true; - - if pos(' /fps', mit) = 1 then - opt_drawfps:= not opt_drawfps; - - if pos(' /texturelist', mit) = 1 then - savetexfilelist; + if pos(' /texturelist', mit) = 1 then + savetexfilelist; if pos(' /saveterrainmodel', mit) = 1 then saveterrainmodel; @@ -15219,36 +13930,25 @@ var SpawnVehicle(d3dxvector3(-335, waterlevel, -60),2,'submarine'); end; {$ENDIF} - { - if pos(' //', mit) = 1 then evalscriptline(copy(mit, 4, length(mit) - 3)); - } - - { - //EXAMPLE - if pos(' /servertime', mit) = 1 then - begin - TPrintServerTimeThread.Create(FALSE); - end; - } if pos(' /havitop', mit) = 1 then begin - TPrintTopThread.Create(FALSE, TOP_MONTHLY); - end; + threadHandlerModule.call('printTop', ['havitop']); + end; if pos(' /hetitop', mit) = 1 then begin - TPrintTopThread.Create(FALSE, TOP_WEEKLY); + threadHandlerModule.call('printTop', ['hetitop']); end; if pos(' /napitop', mit) = 1 then begin - TPrintTopThread.Create(FALSE, TOP_DAILY); + threadHandlerModule.call('printTop', ['napitop']); end; if pos(' /top', mit) = 1 then begin - TPrintTopThread.Create(FALSE); + threadHandlerModule.call('printTop', ['top']); end; if pos(' /rank', mit) = 1 then @@ -15256,7 +13956,7 @@ var tmp := ''; for i:=0 to high(ppl) do if (ppl[i].net.UID = 0) then tmp := ppl[i].pls.nev; - TPrintRank.Create(FALSE, tmp); + threadHandlerModule.call('printRank', [tmp, 'ossz']); end; if pos(' /rank napi', mit) = 1 then @@ -15264,7 +13964,7 @@ var tmp := ''; for i:=0 to high(ppl) do if (ppl[i].net.UID = 0) then tmp := ppl[i].pls.nev; - TPrintRank.Create(FALSE, tmp, TOP_DAILY); + threadHandlerModule.call('printRank', [tmp, 'napi']); end; if pos(' /rank heti', mit) = 1 then @@ -15272,7 +13972,7 @@ var tmp := ''; for i:=0 to high(ppl) do if (ppl[i].net.UID = 0) then tmp := ppl[i].pls.nev; - TPrintRank.Create(FALSE, tmp, TOP_WEEKLY); + threadHandlerModule.call('printRank', [tmp, 'heti']); end; if pos(' /rank havi', mit) = 1 then @@ -15280,19 +13980,20 @@ var tmp := ''; for i:=0 to high(ppl) do if (ppl[i].net.UID = 0) then tmp := ppl[i].pls.nev; - TPrintRank.Create(FALSE, tmp, TOP_MONTHLY); - end; + threadHandlerModule.call('printRank', [tmp, 'havi']); + end; if pos(' /koth', mit) = 1 then begin - TPrintKoTH.Create(FALSE); + threadHandlerModule.call('printKoth', ['koth']); end; if pos(' /toth', mit) = 1 then begin - TPrintToTH.Create(FALSE); + threadHandlerModule.call('printKoth', ['toth']); end; + {$IFDEF propeditor} if pos(' /p', mit) = 1 then begin @@ -15370,19 +14071,19 @@ view.x := cos(szogy); view.y := sin(szogy); view.z := cos(szogx)*view.x; // +z *sin ,de Z = 0 -view.x := sin(szogx)*view.x; // -Z *cos , de Z még mindig 0 +view.x := sin(szogx)*view.x; // -Z *cos , de Z még mindig 0 D3DXVec3Normalize(view,view); for i:=0 to length(propsystem.objects)-1 do begin - if tavPointPointsq(propsystem.objects[i].pos,campos) < 7 then // 1 méter minimum + if tavPointPointsq(propsystem.objects[i].pos,campos) < 7 then // 1 méter minimum begin - //összekötõ vector + //összekötõ vector D3DXVec3Subtract(vec,propsystem.objects[i].pos,campos); D3DXVec3Normalize(vec,vec) ; - //skaláris + //skaláris if (D3DXVec3Dot(vec,view)>0.9) then messagebox(0,'pickup',';)',0); @@ -15454,11 +14155,11 @@ end; {} if (chr(mit) = 'c') or (chr(mit) = 'C') then chatmost:= ' /c '; //script binds - for i:=0 to Length(binds) - 1 do + for i:=0 to Length(scriptsHandler._binds) - 1 do begin - if Length(binds) = 0 then break; - if LowerCase(chr(mit)) = binds[i].key then - evalScript(binds[i].script); + if Length(scriptsHandler._binds) = 0 then break; + if LowerCase(chr(mit)) = scriptsHandler._binds[i].key then + scriptsHandler.evalScript(scriptsHandler._binds[i].script); end; @@ -15550,7 +14251,7 @@ end; {} if (mit = VK_ESCAPE) and labelactive then begin labelactive:=false; - evalscript(displaycloseevent); + scriptsHandler.evalscript(displaycloseevent); end; if ((chr(mit) = 'f') or (chr(mit) = 'F')) then usebutton:=true; if ((chr(mit) = 'f') or (chr(mit) = 'F')) and not labelactive and labelvolt then @@ -15562,7 +14263,7 @@ end; {} if ((chr(mit) = 'f') or (chr(mit) = 'F')) and labelactive then begin labelactive:=false; - evalscript(displaycloseevent); + scriptsHandler.evalscript(displaycloseevent); end; //debug stuff @@ -15675,18 +14376,18 @@ end; {} if (' hogy ' = lowercase(Copy(chatmost, 1, 6))) or (' hogyan ' = lowercase(Copy(chatmost, 1, 8))) or (' mennyi ' = lowercase(Copy(chatmost, 1, 8))) or - (' miért ' = lowercase(Copy(chatmost, 1, 7))) or - (' mért ' = lowercase(Copy(chatmost, 1, 6))) or - (' miér ' = lowercase(Copy(chatmost, 1, 6))) or - (' mié ' = lowercase(Copy(chatmost, 1, 5))) or - (' mér ' = lowercase(Copy(chatmost, 1, 5))) or - (' mé ' = lowercase(Copy(chatmost, 1, 4))) or - (' MIÉRT ' = Copy(chatmost, 1, 4)) or - (' MÉRT ' = Copy(chatmost, 1, 6)) or - (' MIÉR ' = Copy(chatmost, 1, 6)) or - (' MIÉ ' = Copy(chatmost, 1, 5)) or - (' MÉR ' = Copy(chatmost, 1, 5)) or - (' MÉ ' = Copy(chatmost, 1, 4)) then + (' miért ' = lowercase(Copy(chatmost, 1, 7))) or + (' mért ' = lowercase(Copy(chatmost, 1, 6))) or + (' miér ' = lowercase(Copy(chatmost, 1, 6))) or + (' mié ' = lowercase(Copy(chatmost, 1, 5))) or + (' mér ' = lowercase(Copy(chatmost, 1, 5))) or + (' mé ' = lowercase(Copy(chatmost, 1, 4))) or + (' MIÉRT ' = Copy(chatmost, 1, 4)) or + (' MÉRT ' = Copy(chatmost, 1, 6)) or + (' MIÉR ' = Copy(chatmost, 1, 6)) or + (' MIÉ ' = Copy(chatmost, 1, 5)) or + (' MÉR ' = Copy(chatmost, 1, 5)) or + (' MÉ ' = Copy(chatmost, 1, 4)) then begin len:=Length(chatmost); @@ -15710,24 +14411,24 @@ end; {} tmp := stringreplace(tmp,';','',[rfReplaceAll, rfIgnoreCase]); tmp := stringreplace(tmp,'?','',[rfReplaceAll, rfIgnoreCase]); tmp := stringreplace(tmp,'!','',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'á','a',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'é','e',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'õ','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'ö','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'ó','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'û','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'ü','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'ú','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'í','i',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Á','a',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'É','e',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Õ','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Ö','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Ó','o',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Û','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Ü','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Ú','u',[rfReplaceAll, rfIgnoreCase]); - tmp := stringreplace(tmp,'Í','i',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'á','a',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'é','e',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'õ','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'ö','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'ó','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'û','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'ü','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'ú','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'í','i',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ã','a',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'É','e',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Õ','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ö','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ó','o',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Û','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ü','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ú','u',[rfReplaceAll, rfIgnoreCase]); + tmp := stringreplace(tmp,'Ã','i',[rfReplaceAll, rfIgnoreCase]); args[j]:=args[j] + lowercase(tmp); end; end; @@ -15879,7 +14580,7 @@ end; {} bigtext:=0.8; - //Menü lap all + //Menü lap all for i:=0 to MENULAP_MAX do begin menu.Addteg(balstart, 0.3, balveg, 0.8, i); @@ -15888,7 +14589,7 @@ end; {} menu.AddText(balstart, 0.65, balveg, 0.75, bigtext, i, lang[2], true); end; - //Menü lap 0; + //Menü lap 0; // Invisible GazMSG menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 0); @@ -15897,7 +14598,7 @@ end; {} menu.AddText(jobbstart, 0.3, jobbveg, 0.8, 0.5, 0, 'WTF factor.', false);menufi[MI_GAZMSG]:=menu.items[0, 3]; menufi[MI_GAZMSG].visible:=false; - //Menü lap 1 -- Connect + //Menü lap 1 -- Connect menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 1); menu.AddText(jobbstart, 0.7, jobbveg, 0.8, 1, 1, lang[3], true);menufi[MI_CONNECT]:=menu.items[1, 3]; @@ -15922,7 +14623,7 @@ end; {} - //Menü lap 2 --- Options + //Menü lap 2 --- Options menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 2); sor:=0.08; @@ -15941,14 +14642,14 @@ end; {} - //Menü lap 3 --- Exit + //Menü lap 3 --- Exit menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 3); - menu.AddText(jobbstart, 0.5, jobbveg, 0.6, 0.5, 3, lang[58], true); // Idáig nem ért el a Menufi[] + menu.AddText(jobbstart, 0.5, jobbveg, 0.6, 0.5, 3, lang[58], true); // Idáig nem ért el a Menufi[] menu.AddText(jobbstart, 0.6, jobbveg, 0.7, 0.5, 3, lang[15], true); menu.AddText(jobbstart, 0.4, jobbveg, 0.5, 0.5, 3, lang[16], false); - //Menü lap 4 --- Options-Graphics + //Menü lap 4 --- Options-Graphics sor:=0.034; fent:=0.3; menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 4); @@ -15977,7 +14678,7 @@ end; {} //menu.AddText(0.51 ,0.64,0.69,0.68,0.5,4,lang[75],false); //menu.AddText(0.69 ,0.64,0.77,0.68,0.5,4,'[X]',true); menufi[MI_IMPOSTER]:=menu.items[4,14]; - //Menü lap 5 --- Options-Sound + //Menü lap 5 --- Options-Sound menu.Addteg(jobbstart, 0.3, jobbveg, 0.8, 5); menu.AddText(jobbstart, 0.350, jobbstart + 0.13 * korr, 0.400, 0.5, 5, lang[20], false); @@ -15998,7 +14699,7 @@ end; {} menu.AddText(jobbstart + korr * 0.2, 0.580, jobbstart + 0.35 * korr, 0.650, 0.5, 5, lang[25], false); menu.AddText(jobbstart + 0.35 * korr, 0.580, jobbstart + 0.4 * korr, 0.650, 1, 5, '[X]', true);menufi[MI_R_ACTION]:=menu.items[5, 14]; - //Menü lap 6 --- Controls + //Menü lap 6 --- Controls sor:=0.034; fent:=0.5; hanyadik:=1; @@ -16031,7 +14732,7 @@ end; {} // menu.AddText(jobbstart+korr*0.2 ,fent+sor*hanyadik,jobbstart+korr*0.3,fent+sor*(hanyadik+1),0.5,lap,'[X]',true); menufi[MI_MINVY]:=menu.items[lap,16]; - //Menü lap 7 --- Interface + //Menü lap 7 --- Interface fent:=0.3; sor:=0.034; @@ -16053,7 +14754,7 @@ end; {} menu.AddText(jobbstart, fent + sor * 11, jobbstart + 0.3 * korr, fent + sor * 12, 0.5, 7, lang[76], false); menu.AddText(jobbstart + 0.3 * korr, fent + sor * 11, jobbveg - 0.03 * korr, fent + sor * 12, 1, 7, '[X]', true);menufi[MI_SAVEPW]:=menu.items[7, 12]; - //Menü lap 8 --- Options-More graphics + //Menü lap 8 --- Options-More graphics sor:=0.034; fent:=0.3; hanyadik:=1; @@ -16285,7 +14986,7 @@ label men, jatek, vege; begin // BEGIIIN {$IFDEF undebug} asm -//PEB mágia +//PEB mágia MOV eax,FS:[$30] ADD eax,2 MOV ECX,[EAX] @@ -16300,6 +15001,8 @@ begin // BEGIIIN NtSIT(GetCurrentThread, $11, nil, 0); {$ENDIF} + sentryModule := TSentry.Create; + try //Absolute Initialization @@ -16308,9 +15011,9 @@ begin // BEGIIIN DecimalSeparator:= '.'; //admin checking adm:= 'JEAH'; - if fileexists('C:\Anyáddal szórakozz.txt') then + if fileexists('C:\Anyáddal szórakozz.txt') then begin - assignfile(logfile, 'C:\Anyáddal szórakozz.txt'); + assignfile(logfile, 'C:\Anyáddal szórakozz.txt'); reset(logfile); readln(logfile, adm); closefile(logfile); @@ -16570,10 +15273,10 @@ begin // BEGIIIN // messagebox(0,PChar('Lflngt:'+floattostr(lflngt2/lflngt)),'Stats',0); laststate:= 'Init Menu 1'; writeln(logfile, 'Loaded geometry and data');flush(logfile); - //menü helye + //menü helye //FillupMenu; - // crunchSettings; //tyúklife + // crunchSettings; //tyúklife //writeln(logfile, 'Checksum: ' + inttohex(checksum, 8)); {$IFDEF nochecksumcheck} checksum:=datachecksum; @@ -16699,17 +15402,18 @@ begin // BEGIIIN - multisc.weather:=felho.coverage; //ehh, ennyit a csodálatos OOP-rol. + multisc.weather:=felho.coverage; //ehh, ennyit a csodálatos OOP-rol. multip2p:=TMMOPeerToPeer.Create(multisc.myport, myfegyv, myfegyv_skin); //JAEZAZ writeln(logfile, 'Network initialized'); - laststate:= 'Initialzing game 3'; respawn; - evalScript('startup'); - evalscriptline('var $thistrigger'); + + lastState := 'startup script'; + scriptsHandler.evalScript('startup'); + scriptsHandler.evalscriptline('var $thistrigger'); laststate:= 'Initialzing game 4'; if not iswindowed then @@ -16866,12 +15570,14 @@ begin // BEGIIIN except on E:Exception do begin + sentryModule.reportError(E, 'Fatal Error'); + g_pD3Ddevice:=nil; g_pD3D:=nil; closeSound; closewindow(hwindow); UnregisterClass('CLS12345', wc.hInstance); - messagebox(0, PChar(lang[28] + AnsiString(#13#10) + E.Message + AnsiString(#13#10) + 'Aktuális esemény:' + laststate + AnsiString(#13#10) + lang[29]), Pchar(lang[30]), MB_SETFOREGROUND or MB_ICONERROR); + messagebox(0, PChar(lang[28] + AnsiString(#13#10) + E.Message + AnsiString(#13#10) + 'Aktuális esemény:' + laststate + AnsiString(#13#10) + lang[29]), Pchar(lang[30]), MB_SETFOREGROUND or MB_ICONERROR); writeln(logfile, 'Unhandled error @' + inttohex(Integer(ExceptAddr), 8) + ':' + E.Message); writeln(logfile, 'Last state: ', laststate); writeln(logfile, 'Last sound action: ', lastsoundaction); diff --git a/src/ThreadHandler.pas b/src/ThreadHandler.pas new file mode 100644 index 0000000..0711322 --- /dev/null +++ b/src/ThreadHandler.pas @@ -0,0 +1,167 @@ +unit ThreadHandler; + +interface + + uses + Classes, + Variants, + // + Typestuff, + QJSON; + + type TSaga = class (TObject) + private + _key: string; + _callback: TIndefiniteProcedure; + published + constructor Create(key: string; callback: TIndefiniteProcedure); + function key: string; + function callback: TIndefiniteProcedure; //this will be the thread execute + end; + + type TCallbackThread = class (TThread) + private + _callback: TIndefiniteProcedure; + protected + procedure Execute(const args: array of const); reintroduce; + published + constructor Create(callback: TIndefiniteProcedure); + end; + + TCallbackThreadArray = array of TCallbackThread; + + //TODO: proxy layer to takeLeading, takeLatest, etc sagas + type TThreadHandler = class (TObject) + private + _sagas: array of TSaga; + _threads: TCallbackThreadArray; + procedure cleanup(hard: boolean = false); + published + constructor Create; + procedure addSaga(saga: TSaga); + function call(key: string; const args: array of const): THandle; //creates new saga, suspended ones stay as-is + //TODO: procedure all(keys: array of string; parallel: boolean = false); + //TODO: procedure race(keys: array of string); + //TODO: execute(key / keys / null) //starts suspended ones, does not create new saga + //TODO: suspend(key / keys / null) + //TODO: terminate(key / keys / null) + //TODO: waitFor(key / keys / null) //runs given saga(s), all others stay as-is/suspended + end; + + +var + threadHandlerModule: TThreadHandler; + fastinfoSaga, printTopSaga, printRankSaga, printKothSaga, reportBotKillsSaga: TSaga; //TODO: move these + + +implementation + +//TCallbackThread +constructor TCallbackThread.Create(callback: TIndefiniteProcedure); +begin + inherited Create(true); //suspended on create + + _callback := callback; +end; + +procedure TCallbackThread.Execute(const args: array of const); +begin + _callback(args); + terminate; +end; + + +//TSaga +constructor TSaga.Create(key: string; callback: TIndefiniteProcedure); +begin + _key := key; + _callback := callback; +end; + +function TSaga.key: string; +begin + result := _key; +end; + +function TSaga.callback: TIndefiniteProcedure; +begin + result := _callback; +end; + + +//TThreadHandler +constructor TThreadHandler.Create; +begin + setlength(_sagas, 0); + setlength(_threads, 0); +end; + +procedure TThreadHandler.addSaga(saga: TSaga); +begin + setlength(_sagas, succ(length(_sagas))); + _sagas[high(_sagas)] := saga; +end; + +function TThreadHandler.call(key: string; const args: array of const): THandle; +var + i: Integer; + saga: TSaga; +begin + cleanup; + saga := nil; + result := Null; + + //find the saga + for i := low(_sagas) to high(_sagas) do + if _sagas[i].key <> key then + continue + else + begin + saga := _sagas[i]; + break; + end; + + if saga = nil then exit; + + //create thread + setlength(_threads, succ(length(_threads))); + _threads[high(_threads)] := TCallbackThread.Create(saga.callback()); + + result := _threads[high(_threads)].ThreadID; + + //execute + _threads[high(_threads)].Execute(args); +end; + +//TODO: clear results for deleted threads +procedure TThreadHandler.cleanup(hard: boolean = false); +var + i: Integer; + newThreads: TCallbackThreadArray; +begin + setlength(newThreads, 0); + + if hard then + for i := low(_threads) to high(_threads) do + begin + if _threads[i].Terminated then continue; + if not _threads[i].Suspended then _threads[i].Suspend; + _threads[i].Terminate; + end; + + for i := low(_threads) to high(_threads) do + begin + if not _threads[i].Terminated then + begin + setlength(newThreads, length(newThreads) + 1); + newThreads[high(newThreads)] := _threads[i]; + end + else + _threads[i].Destroy; + end; + + setlength(_threads, length(newThreads)); + _threads := copy(newThreads, low(newThreads), length(newThreads)); +end; + +end. diff --git a/src/Utils.pas b/src/Utils.pas index 7e1d944..fbd6510 100644 --- a/src/Utils.pas +++ b/src/Utils.pas @@ -5,7 +5,11 @@ interface Sysutils, Typestuff, D3DX9, - ojjektumok; + Direct3D9, + ojjektumok, + fizika, + windows, + qjson; type ByteArrayUtils = class @@ -74,8 +78,185 @@ TLovesArrayUtils = class //TODO procedure filterByFegyv(); end; + type TRenderUtils = class (TObject) + protected + g_pD3Ddevice: IDirect3ddevice9; + public + constructor Create(d3dxDevice: IDirect3DDevice9); + //TODO: procedure drawTextOnHud(text: string; pos: TD3DXVector2; color: Cardinal); + //TODO: procedure drawText(text: string; pos: TD3DXVector2; color: Cardinal); + procedure drawBox(pos: TD3DXVector3; size: TD3DXVector3; color: Cardinal); + //TODO: procedure displayText(text: string); + end; + + type TMapUtils = class (TObject) + public + function getMapHeight(xx, zz: Single): Single; + function vanOttValami(xx:single;var yy:single;zz:single):boolean; + function raytestlvl(v1, v2:TD3DXVector3; hany:integer; var v3:TD3DXVector3):boolean; + end; + + type VariantUtils = class (TObject) + published + class function VarRecToStr(rec: TVarRec): string; + //TODO: class function VarRecToInt(): string; + //TODO: class function VarRecToFloat(): string; + end; + + //TODO: remove + type KillMeUtils = class (TObject) + published + class function unhungaryify(src: string): string; + end; + + implementation +class function KillMeUtils.unhungaryify(src: string): string; +begin + result := src; + result := StringReplace(result, 'á', 'a', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'é', 'e', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'í', 'i', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'ó', 'o', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'ö', 'o', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'õ', 'o', [rfReplaceAll, rfIgnoreCase]); //ez egy hoszzu ö + result := StringReplace(result, 'ú', 'u', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'ü', 'u', [rfReplaceAll, rfIgnoreCase]); + result := StringReplace(result, 'û', 'u', [rfReplaceAll, rfIgnoreCase]); //emmeg hosszu ü +end; + +class function VariantUtils.VarRecToStr(rec: TVarRec): string; +begin + with rec do + case VType of + vtInteger: Result := Result + IntToStr(VInteger); + vtBoolean: Result := Result + BoolToStr(VBoolean); + vtChar: Result := Result + VChar; + vtExtended: Result := Result + FloatToStr(VExtended^); + vtString: Result := Result + string(VAnsiString);//VString^; + vtPChar: Result := Result + string(VAnsiString); //VPChar; + vtObject: Result := Result + VObject.ClassName; + vtClass: Result := Result + VClass.ClassName; + vtAnsiString: Result := Result + string(VAnsiString); + //vtUnicodeString: Result := Result + string(VUnicodeString); + vtCurrency: Result := Result + CurrToStr(VCurrency^); + vtVariant: Result := Result + string(VVariant^); + vtInt64: Result := Result + IntToStr(VInt64^); + + end; +end; + +//MAP START +function TMapUtils.vanOttValami(xx:single;var yy:single;zz:single):boolean; //copy of vanottvalami +const + szor = 2; +var + i:integer; + tav:single; +begin + result:=false; + + for i:=0 to high(posrads) do + with posrads[i] do + begin + + tav:=sqr(posx - xx) + sqr(posz - zz); + if tav > sqr(raddn) then continue; + + if tav < sqr(radd) then + tav:=0 + else + begin + tav:=sqrt(tav); + if tav<(radd + raddn) * 0.5 then + tav:=sqr((tav - radd) / (raddn - radd)) * 2 + else + tav:=1 - sqr((raddn - tav) / (raddn - radd)) * 2; + end; + yy:=posy * (1 - tav) + yy * tav; + result:=true; + end; +end; + +function TMapUtils.raytestlvl(v1, v2:TD3DXVector3; hany:integer; var v3:TD3DXVector3):boolean; //copy of raytestlvl +var + k:integer; + v4:TD3DXVector3; +begin + v4:=v1; + for k:=0 to hany do + begin + v3:=v4; + d3dxvec3lerp(v4, v1, v2, k / (hany + 1)); + try + if getMapHeight(v4.x, v4.z) > v4.y then + begin + result:=true;exit; + v3:=v4; + end; + except + v3:=v2;result:=false;exit; + end; + end; + + result:=false; +end; + +function TMapUtils.getMapHeight(xx, zz: Single): Single; +var + ay:single; +begin + if (xx < -10000) or (xx > 10000) or (zz < -10000) or (zz > 10000) then + begin + result:=0; + exit; + end; + ay:=wove(xx, zz); + vanOttValami(xx, ay, zz); + result:=ay; +end; + +//RENDER START +constructor TRenderUtils.Create(d3dxDevice: IDirect3DDevice9); +begin + inherited Create; + + g_pD3Ddevice := d3dxDevice; +end; + +procedure TRenderUtils.drawBox(pos: TD3DXVector3; size: TD3DXVector3; color: Cardinal); +var + oo: HRESULT; + mesh: ID3DXMesh; + tempmesh:ID3DXMesh; +begin + g_pd3dDevice.SetRenderState(D3DRS_FOGENABLE, itrue); + + g_pd3dDevice.SetTexture(0, nil); + g_pd3dDevice.SetRenderState(D3DRS_FOGENABLE, iFalse); + g_pd3dDevice.SetRenderState(D3DRS_LIGHTING, iTrue); + g_pd3dDevice.SetRenderState(D3DRS_AMBIENT, color); + + oo := D3DXCreateBox(g_pD3DDevice, size.x, size.y, size.z, tempmesh, nil); + if (oo <> D3D_OK) then Exit; + if tempmesh = nil then exit; + if FAILED(tempmesh.CloneMeshFVF(0, D3DFVF_XYZ or D3DFVF_NORMAL, g_pd3ddevice, mesh)) then exit; + if tempmesh <> nil then tempmesh:=nil; + + //normalizemesh(mesh); + + mat_world:=identmatr; + mat_world._11:=1; + mat_world._22:=1; + mat_world._33:=1; + mat_world._41:=pos.x; + mat_world._42:=pos.y; + mat_world._43:=pos.z; + g_pd3dDevice.SetTransform(D3DTS_WORLD, mat_World); + mesh.DrawSubset(0); +end; + //BYTE START function ByteArrayUtils.indexOf(arr: array of Byte; value: Byte): Integer; var @@ -354,3 +535,4 @@ procedure TPlayerArrayUtils.filterByZone(result: TPlayerArray; arr: TPlayerArray end; end. + diff --git a/src/props.pas b/src/props.pas index 8a593a5..00f6e64 100644 --- a/src/props.pas +++ b/src/props.pas @@ -112,6 +112,9 @@ TPropsystem = class (TObject) end; +var + propsystem:TPropsystem; + const COLL_BOX = $01; diff --git a/src/qjson.pas b/src/qjson.pas index badc888..a2ec6dc 100644 --- a/src/qjson.pas +++ b/src/qjson.pas @@ -65,7 +65,9 @@ TQJSON = class(TObject) constructor Create(); constructor CreateFromFile(const filename:string); constructor CreateFromHTTP(const url:string); + constructor CreateFromString(const src: string); procedure SaveToFile(const filename:string); + function toString(data:PQJSONData; indent:integer): string; destructor Destroy();override; procedure SetVal(keys:array of const;mire:integer);overload; procedure SetValF(keys:array of const;mire:single);overload; @@ -339,6 +341,98 @@ constructor TQJSON.CreateFromHTTP(const url:string); IdHTTP.Free; end; end; + +constructor TQJSON.CreateFromString(const src: string); +var + i: integer; +begin + i := 1; + root := CreateQJSONFromString(src, i); +end; + +function TQJSON.toString(data:PQJSONData; indent:integer): string; +var + i, hgh: integer; +begin + result := ''; + + case data.typ of + QJSON_NULL: result := result + 'null'; //ez mi lesz lel + + QJSON_INT: result := result + intToStr(data.intval); + + QJSON_FLOAT: result := result + FloatToStrF(data.floatval,ffGeneral,7,1); + + QJSON_BOOLEAN: if data.boolval then result := result + 'true' else result := result + 'false'; + + QJSON_STRING: result := result + '"' + data.strval^ + '"'; + + QJSON_ARRAY: + begin + hgh:=high(data.arrval^); + + result := result + '['; + + if hgh>=3 then + // writeln(fil); + result := result; + + for i:=0 to hgh do + begin + if hgh>=3 then + result := result + StringOfChar(#9,indent+1); + + toString(data.arrval^[i], indent+1); + if i=hgh then + //write(fil) + result := result + else + result := result + ', '; + + if hgh>=3 then + //writeln(fil); + result := result; + + end; + if hgh>=3 then + result := result + StringOfChar(#9,indent); + + result := result + ']'; + end; + + QJSON_MAP: + begin + hgh:=high(data.mapval^); + result := result + '{'; + if hgh>=3 then + //writeln(fil); + result := result; + + for i:=0 to hgh do + begin + if hgh>=3 then + result := result + StringOfChar(#9,indent+1); + + result := result + '"' + data.mapval^[i].key + '": '; + toString(data.mapval^[i].data,indent+1); + if i=hgh then + //write(fil) + result := result + else + result := result + ', '; + + if hgh>=3 then + //writeln(fil); + result := result; + end; + + if hgh>=3 then + result := result + StringOfChar(#9,indent); + + result := result + '}'; + end; + end; +end; procedure TQJSON.SaveToFile2(data:PQJSONData;indent:integer;var fil:TextFile); var diff --git a/src/stickApi.pas b/src/stickApi.pas index 841e3a1..5780c1b 100644 --- a/src/stickApi.pas +++ b/src/stickApi.pas @@ -2,56 +2,226 @@ interface -uses - Classes, - Windows, - SysUtils, - multiplayer, - qjson, - IdHTTP; - -const baseUrl = 'https://stickman.hu/api?mode='; - -//TODO: remove -type TAsync = class(TThread) -end; + uses + Classes, + Windows, + SysUtils, + // + IdHTTP, + IdURI, + IdMultipartFormData, + IdIOHandler, + IdSSLOpenSSL, + // + multiplayer, + qjson, + Sentry, + Scripts, + Utils; -type TApiResponse = record - success: boolean; - data: TQJSON; -end; + const + PROTOCOL = 'https://'; + BASE_URL = 'stickman.hu/api?mode='; + NL = AnsiString(#13#10); -type TApi = class(TObject) -private -public - function GET(const url: string): TApiResponse; -end; + type TApiResponse = record + success: boolean; + data: TQJSON; + end; + + type TApi = class(TObject) + public + class function GET(const route: string): TApiResponse; + class function POST(const route: string; const data: TIdMultipartFormDataStream): TApiResponse; + end; + + procedure printTop(const args: array of const); + procedure printRank(const args: array of const); + procedure printKoth(const args: array of const); + procedure sendBotKills(const args: array of const); + + implementation { - HELPER FUNCTIONS + TApi } -function StreamToString(Stream: TMemoryStream): String; +class function TApi.GET(const route: string): TApiResponse; var - len: Integer; + url: string; begin - len := Stream.Size - Stream.Position; - SetLength(Result, len); - if len > 0 then Stream.ReadBuffer(Result[1], len); + try + url := TIdURI.URLEncode(PROTOCOL + BASE_URL + KillMeUtils.unhungaryify(route)); + sentryModule.addBreadcrumb(makeBreadcrumb('[GET] ' + url)); + + result.success := true; + result.data := TQJSON.CreateFromHTTP(url); + except + on E:Exception do + begin + sentryModule.addBreadcrumb(makeBreadcrumb('[GET] Failed: ' + url + ' - with ' + E.Message)); + result.success := false; + result.data := TQJSON.Create; + end + end; end; -{ - TApi -} -function TApi.GET(const url: string): TApiResponse; +class function TApi.POST(const route: string; const data: TIdMultipartFormDataStream): TApiResponse; +var + url: string; + postResponse: string; + HTTPClient: TIdHTTP; + IdSSLIOHandler: TIdSSLIOHandlerSocketOpenSSL; begin try + url := TIdURI.URLEncode(PROTOCOL + BASE_URL + KillMeUtils.unhungaryify(route)); + sentryModule.addBreadcrumb(makeBreadcrumb('[POST] ' + url)); + + HTTPClient := TIdHTTP.Create(nil); + + IdSSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(nil); + IdSSLIOHandler.SSLOptions.SSLVersions := [sslvTLSv1,sslvTLSv1_1,sslvTLSv1_2]; + HTTPClient.IOHandler := IdSSLIOHandler; + + postResponse := HTTPClient.Post(url, data); + postResponse := stringreplace(postResponse, '\', '', [rfReplaceAll]); + result.success := true; - result.data := TQJSON.CreateFromHTTP(url); + result.data := TQJSON.CreateFromString(postResponse); + except + on E:Exception do + begin + sentryModule.addBreadcrumb(makeBreadcrumb('[POST] Failed: ' + url + ' - with ' + E.Message)); + result.success := false; + result.data := TQJSON.Create; + end + end; +end; + +//----------------------------------------------------------------------------- +// THREADS +//----------------------------------------------------------------------------- + +procedure printTop(const args: array of const); +var + i: Integer; + route, output, line, nev, pont: string; + response: TApiResponse; +begin + route := VariantUtils.VarRecToStr(args[0]); + + try + response := TApi.GET(route); + + if response.success then + begin + for i := 0 to 9 do + begin + nev := response.data.getString(['data', i, 'nev']); + if length(nev) = 0 then nev := '-'; + + pont := response.data.getString(['data', i, 'pont']); + if length(pont) = 0 then pont := ''; + + line := intToStr(i + 1) + '. ' + nev + ' ' + pont; + output := output + NL + line; + end; + scriptsHandler.evalscriptline('display ' + output); + end; + + except + sentryModule.addBreadcrumb(makeBreadcrumb('printTop failed on ' + route)); + //TODO: reportError(E, msg) helyette majd ha nem egy file lesz az output + end; + +end; + +procedure printRank(const args: array of const); +var + route, output, username, mode: string; + response: TApiResponse; +begin + try + username := VariantUtils.VarRecToStr(args[0]); + mode := VariantUtils.VarRecToStr(args[1]); + route := 'rank&nev=' + username + '&type=' + mode; + + response := TApi.GET(route); + + if response.success then + begin + output := response.data.getString(['data', 'rank']); + + scriptsHandler.evalscriptline('display ' + output); + end; + + except + on E:Exception do + begin + sentryModule.addBreadcrumb(makeBreadcrumb('printRank failed on ' + route)); + //TODO: reportError(E, msg) helyette majd ha nem egy file lesz az output + end; + end; +end; + +procedure printKoth(const args: array of const); +var + i: Integer; + output, line, nev, pont, mode: string; + response: TApiResponse; +begin + try + mode := VariantUtils.VarRecToStr(args[0]); + response := TApi.GET(mode); + + if response.success then + begin + for i := 0 to 9 do + begin + nev := response.data.getString(['data', i, 'nev']); + if length(nev) = 0 then nev := '-'; + + pont := response.data.getString(['data', i, 'pont']); + if length(pont) = 0 then pont := ''; + + line := intToStr(i + 1) + '. ' + nev + ' ' + pont; + output := output + NL + line; + end; + + scriptsHandler.evalscriptline('display ' + output); + end; + except + on E:Exception do + begin + sentryModule.addBreadcrumb(makeBreadcrumb('printKoth failed on ' + mode)); + //TODO: reportError(E, msg) helyette majd ha nem egy file lesz az output + end; + end; +end; + +procedure sendBotKills(const args: array of const); +var + route, kills: string; + response: TApiResponse; + postData: TIdMultiPartFormDataStream; +begin + route := 'botkill'; + + try + kills := VariantUtils.VarRecToStr(args[0]); + + postData := TIdMultiPartFormDataStream.Create; + postData.AddFormField('form[nev]', KillMeUtils.unhungaryify(multisc.nev)); + postData.AddFormField('form[kills]', kills); + + response := TApi.POST(route, postData); except - result.success := false; - result.data := TQJSON.Create; + on E:Exception do + begin + sentryModule.addBreadcrumb(makeBreadcrumb('sendBotKills failed')); + //TODO: reportError(E, msg) helyette majd ha nem egy file lesz az output + end; end; end; diff --git a/src/typestuff.pas b/src/typestuff.pas index 2ad242a..f474a4d 100644 --- a/src/typestuff.pas +++ b/src/typestuff.pas @@ -11,7 +11,8 @@ interface math, Zlib, Idwinsock2, - qjson; + qjson, + Variants; const PROG_VER=211000; @@ -21,6 +22,15 @@ interface array4ofbyte=array[0..3] of byte; + TProcedure = procedure; + TProcedureArray = array of TProcedure; + TCallback = procedure of object; + TCallbackArray = array of TCallback; + TIndefiniteProcedure = procedure(const args: array of const); + + TComparatorFunction = function(value: Variant; key: string = ''): boolean; + TMutatorFunction = function(value: Variant; key: string = ''): Variant; + THUDmessage=class(TObject) public value:string; @@ -328,42 +338,6 @@ TExtraPartAsset=record tex:IDirect3DTexture9; end; - TScript=record - name:string; - instructions:array of string; - end; - - T3dLabel=record - pos:TD3DXVector3; - rad:single; - text:string; - end; - - TVecVar=record - pos:TD3DXVector3; - name:string; - end; - - TNumVar=record - num:single; - name:string; - end; - - TStrVar=record - text:string; - name:string; - end; - - TBind=record - key:char; - script:string; - end; - - TTimedscript=record - time:cardinal; - script:string; - end; - TParticleSys=record from,spd:TD3DXVector3; tipus:integer; @@ -384,7 +358,6 @@ TParticleSys=record Tbinmsg=packed array[0..511] of byte; - PVecArr2=^TVecarr2; TVecarr2=array[0..100000] of TD3DXVector3; @@ -577,6 +550,10 @@ Tojjrect=record cpy:Psingle;///FRÖCCCS cpz:Psingle;///FRÖCCCS + addchatindex: integer; + + displaycloseevent: string; + sundir:TD3DXVector3; texturefilelist:string; @@ -651,6 +628,24 @@ Tojjrect=record vizkor1,vizkor2,vizkor3:single; FPSLimit:cardinal = 0; + + teleports:array of TTeleport; + particlesSyses:array of TParticleSys; + particlesProtos:array of TParticleSys; + triggers:array of TTrigger; + leavetriggers:array of TLeaveTrigger; + + labelactive:boolean; + labeltext:string; + + bots_enabled:boolean = true; + + battle:boolean = false; + skirmish:boolean = false; + wave:integer = 0; + accuracy_modif:single = 0; + + safemode:boolean = false; const //FPS limiter FPS_MAX=500; @@ -780,6 +775,9 @@ Tojjrect=record _41:0;_42:0;_43:0;_44:1); } sqrt2=1.414213; +//TODO: move to separate unit +procedure addHudMessage(input:string;col:longword;f:word = 500); + function CustomVertex(x,y,z,nx,ny,nz:single;acolor:longword;au,av,au2,av2:single):TCustomVertex;overload; function CustomVertex(pos:TD3DXVector3;nx,ny,nz:single;acolor:longword;au,av,au2,av2:single):TCustomVertex;overload; //function CustomVertex(pos:TD3DXVector3;n:TD3DXVector3;acolor:longword;au,av:single):TCustomVertex;overload; @@ -985,9 +983,17 @@ procedure logerror(s:string); function rotate2d(x,y,cx,cy:single;angle:single):TD3DXVector2; +procedure AddLAW(av1, av2:TD3DXvector3;akl:integer); +procedure AddNOOB(av1, av2:TD3DXvector3;akl:integer); +procedure AddX72(av1, av2:TD3DXvector3;akl:integer); +procedure AddH31_G(av1, av2:TD3DXvector3;akl:integer); +procedure AddH31_T(av1, av2:TD3DXvector3;akl:integer); + procedure log(s:string); function csicsahdr:boolean; +function variantToStr(value: Variant): string; + var perlin:Tperlinnoise; stuffjson:TQJSON; @@ -1006,6 +1012,15 @@ function csicsahdr:boolean; isnormals:boolean; lang:array of string; weapons:array of TWeaponType; + + noobproj, lawproj, x72proj, h31_gproj, h31_tproj:array of Tnamedprojectile; + lawmesh, noobmesh:ID3DXMesh; + rezg:single; + hatralok:single; + LAWkesleltetes:integer = -1; + mp5ptl:single; + x72gyrs:single; + implementation var @@ -1013,6 +1028,119 @@ implementation Infinity:single=(1.00/0); InfinityMask:cardinal absolute infinity; +function variantToStr(value: Variant): string; +begin + case VarType(value) of + varWord: result := intToStr(value); + varByte: result := intToStr(value); + varSmallInt: result := intToStr(value); + varInteger: result := intToStr(value); + varSingle: result := floatToStr(value); + varDouble: result := floatToStr(value); + varBoolean: if value then result := 'true' else result := 'false'; + varString: result := value; + end; +end; + +procedure AddLAW(av1, av2:TD3DXvector3;akl:integer); +begin + setlength(lawproj, length(lawproj) + 1); + with lawproj[high(lawproj)] do + begin + v1:=av1; + v2:=av2; + v3:=v2; + name:=XORHash2x12byte(v1, v2); + kilotte:=akl; + eletkor:=0; + end; +end; + +procedure AddNOOB(av1, av2:TD3DXvector3;akl:integer); +begin + setlength(noobproj, length(noobproj) + 1); + with noobproj[high(noobproj)] do + begin + v1:=av1; + v2:=av2; + v3:=v2; + name:=XORHash2x12byte(v1, v2); + kilotte:=akl; + eletkor:=0; + end; +end; + +procedure AddX72(av1, av2:TD3DXvector3;akl:integer); +var + tmp1, tmp2:TD3DXVector3; + szog, l:single; +begin + setlength(X72proj, length(X72proj) + 1); + with X72proj[high(X72proj)] do + begin + v1:=av1; + cel:=av2; + d3dxvec3Subtract(v2, av2, av1); + + name:=XORHash2x12byte(av1, av2); + name:=(name + 1) * (name + 2) * (name - 1) * (name - 2) * 134775813; + D3DXVec3Cross(tmp1, v2, D3DXVector3(0, 1, 0)); + D3DXVec3Cross(tmp2, v2, tmp1); + + FastVec3Normalize(tmp1); + FastVec3Normalize(tmp2); + + szog:=((name and $FFFF) / $10000) * D3DX_PI; + + d3dxvec3scale(tmp1, tmp1, cos(szog)); + d3dxvec3scale(tmp2, tmp2, -sin(szog)); + l:=d3dxvec3length(v2); + if l > 0.000001 then + d3dxvec3scale(v2, v2, 1 / l); + d3dxvec3add(v2, v2, tmp1); + d3dxvec3add(v2, v2, tmp2); + d3dxvec3scale(v2, v2, 0.005 * l); + + d3dxvec3subtract(v2, v1, v2); + + v3:=v2; + kilotte:=akl; + eletkor:=0; + end; +end; + +procedure AddH31_G(av1, av2:TD3DXvector3;akl:integer); +begin + setlength(h31_gproj, length(h31_gproj) + 1); + with h31_gproj[high(h31_gproj)] do + begin + D3DXvec3subtract(v1, av2, av1); + D3DXvec3normalize(v1, v1); + D3DXvec3add(v1, v1, av1); + v2:=av1; + v3:=v2; + name:=XORHash2x12byte(v1, v2); + kilotte:=akl; + eletkor:=0; + end; +end; + +procedure AddH31_T(av1, av2:TD3DXvector3;akl:integer); +begin + setlength(h31_tproj, length(h31_tproj) + 1); + with h31_tproj[high(h31_tproj)] do + begin + D3DXvec3subtract(v1, av2, av1); + D3DXvec3normalize(v1, v1); + D3DXvec3add(v1, v1, av1); + v2:=av1; + v3:=v2; + name:=XORHash2x12byte(v1, v2); + kilotte:=akl; + eletkor:=0; + end; +end; + function clip(low,high:single;alany:single):single; begin if alany