Merge branch 'master' into jgrpp
# Conflicts: # bin/baseset/no_sound.obs # bin/baseset/orig_dos.obg # bin/baseset/orig_dos.obs # bin/baseset/orig_dos_de.obg # bin/baseset/orig_win.obg # bin/baseset/orig_win.obm # bin/baseset/orig_win.obs # src/aircraft_cmd.cpp # src/blitter/32bpp_anim.cpp # src/blitter/32bpp_anim.hpp # src/blitter/32bpp_base.cpp # src/blitter/32bpp_base.hpp # src/blitter/8bpp_base.cpp # src/blitter/8bpp_base.hpp # src/blitter/common.hpp # src/group_gui.cpp # src/lang/korean.txt # src/linkgraph/linkgraph_gui.cpp # src/saveload/saveload.cpp # src/town_cmd.cpp # src/viewport.cpp # src/viewport_func.h
This commit is contained in:
@@ -24,6 +24,8 @@ BEGIN {
|
||||
skiptillend = 0;
|
||||
}
|
||||
|
||||
{ CR = (match($0, "\\r$") > 0 ? "\r" : "") }
|
||||
|
||||
/@enum/ {
|
||||
print;
|
||||
add_indent = gensub("[^ ]*", "", "g");
|
||||
@@ -42,7 +44,7 @@ BEGIN {
|
||||
active_comment = 0;
|
||||
comment = "";
|
||||
file = filearray[i];
|
||||
print add_indent "/* automatically generated from " file " */"
|
||||
print add_indent "/* automatically generated from " file " */" CR
|
||||
while ((getline < file) > 0) {
|
||||
sub(rm_indent, "");
|
||||
|
||||
@@ -65,7 +67,7 @@ BEGIN {
|
||||
}
|
||||
|
||||
# Forget doxygen comment, if no enum follows
|
||||
if (active_comment == 2 && $0 != "") {
|
||||
if (active_comment == 2 && $0 != "" CR) {
|
||||
active_comment = 0;
|
||||
comment = "";
|
||||
}
|
||||
@@ -78,22 +80,21 @@ BEGIN {
|
||||
sub(" *//", " //");
|
||||
|
||||
match($0, "^( *)([A-Za-z0-9_]+),(.*)", parts);
|
||||
enumwidth - length(parts[2])
|
||||
|
||||
if (parts[3] == "") {
|
||||
printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] ",")
|
||||
if (parts[3] == "" CR) {
|
||||
printf "%s%s%-45s= ::%s\n", add_indent, parts[1], parts[2], (parts[2] "," CR)
|
||||
} else {
|
||||
printf "%s%s%-45s= ::%-45s%s\n", add_indent, parts[1], parts[2], (parts[2] ","), parts[3];
|
||||
printf "%s%s%-45s= ::%-45s%s\n", add_indent, parts[1], parts[2], (parts[2] ","), (parts[3]);
|
||||
}
|
||||
} else if ($0 == "") {
|
||||
print "";
|
||||
} else if ($0 == "" CR) {
|
||||
print "" CR;
|
||||
} else {
|
||||
print add_indent $0;
|
||||
}
|
||||
}
|
||||
|
||||
if (match($0, "^ *\\};") > 0) {
|
||||
if (active != 0) print "";
|
||||
if (active != 0) print "" CR;
|
||||
active = 0;
|
||||
}
|
||||
}
|
||||
|
192
src/script/api/generate_widget.vbs
Normal file
192
src/script/api/generate_widget.vbs
Normal file
@@ -0,0 +1,192 @@
|
||||
Option Explicit
|
||||
|
||||
' $Id$
|
||||
'
|
||||
' This file is part of OpenTTD.
|
||||
' OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
|
||||
' OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
' See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Dim FSO, filename, skiptillend, eof
|
||||
Set FSO = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
filename = "script_window.hpp"
|
||||
skiptillend = False
|
||||
eof = vbCrLf
|
||||
|
||||
If Not FSO.FileExists(filename) Then
|
||||
WScript.Echo filename & " not found"
|
||||
WScript.Quit 1
|
||||
End If
|
||||
|
||||
Function GetFiles(pattern)
|
||||
Dim parent, re, files, f
|
||||
Set files = CreateObject("Scripting.Dictionary")
|
||||
Set re = New RegExp
|
||||
|
||||
parent = FSO.GetParentFolderName(pattern)
|
||||
pattern = FSO.GetFileName(pattern)
|
||||
|
||||
' Convert pattern to a valid regex
|
||||
re.Global = True
|
||||
re.Pattern = "\."
|
||||
pattern = re.Replace(pattern, "\.")
|
||||
re.Pattern = "\*"
|
||||
pattern = re.Replace(pattern, ".*")
|
||||
re.Pattern = pattern
|
||||
|
||||
' Get the file list
|
||||
For Each f In FSO.GetFolder(parent).Files
|
||||
If re.Test(f.Path) Then
|
||||
f = parent & "/" & f.Name
|
||||
files.Add f, f
|
||||
End If
|
||||
Next
|
||||
|
||||
' Sort the file list
|
||||
Set GetFiles = CreateObject("Scripting.Dictionary")
|
||||
While files.Count <> 0
|
||||
Dim first
|
||||
first = ""
|
||||
For Each f in files
|
||||
If first = "" Or StrComp(first, f) = 1 Then first = f
|
||||
Next
|
||||
GetFiles.Add first, first
|
||||
files.Remove(First)
|
||||
Wend
|
||||
End Function
|
||||
|
||||
Sub Generate(line, file)
|
||||
Dim re, add_indent, enum_pattern, file_pattern, f, active, active_comment, comment, rm_indent
|
||||
Set re = New RegExp
|
||||
|
||||
re.Global = True
|
||||
re.Pattern = "[^ ]*"
|
||||
add_indent = re.Replace(line, "")
|
||||
re.Global = False
|
||||
re.Pattern = ".*@enum *"
|
||||
line = Split(re.Replace(line, ""))
|
||||
enum_pattern = line(0)
|
||||
file_pattern = line(1)
|
||||
For Each f In GetFiles(file_pattern).Items
|
||||
active = 0
|
||||
active_comment = 0
|
||||
comment = ""
|
||||
file.Write add_indent & "/* automatically generated from " & f & " */" & eof
|
||||
Set f = FSO.OpenTextFile(f, 1)
|
||||
While Not f.AtEndOfStream
|
||||
re.Pattern = rm_indent
|
||||
line = re.Replace(f.ReadLine, "")
|
||||
|
||||
' Remember possible doxygen comment before enum declaration
|
||||
re.Pattern = "/\*\*"
|
||||
If active = 0 And re.Test(line) Then
|
||||
comment = add_indent & line
|
||||
active_comment = 1
|
||||
ElseIf active_comment = 1 Then
|
||||
comment = comment & vbCrLf & add_indent & line
|
||||
End If
|
||||
|
||||
' Check for enum match
|
||||
re.Pattern = "^ *enum *" & enum_pattern & " *\{"
|
||||
If re.Test(line) Then
|
||||
re.Global = True
|
||||
re.Pattern = "[^ ]*"
|
||||
rm_indent = re.Replace(line, "")
|
||||
re.Global = False
|
||||
active = 1
|
||||
If active_comment > 0 Then file.Write comment & eof
|
||||
active_comment = 0
|
||||
comment = ""
|
||||
End If
|
||||
|
||||
' Forget doxygen comment, if no enum follows
|
||||
If active_comment = 2 And line <> "" Then
|
||||
active_comment = 0
|
||||
comment = ""
|
||||
End If
|
||||
re.Pattern = "\*/"
|
||||
If active_comment = 1 And re.Test(line) Then active_comment = 2
|
||||
|
||||
If active <> 0 Then
|
||||
re.Pattern = "^ *[A-Za-z0-9_]* *[,=]"
|
||||
If re.Test(line) Then
|
||||
Dim parts
|
||||
' Transform enum values
|
||||
re.Pattern = " *=[^,]*"
|
||||
line = re.Replace(line, "")
|
||||
re.Pattern = " *//"
|
||||
line = re.Replace(line, " //")
|
||||
|
||||
re.Pattern = "^( *)([A-Za-z0-9_]+),(.*)"
|
||||
Set parts = re.Execute(line)
|
||||
|
||||
With parts.Item(0).SubMatches
|
||||
If .Item(2) = "" Then
|
||||
file.Write add_indent & .Item(0) & .Item(1) & String(45 - Len(.Item(1)), " ") & "= ::" & .Item(1) & "," & eof
|
||||
Else
|
||||
file.Write add_indent & .Item(0) & .Item(1) & String(45 - Len(.Item(1)), " ") & "= ::" & .Item(1) & "," & String(44 - Len(.Item(1)), " ") & .Item(2) & eof
|
||||
End If
|
||||
End With
|
||||
ElseIf line = "" Then
|
||||
file.Write eof
|
||||
Else
|
||||
file.Write add_indent & line & eof
|
||||
End If
|
||||
End If
|
||||
|
||||
re.Pattern = "^ *\};"
|
||||
If re.Test(line) Then
|
||||
If active <> 0 Then file.Write eof
|
||||
active = 0
|
||||
End If
|
||||
Wend
|
||||
f.Close
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Sub Parse(line, file)
|
||||
Dim re
|
||||
Set re = New RegExp
|
||||
|
||||
re.pattern = "@enum"
|
||||
If re.Test(line) Then
|
||||
file.Write line & eof
|
||||
Generate line, file
|
||||
skiptillend = True
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
re.pattern = "@endenum"
|
||||
If re.Test(line) Then
|
||||
file.Write line & eof
|
||||
skiptillend = False
|
||||
Exit Sub
|
||||
End If
|
||||
|
||||
If Not skiptillend Then
|
||||
file.Write line & eof
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Dim file, source, lines, i
|
||||
|
||||
WScript.Echo "Starting to parse " & filename
|
||||
Set file = FSO.OpenTextFile(filename, 1)
|
||||
If Not file.AtEndOfStream Then
|
||||
source = file.ReadAll
|
||||
End IF
|
||||
file.Close
|
||||
|
||||
lines = Split(source, eof)
|
||||
If UBound(lines) = 0 Then
|
||||
eof = vbLf
|
||||
lines = Split(source, eof)
|
||||
End If
|
||||
|
||||
Set file = FSO.OpenTextFile(filename, 2)
|
||||
For i = LBound(lines) To UBound(lines) - 1 ' Split adds an extra line, we must ignore it
|
||||
Parse lines(i), file
|
||||
Next
|
||||
file.Close
|
||||
WScript.Echo "Done"
|
@@ -170,7 +170,7 @@
|
||||
break;
|
||||
|
||||
default:
|
||||
EnforcePrecondition(false, days_between_town_growth <= MAX_TOWN_GROWTH_TICKS);
|
||||
EnforcePrecondition(false, (days_between_town_growth * DAY_TICKS / TOWN_GROWTH_TICKS) <= MAX_TOWN_GROWTH_TICKS);
|
||||
/* Don't use growth_rate 0 as it means GROWTH_NORMAL */
|
||||
growth_rate = max(days_between_town_growth * DAY_TICKS, 2u) - 1;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user