Skip to content

Basic storage and process modernization, basic API, basic bot kills, basic Sentry, scripts unit#10

Open
dagoddamnlazysnake wants to merge 15 commits into
developfrom
feature/thread_handler
Open

Basic storage and process modernization, basic API, basic bot kills, basic Sentry, scripts unit#10
dagoddamnlazysnake wants to merge 15 commits into
developfrom
feature/thread_handler

Conversation

@dagoddamnlazysnake

Copy link
Copy Markdown

No description provided.

@dagoddamnlazysnake dagoddamnlazysnake self-assigned this Sep 27, 2021
@dagoddamnlazysnake dagoddamnlazysnake added the enhancement New feature or request label Sep 27, 2021
@dagoddamnlazysnake

Copy link
Copy Markdown
Author

#9 -hez képest több fix bekerült ide, bot toplistához kell az api rework.

@dagoddamnlazysnake dagoddamnlazysnake changed the title WIP | Feature/thread handler Feature/thread handler Sep 29, 2021
Comment thread src/DynamicArray.pas

implementation

procedure TDynamicArray.init;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ezt még át akarom pakolni privátba, csak elfelejtettem.

Comment thread src/Redux.pas Outdated
end;
end;

{

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ezt akár ki is lehetne venni, mert a wikin megvan.

Comment thread src/Sentry.pas
json, fname: string;
i: Integer;
begin
//open output file

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most, hogy van API POST akár már azt is használhatná de nem akartam ebbe a releasebe még azt is beszuszakolni.

Comment thread src/Stickman.dpr Outdated
{$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 undebug} //Remove dot for release, add dot for dev

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Azottmaradt, bár nem is emlékszem, hogy ezt csak RC mellett szoktuk-e kivenni.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developon release utan vissza szoktam rakni egy 'Return to dev' commitban. Rossz commitbol inditottad az elso branchet.

Comment thread src/stickApi.pas Outdated
end;
const
PROTOCOL = 'https://';
BASE_URL = 'localhost/api?mode='; //'stickman.hu/api?mode=';

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ezt tesztelés után vissza kell majd írni, mergelni így nem kéne.

Comment thread src/stickApi.pas Outdated
result.data := TQJSON.CreateFromHTTP(url);
except
result.success := false;
result.data := TQJSON.Create;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Innen elmaradt a postResponse-ból serializálás.

Comment thread src/stickApi.pas
kills := VariantUtils.VarRecToStr(args[0]);

postData := TIdMultiPartFormDataStream.Create;
postData.AddFormField('form[nev]', KillMeUtils.unhungaryify(multisc.nev));

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ez nem a legjobb, de így lekezeli a speckó karaktereket is és nem kell szerver oldalon encodinggal hülyéskedni.

Comment thread src/Sentry.pas
begin
with _metadata do
begin
isDev := {$IFDEF undebug} false {$ELSE} true {$ENDIF};

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flags are not global. Should create separete unit for them later.

Comment thread src/Stickman.dpr Outdated
{$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 undebug} //Remove dot for release, add dot for dev

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Developon release utan vissza szoktam rakni egy 'Return to dev' commitban. Rossz commitbol inditottad az elso branchet.

Comment thread src/Stickman.dpr Outdated
procedure reportBotKills(const args: array of const);
begin
bootkillsendtim := 500;
if (botkills <= 0) exit;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Syntax error! Missing 'then'. Compile (and run) before commit!

Comment thread src/Stickman.dpr Outdated
cloud_color:longword;
mati:TMaterial;
tmpbol:boolean;
tmpbol:boolean;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much better!

Comment thread src/Scripts.pas Outdated
value:single;
r:TSingleArray;
begin
// ! a vektor v�ltoz�

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO rewrite old comments in English so less stuff breaks when encoding hits the fan

@dagoddamnlazysnake dagoddamnlazysnake changed the title Feature/thread handler Basic storage and process modernization, basic API, basic bot kills, basic Sentry, scripts unit Oct 1, 2021
Comment thread src/qjson.pas Outdated
i: integer;
begin
i := 1;
CreateQJSONFromString(src, i);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return value not used. Assign to root.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should skip if src is empty.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we should skip if src is empty.

CreateQJSONFromString handles that case, will return QJSON_NULL accurately.

Most of these directives provide conditional compilation for developer-only features. Storing them in memory poses security issues. Even though in this case (Sentry) it does end up in the memory, it is only for convenience and not used to add any critical code, we should not promote indirect usage of directives.
@dagoddamnlazysnake

Copy link
Copy Markdown
Author

TODO: add explicit null return or throw on critical short circuit checks

@wasweb wasweb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some changes in this branch

Comment thread src/ThreadHandler.pas Outdated
Comment on lines +18 to +47
function callback: TIndefiniteProcedure; //ez lesz a thread execute
end;

type TCallbackThread = class (TThread)
private
_callback: TIndefiniteProcedure;
protected
procedure Execute(const args: array of const); overload;
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; //�jat ind�t, suspend marad ahogy volt
//TODO: procedure all(keys: array of string; parallel: boolean = false);
//TODO: procedure race(keys: array of string);
//TODO: execute(key / keys / null) //csak ha van is suspended, nem ind�t �jat
//TODO: suspend(key / keys / null)
//TODO: terminate(key / keys / null)
//TODO: waitFor(key / keys / null) //az lemegy, t�bbi suspended

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Translate comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

3 participants