Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / [Cleanup] Global Functions
- - By Newton [es] Date 2009-07-15 10:30 Edited 2010-02-19 00:17
strike = already removed in my local repos

Functions that I would like to remove from System.c4g:
Commits.c

  • Nor(bool con1, bool con2, bool con3, bool con4, bool con5)

  • Bounce(int iPower)

  • RndMakeCrewMember(int iPlayer, id ID)

  • SemiExplode(int iLevel, int incidence)

  • PlaceInMaterial(id def, int material, int _retries) (PlaceObjects does the same and more)

  • CastObjectsX(iddef,am,lev,x,y,angs,angw,callback) (instead extend the original function)

  • CastPXSX(string mat,int am,int lev,int x,int y,int angs,int angw) (instead extend the original function)

  • GetMaterialColorX(mat, num) (with the color determined by the texture, this is obsolete like GetMaterialColor)

  • FindConstructionSiteX(id idDef, &iVarX, &iVarY) (change the FindConstructionSite function to do what this function does now - references instead of Var(...))



C4.c

  • ForcePosition(object obj, int x, int y)

  • AssignRemoval(object obj)

  • Barrel-Functions - why does this need to be global?

  • SetOnlyVisibleToOwner(bool fVisible, object pObj) (we don't need this wrapper around SetVisibility)

  • GetOnlyVisibleToOwner(object pObj)

  • MessageBoard(string msg, par0, par1, par2, par3, par4, par5, par6, par7, par8)



Helpers.c

  • CastlePanic() (???)

  • CastlePanicResort(object pObj1, object pObj2)



JumpAndRun.c, Magic.c - neither magic nor the controls have been touched yet, so I am leaving them for now.

C4Script.cpp

  • Or, And, Not, BitAnd, Sum, Mul, Mod, Sub, Div, Pow, LessThan, GreaterThan, SEqual

  • Smoke, Bubble - move to System.c4g

  • ObjectSetAction - obsolete: object->SetAction()

  • SoundLevel - Sound can do everything that SoundLevel can

  • SetSkyFade, SetSkyColor, GetSkyColor, GetMaterialColor, SetMaterialColor, IsNewGfx

  • Value - One can ask the defcore

  • FindObject, FindObjectOwner, ObjectCount - rename FindObject2 to FindObject, ObjectCount2 to ObjectCount



Then, reorder it and document all remaining functions + remove docs for these.
Parent - - By Zapper [de] Date 2009-07-15 11:13

>CastlePanic() (???)


CastlePanic normally resorts a castle so that every castle part is in front of every other castle part that is below the first one. But I think the function does not work atm. At least I had to write my own once
Parent - By Caesar [de] Date 2009-07-16 17:29
Phew, I remember that it worked (partially) when I was changing the castles of MmgZ. Oh, I even use it in the Scenscript... can't be too buggy.
Parent - - By Newton [es] Date 2009-07-15 12:36 Edited 2009-07-15 12:47
Another big thing would be to strip all functions of the obj-Parameter. E.g. GetXDir(obj) will be obj->GetXDir();

Plus, assume that all scripts are #strict 2 so #strict 2 doesn't need to be written down.

What do the devs think about this?
Parent - - By Günther [de] Date 2009-07-15 13:00
As long as the object parameter is the last parameter, it doesn't really matter. But I really want to change Message(). But we should try to make conversion easy, ideally automated, to alleviate the harm from these changes.
Reply
Parent - - By Zapper [de] Date 2009-07-15 13:12

>As long as the object parameter is the last parameter, it doesn't really matter.


But that would mean that we could not add other parameters later on. The object parameter would not be the last one anymore and everything would be mixed up again
Parent - - By Günther [de] Date 2009-07-15 17:50
Yes, but extending functions by adding more parameters isn't the best style anyway, because it creates ugly interfaces.
Reply
Parent - By Zapper [de] Date 2009-07-15 18:06
yupp, but that is the way it was done up to now. :)
Parent - - By Caesar [de] Date 2009-07-16 17:30
What's better? Named Pararmeters?
Parent - By Fireknight [ch] Date 2009-07-16 20:37
Like Windows? Just add an Ex at the end of the function. (e.g GetDirEx)
Reply
Parent - By Günther [de] Date 2009-07-17 11:02
That might be an option, but for things like Sound there really should be an sound instance object which you can further manipulate.
Reply
Parent - - By Newton [es] Date 2009-07-15 15:02
Whats the matter with Message?
Parent - - By Günther [de] Date 2009-07-15 17:25
Message actually has often-used parameters after the object parameter, and I fell into that trap myself.
Reply
Parent - By MrBeast [de] Date 2009-07-15 18:04
May seperate into Message and GlobalMessage? Message shows the Message above the object which called it. And GlobalMessage shows it "globally".
Reply
Parent - By Caesar [de] Date 2009-07-16 17:31
Oh, and MakeCrewMember as well as Message?
Parent - - By Günther [de] Date 2009-07-15 12:54
The various message functions from C4Script.cpp should also be reevaluated.
Value might be handy if it does the value-overriding callbacks, but we should probably replace those with a property. (I've only one more homework assignment and one exam this semester, so I should be able to write the savegame code for and merge this soon)
I already removed the documentation for these functions: And AssignVar BitAnd Dec DecVar Div Equal Global GreaterThan Inc IncVar IsNewgfx LessThan Local Mod Mul Not Or SEqual SetGlobal SetLocal SetMaterialColor SetSkyColor SetSkyFade SetVar Sub Sum Var
Reply
Parent - - By Newton [es] Date 2009-07-15 12:58

>I already removed the documentation for these functions: And AssignVar BitAnd Dec DecVar Div Equal Global GreaterThan Inc IncVar IsNewgfx LessThan Local Mod Mul Not Or SEqual SetGlobal SetLocal SetMaterialColor SetSkyColor SetSkyFade SetVar Sub Sum Var


Yeah I noticed. You forgot GetMaterialColor, though ;-)

Regarding the docs. I only find the German documentation in the repos, where are the English XMLs?
Parent - By Günther [de] Date 2009-07-15 13:01

> I only find the German documentation in the repos, where are the English XMLs?


In en.po.
Reply
Parent - By Newton [es] Date 2009-07-15 13:26

>Value might be handy if it does the value-overriding callbacks


GetValue does this iirc.
Parent - - By Günther [de] Date 2009-07-15 13:04 Edited 2009-07-15 13:07

> Barrel-Functions - why does this need to be global?


Probably because they were in the engine once. They might also really be used by multiple objects.

> AsyncRandom - what is this?


As the name says - a random function which returns unsynchronized random values. There are very few uses for that, but I think they exist.
Reply
Parent - - By MrBeast [de] Date 2009-07-15 14:48

>> AsyncRandom - what is this?
>As the name says - a random function which returns unsynchronized random values. There are very few uses for that, but I think they exist.


You've gave me a new idea: how about asynchrous objects? These objects are not synchronized and can not change real objects. But unlike normal objects the can get asynchrous values like screensize, the curent real time and so on. This would be great for GUI and HeadUp Displays.
Reply
Parent - By Newton [es] Date 2009-07-15 14:55
HUDs must be synchronous too since it is possible that a player follows the view of another player.
Parent - - By Sven2 [us] Date 2009-07-15 16:10
I had considered this for a while - along with async script contexts, which have a reduced set of functions. But this would be a) an enormous amount of work in the engine and b) very complicated to handle for the scripter. I think it's better to keep things simple for the scripter, i.e. just have them assume every client sees the same thing.
Parent - By Günther [de] Date 2009-07-15 17:44
I'm not sure about the enormous amount of work. Reviewing and possibly changing every function would be impossible, but creating a (very) short whitelist might be workable. I'd do this in the parser - disallow access to global variables and functions not marked as async, and you could implement things like particles which accelerate towards an object. Of course, the usefulness depends on the length of the whitelist, and lots of essential functions like FindObjects are unsafe. Time spent on optimizing normal objects might be more fruitful.
Reply
Parent - By Fireknight [ch] Date 2009-07-16 10:31

>RndMakeCrewMember(int iPlayer, id ID)


Why? That function is used a lot.
Reply
Parent - By Kanibal [de] Date 2009-07-18 12:06
I liked "RndMakeCrewMember" very much. It's makes relaunchs or something much easier.
Reply
Parent - By Caesar [de] Date 2009-07-19 18:30
What about DecVar, IncVar, SetVar and AssingVar?
And btw, do we still need FindObject, FindObjectOwner and ObjectCount?
Parent - By Mortimer [de] Date 2009-07-21 11:12
The Eclipse Plugin for Clonk provides some still experimental functionality to auto convert old-style scripts to #strict (2) scripts. Since the functionality operates on a kind of abstract syntax tree it might also possible to extend it to "auto modernize" scripts in other ways. Just wanted to point that out </advertisment>
Reply
Parent - - By Isilkor Date 2009-07-22 07:37 Edited 2009-07-22 07:47
Functions I have converted to C4Script functions so far:
  • ExtractLiquid

  • FlameConsumeMaterial

  • LaunchEarthquake

  • LaunchLightning

We can probably also remove GBackSolid et al., but I haven't considered the performance implications.

Functions removed without replacement, and rationale:
  • LaunchVolcano (already have a replacement in Commits.c)

  • Var, as well as (Set/Inc/Dec)Var (obsolete due to named variables)

  • SetLocal/SetGlobal (obsolete since Local/Global returns a reference)

  • ObjectCall (obsolete, use arrow syntax and Call)

  • Set/Inc/Dec (obsolete)


Also I've changed SetColor to use 32bit colors, like SetColorDw did before. The latter has been removed. Same thing with GetColor.
Reply
Parent - - By MrBeast [de] Date 2009-07-22 11:07

>ObjectCall (obsolete, use arrow syntax and Call)


ObjectCall was good to call a command out of a string. You can make a almost simillar result with "pObj->eval(szString);" or "pObj->Call(szString);" but I dont know how the performace is.
Reply
Parent - By Luchs [de] Date 2009-07-22 12:11

>use arrow syntax and Call


^-
Parent - By Günther [de] Date 2009-07-22 13:32
GetMaterialVal is not a fast function, and FlameConsumeMaterial is one of the functions responsible for burning oil being slow.
Reply
Parent - By Newton [es] Date 2009-07-22 17:32
Done. Things I didnt touch after all:
FindConstructionSiteX(id idDef, &iVarX, &iVarY) - should be rescripted when the hammer is scripted.
Barrel-functions - should be rescripted when the barrel is scripted.
Smoke, Bubble - I don't like to go too deep into the engine ... ;-)
LaunchRain - (the documentation part:) should be rescripted when the cloud is rescripted
Parent - - By Maikel Date 2009-09-05 10:26
Since the replacement of FindObject with FindObject2, it is impossible to find objects with the specified second action target.
I think Find_ActionTarget should be extended in such a way that you can specify the first action target, the second action target, or both. I.e. the specified object must be either the first or the second action target (this is the old FindObject functionality).
Parent - By Newton [de] Date 2009-09-05 11:09
I didn't even know there is such a thing as the second action target
Parent - - By Günther [de] Date 2009-09-05 11:39
I just used Find_Func() when I had to search for an object with a specific second actiontarget (for the pump-the-lava-away tutorial in CR). I could have modified the engine, but I didn't want to find a line with the specific object at any end, but only a line with the object at the right end. I could have added Find_ActionTarget2, but I didn't think it was generally useful enough.

But if our lines become bidirectional, always looking for both action targets would make more sense. Want to make a patch? I'd guess it would be only one or two lines in src/game/script/C4FindObject.cpp.
Reply
Parent - By Maikel Date 2009-09-05 14:23
So I did, I hope I patched it right.

>Search criterion: finds all objects that have the specified action target, either the first or the second.


Should be changed in the docu.

Find_ActionTarget(object pActionTarget) will now find all objects having pActionTarget as one of its action targets, not only the first.

ISC license is understood.
Attachment: Find_ActionTarget.patch (691B)
Up Topic Development / Developer's Corner / [Cleanup] Global Functions

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill