Chaosforge Forum

  • March 28, 2024, 13:37
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: 1 2 [All]

Author Topic: "Destroy" method override in Vnode?..  (Read 23280 times)

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
"Destroy" method override in Vnode?..
« on: December 27, 2007, 04:35 »

///
       destructor  Destroy; override;
///

...even though it consecutively inherits from TVClass and TVObject, neither of which has defined destructor.

Why?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #1 on: December 27, 2007, 11:31 »

TObject, the base class of all objects in FreePascal has a Destroy method (note that you can call X.Destroy on ANY object in FreePascal, even if it doesn;t define it's own destructor). The usage of it is for data structures -- so they can hold any sets of objects, and be sure that if they call Object.Destroy, then all data will be properly disposed of.

P.S. What's up lately? :)
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #2 on: December 27, 2007, 12:59 »

Aha, I see it now. God damn the FreePascal documentation for omitting heaps of useful information and being an overall mess.

A second question: I somehow managed to get program crashing with calling the TNode.Free procedure, for which I cannot find any description and which doesn't look like a simple Destructor. What is is, where it comes from and what it really does? Is it safe to replace it with merely a TNode.Destroy (which doesn't produce any crashes) or there's a catch?

Awww... lots of stuff. I'm almost ready taking on the Universe with limited public release of "HoaH", which now mostly requires some polish (functionality-wise it only lacks some easier-to-implement stuff which isn't really necessary to prove geniality of the concept).

In regards to Life (TM): I've got my first serious work (software tester at one of the largest Lithuanian IT companies), I have an uncoming session on me, and this Spring I'm getting engaged (-:. Life's bright, life's taxing. Life is good.


p. s. My avatar seems outdated in regards to yours :).
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #3 on: December 27, 2007, 13:54 »

A good programming practice is to never use Free or Destroy at all, but to always use FreeAndNil(Object) -- from SysUtils. It's the safest way (if the object is already nil, then nothing happens).

As to real life -- OMG! O.o

Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #4 on: December 29, 2007, 05:00 »

Kornel, shouldn't TNode.Detach include Parent:=nil?..
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #5 on: December 29, 2007, 06:06 »

Sometimes after detaching we might still like to know the parent. And leaving it uncleared doesn't open too any mistakes anyway.
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #6 on: January 01, 2008, 13:09 »

After the major exam (World Literature on Jan. 7) is over, I'm planning on attempting a new iteration of functionality adaptation from Valkyrie to Colossus (Valkyrion Stage 2). I wonder if you have any interest in whatever expansions to Valkyrie functionality might be made from Colossus, and what would be the best way of describing and proposing them to V. - most probably SVN commits would be an inappropriate way.
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #7 on: January 01, 2008, 13:34 »

Depends on what you want to expand -- it may be already planned. Just hint me hwat you are thinking about :)
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #8 on: January 04, 2008, 15:13 »

I've been primarily thinking about revamping menus - I recall those used in Berserk! being a hardcoded non-reusable nightmare.

AFAIR, you are using LGPL for Valkyrie? If I'm going to distribute software which uses modified parts of it, what should I include in my sources (besides the typical kudos) - complete LGPL license in addition to the one I use (GPL3)?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #9 on: January 04, 2008, 17:02 »

Umm, have you seen, vtextut.pas, and TTextMenu in it? Berserk! uses those too now. And as for general GUI stuff, I'm planning to do a proper and compete GUI system in Valkyrie for the use of especialy Sa^D^D... another project of mine :P

As for license, my friend, I give you the right to relicense it under what you want :P.
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #10 on: January 05, 2008, 03:28 »

Yep, my Berserk! sources are rather outdated. I'll check the latest ones.

You mean ASCII-based GUI? When is the expected date of release (with half a year precision :-P)?

As for license, my friend, I give you the right to relicense it under what you want :P.

Wow, thanks. Does this include relicensing rights to whatever moment I finally start using complete Valkyrie, or only to current transitional stage?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #11 on: January 05, 2008, 08:42 »

with a half year precision? In half a year :P.

Seriously though -- I need a simple GUI to start working on S anyway. :P

Whenever you like. The FP version of Valkyrie I may release under a BSD license anyway.
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #12 on: January 06, 2008, 12:32 »

Latest Berserk sources are beautiful :).

What does the "class function\procedure" mean?

Like
"class procedure Skill;"
in TBerserkCharGen (bruichar)
description?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #13 on: January 06, 2008, 12:44 »

a class procedure/function is not tied to the instance. That is -- you don't have to create such a object, you can call that function/procedure directly.
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #14 on: January 06, 2008, 13:19 »

Looks like this time I'll migrate completely :).

You are using AnsiStrings everywhere (e. g. default Output.DrawString). Aren't those time\resource-wasting overkill?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #15 on: January 06, 2008, 13:39 »

Yeah. Insted of 1 microsecond, you'll use 10 microseconds. So your roguelike will not quickly on a PC 386 DX2 -- on the others there will be no difference :P. Come on, we're writing text games here! DiabloRL used to LINEARY check it's WHOLE database each time it wanted any SINGLE attribute. And it was as fast as the others. TBH, you'd need to do some pretty fucked up shit to make a roguelike as slow as Dwarf Fortress :). Anyway, all those Java roguelikes have a massively bigger overhead on *each* operation, and still they work fast, so AnsiStrings are a yes, yes :P.

P.S. BTW, I started work on the GUI classes ^^
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #16 on: January 06, 2008, 13:57 »

\Yeah. Insted of 1 microsecond, you'll use 10 microseconds. So your roguelike will not quickly on a PC 386 DX2 -- on the others there will be no difference :P.\

LOL.


\TBH, you'd need to do some pretty fucked up shit to make a roguelike as slow as Dwarf Fortress :).\

I still have to scale BaL's 1 lair, 1 village, 1 army x100 and see what happens (-: Though lags produced will have nothing to do with AnsiStrings...


\Anyway, all those Java roguelikes have a massively bigger overhead on *each* operation, and still they work fast\

We haven't seen JADE yet. It might compete with DF in category "Angel of Sluggishness".

\so AnsiStrings are a yes, yes :P\

*Persuasion roll successful*

\BTW, I started work on the GUI classes\

Ah, now I know their EXACT release date. It's when I finish my own berserk-based implementation :). And they'll be up the same moment I'll check up the forums to brag about it...


\BTW, I started work on the GUI classes ^^\

Like vtextui in the latest SVN?
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #17 on: January 06, 2008, 16:19 »

\Anyway, all those Java roguelikes have a massively bigger overhead on *each* operation, and still they work fast\

We haven't seen JADE yet. It might compete with DF in category "Angel of Sluggishness".
GenRogue might ^^

Ah, now I know their EXACT release date. It's when I finish my own berserk-based implementation :). And they'll be up the same moment I'll check up the forums to brag about it...

Like vtextui in the latest SVN?
Yep.

Try this:
Code: (delphi) [Select]
program s;

{$mode objfpc}{$H+}

uses
  Classes, SysUtils,
  vsystems, vinput, voutput, vtinput, vtoutput,
  vtextut, vnode, vtextui, vutil;

var UI : TTextUIArea;
    W  : TTextWindow;
    TM : TTextMenu;
    TS : TTextUISeparator;

begin
  Systems.Add(Output,TTextModeOutput.Create);
  Systems.Add(Input,TTextModeInput.Create);
  UI := TTextUIArea.Create(nil);
  TTextModeOutput(Output).UI := UI;

  TTextWindow.Create( UI, NewRectXY(10,2,50,15) );
  W := TTextWindow.Create( UI, NewRectXY(15,4,65,20));
  W.Title := 'S*** UI';

  TS := TTextUISeparator.Create( W, False{Vertical}, 30 );
  TTextContent.Create( TS.Left, 'Welcome to the new not abstract '+
    'and fully working Valkyrie text user interface that was specificaly '+
    'designed and written for @RS*****@> but will also be used in '+
    'other Chaosforge roguelikes.' );
  TM := TTextMenu.Create( TS.Right );
  TM.Add( 'Option 1' );
  TM.Add( 'Option 2' );
  TM.Add( 'Option 3' );
  TM.Add( 'Option 4', false );
  // false means inactive - can't be chosen
  TM.Add( 'Option 5' );
  TM.Run;
end.

Works for revision 97

Note that memory management is completely automatic -- we even create anonymous (unnamed) classes! :P Another funny thing is that the interface will be drawn everytime you call Output.Update. The third cool thing is, that to get rid of the window, you just need to call FreeAndNil(W), and that's it xP.

HOWEVER, this is very volatile -- it may change any minute :P
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #18 on: January 06, 2008, 16:55 »

OK, I'll try it tomorrow (actually, today) after the exam - H-Hour is rapidly approaching :).
Logged

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #19 on: January 07, 2008, 10:01 »

E:\Elwin\Yhacking\Pascal\Valk\vtoutput.pas(68,18) Error: There is no method in an ancestor class to be overridden: "TTextModeOutput.ScreenShot(const AnsiString, Byte="0")"
E:\Elwin\Yhacking\Pascal\Valk\vtoutput.pas(70,17) Error: There is no method in an ancestor class to be overridden: "TTextModeOutput.ScreenShotExt(Byte="0"):AnsiString"
\\\

If I comment override out:

E:\Elwin\Yhacking\Pascal\Valk\vrltools.pas(383,47) Error: Incompatible type for arg no. 1: Got "<address of procedure(const ShortString,const ShortString);Register>", expected "<procedure variable type of procedure(const AnsiString,const AnsiString);Register>"
E:\Elwin\Yhacking\Pascal\Valk\vini.pas(346,16) Hint: Found declaration: TINI.QuerySection(TINIFileCallbackProcedure)
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #20 on: January 07, 2008, 11:45 »

Do you use FPC 2.2.0?
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #21 on: January 07, 2008, 13:41 »

Lazarus 0.9.24 (11-14-2007) - fpc 2.2.0
Logged

Kornel Kisielewicz

  • God Hand
  • Apostle
  • *
  • *
  • Offline Offline
  • Posts: 4562
    • View Profile
    • http://chaosforge.org/
Re: "Destroy" method override in Vnode?..
« Reply #22 on: January 07, 2008, 20:20 »

Check you Compiler options.../Parsing/Syntax Options -- the only ones I have checked are Delphi 2 extensions, C Sty;e operators, Allow Label, and C++ style inline. If that helps, I'll put all the options into the valkyrie files so next time you will be able to set the options as you wish.
Logged
at your service,
Kornel Kisielewicz

Igor Savin

  • Elder Chaos Guard
  • Second Lieutenant
  • *
  • *
  • Offline Offline
  • Posts: 180
    • View Profile
Re: "Destroy" method override in Vnode?..
« Reply #23 on: January 08, 2008, 02:06 »

You have no "Use AnsiStrings" turned on?..

Hmmm, anyway, those are the same settings as I have. I'll try it with the latest Lazarus snapshot, maybe it'll help...

\If that helps, I'll put all the options into the valkyrie files so next time you will be able to set the options as you wish\

That'd come handy.
Logged
Pages: 1 2 [All]