Page 1 of 1
Feature placer code review.
Posted: 12 Jul 2014, 04:43
by smoth
the code.
There are a few things I am not altering.
[*] I am not altering my use if tabs for spaces.
[*] I am not removing my localized spFunctionName, they are shorthand and I think it makes the code cleaner to read.
[*] I am not switch the pairs to a for #tablename loop or using next().
Since 2008, I have never experienced an issue with this code failing in my project. Any map that ever used it, also included the features/units. I have been told recently that my old code was not up to snuff. So instead of being lambasted again for my code apparently being poor. I did a minor update and now am putting it up here for review/critique. There was a specific complaint that the code is not within a function, I am not aware of a function that would have the features placed before gamesetup() is called. Should you know that function, do let me know so that I can update that part of this code.
ready, set, go!

Re: Feature placer code review.
Posted: 12 Jul 2014, 04:57
by smoth
First update from KingRaptor's feedback:
Now with preload()
Anyone else?
Re: Feature placer code review.
Posted: 12 Jul 2014, 13:01
by Jools
smoth wrote:the code.
There are a few things I am not altering.
[*] I am not altering my use if tabs for spaces.
Tabs are better than spaces. The tab character can be any number of columns depending on environment, but space is always one. What idiot presses the space key 5 times when he wants one column of 5 spaces? That's the function of the tab key anyway.
Re: Feature placer code review.
Posted: 12 Jul 2014, 13:54
by jK
You should keep the level of indentations <=3, when reaching lvl 5 you should split of code in a subfunction.
http://paste.springfiles.com/view/8f83c8d5
(got a c&p error in L80 & L81, too lazy to fix the pastebin)
Jools wrote:smoth wrote:the code.
There are a few things I am not altering.
[*] I am not altering my use if tabs for spaces.
Tabs are better than spaces. The tab character can be any number of columns depending on environment, but space is always one. What idiot presses the space key 5 times when he wants one column of 5 spaces? That's the function of the tab key anyway.
He also uses as whitespace between code and not just front indentation. That's bad style cause it makes indentation platform/system dependent (on the size of a tab).
Re: Feature placer code review.
Posted: 12 Jul 2014, 14:20
by dansan
Jools wrote:smoth wrote:[*] I am not altering my use if tabs for spaces.
Tabs are better than spaces. The tab character can be any number of columns depending on environment, but space is always one. What idiot presses the space key 5 times when he wants one column of 5 spaces? That's the function of the tab key anyway.
That is not necessary. My IDE inserts x spaces when tab is pressed and the cursor is at the beginning of a line. It multiplies lvl * x for correct indentation in nested commands, and removes x spaces when hitting the backspace button if the cursor is in front of the 1st non-whitespace character.
The result is, that you neither see nor feel, if actually tabs or spaces are stored on disk, it's just a configuration switch. Ofc there is a function to convert one into the other for the whole file.
Re: Feature placer code review.
Posted: 12 Jul 2014, 14:47
by Jools
Ok, but a tab character takes less space than several space characters => smaller file
Re: Feature placer code review.
Posted: 12 Jul 2014, 18:46
by smoth
dansan wrote:Jools wrote:smoth wrote:[*] I am not altering my use if tabs for spaces.
Tabs are better than spaces. The tab character can be any number of columns depending on environment, but space is always one. What idiot presses the space key 5 times when he wants one column of 5 spaces?
no idea but why not alter it to do tabs instead? if you don't like the tab size most also allow for a setting to set the actual size of tabbing. I don't see any value in keeping the spaces
He also uses as whitespace between code and not just front indentation. That's bad style cause it makes indentation platform/system dependent (on the size of a tab).
Example line and suggestion for improvement please?
Re: Feature placer code review.
Posted: 12 Jul 2014, 22:55
by smoth
Version 3
Made a few changes suggested by JK's edit, still leaving the spFunctionName stuff as I find it cleaner to read.
Re: Feature placer code review.
Posted: 15 Jul 2014, 19:00
by PicassoCT
dansan wrote:Jools wrote:smoth wrote:[*] I am not altering my use if tabs for spaces.
Tabs are better than spaces. The tab character can be any number of columns depending on environment, but space is always one. What idiot presses the space key 5 times when he wants one column of 5 spaces? That's the function of the tab key anyway.
That is not necessary. My IDE inserts x spaces when tab is pressed and the cursor is at the beginning of a line. It multiplies lvl * x for correct indentation in nested commands, and removes x spaces when hitting the backspace button if the cursor is in front of the 1st non-whitespace character.
The result is, that you neither see nor feel, if actually tabs or spaces are stored on disk, it's just a configuration switch. Ofc there is a function to convert one into the other for the whole file.
This IDE surely encourages copy and pasting your code into other working enviroments? All you have to do is click the options together, safe the file, open it in the other ide, but you the need arises allmoist never, cause the path is obsticled and structed.
Spaces can not be maintained properly by projects using various ides.