Skip to content

Commit

Permalink
Merge pull request #162 from OpenVicProject/changes
Browse files Browse the repository at this point in the history
Lots of Changes
  • Loading branch information
Hop311 authored Nov 8, 2023
2 parents 5782294 + 47fff27 commit f8da086
Show file tree
Hide file tree
Showing 18 changed files with 630 additions and 198 deletions.
217 changes: 217 additions & 0 deletions .astylesrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# @file Astyle code automatic formatting settings
# @see http://astyle.sourceforge.net/astyle.html#_General_Information

#
# Java style uses attached braces.
#
# int Foo(bool isBar) {
# if (isBar) {
# bar();
# return 1;
# } else
# return 0;
# }
#
--style=attach

#
# Indent using all tab characters, if possible. If a continuation line is not an even number of tabs,
# spaces will be added at the end. Treat each tab as # spaces (e.g. -T6 / --indent=force-tab=6).
# # must be between 2 and 20. If no # is set, treats tabs as 4 spaces.
#
--indent=force-tab=4

#
# Add extra indentation to namespace blocks. This option has no effect on Java files.
#
--indent-namespaces

#
# Indent multi-line preprocessor definitions ending with a backslash. Should be used with --convert-tabs for proper results.
# Does a pretty good job, but cannot perform miracles in obfuscated preprocessor definitions.
# Without this option the preprocessor statements remain unchanged.
#
--indent-preproc-define

#
# Indent C++ comments beginning in column one. By default C++ comments beginning in column one are assumed to be
# commented-out code and not indented. This option will allow the comments to be indented with the code.
#
--indent-col1-comments

#
# Indent, instead of align, continuation lines following lines that contain an opening paren '(' or an assignment '='.
# This includes function definitions and declarations and return statements.
# The indentation can be modified by using the following indent-continuation option.
# This option may be preferred for editors displaying proportional fonts.
#
--indent-after-parens

#
# Set the continuation indent for a line that ends with an opening paren '(' or an assignment '='.
# This includes function definitions and declarations. It will also modify the previous indent-after-paren option.
# The value for # indicates a number of indents. The valid values are the integer values from 0 thru 4.
# If this option is not used, the default value of 1 is used.
#
--indent-continuation=1

#
# Set the minimal indent that is added when a header is built of multiple lines.
# This indent helps to easily separate the header from the command statements that follow.
# The value for # indicates a number of indents and is a minimum value.
# The indent may be greater to align with the data on the previous line.
# The valid values are:
# 0 - no minimal indent. The lines will be aligned with the paren on the preceding line.
# 1 - indent at least one additional indent.
# 2 - indent at least two additional indents.
# 3 - indent at least one-half an additional indent. This is intended for large indents (e.g. 8).
# The default value is 2, two additional indents.
#
--min-conditional-indent=0

#
# Set the maximum of # spaces to indent a continuation line. The # indicates a number of columns and
# must not be less than 40 or greater than 120. If no value is set, the default value of 40 will be used.
# This option will prevent continuation lines from extending too far to the right.
# Setting a larger value will allow the code to be extended further to the right.
#
#--max-continuation-indent=40

#
# Indent labels so that they appear one indent less than
# the current indentation level, rather than being
# flushed completely to the left (which is the default).
#
--indent-labels

#
# This option improves indentation of C++ lambda functions. As it currently does not work well with
# complex lambda function bodies, this feature is not enabled by default.
#
#--lambda-indent

#
# Attach a pointer or reference operator (*, &, or ^) to either the variable type (left) or variable name (right), or place it between the type and name (middle).
#
--align-pointer=type

#
# This option will align references separate from pointers. Pointers are not changed by this option.
# If pointers and references are to be aligned the same, use the previous align-pointer option.
#
--align-reference=type

#
# Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
# The statement must be on a single line. The brackets will be added according to the currently requested predefined style or bracket type.
# If no style or bracket type is requested the brackets will be attached.
# If --add-one-line-brackets is also used the result will be one line brackets.
#
--add-braces

# Don't break complex statements and multiple statements residing on a single line.
#
#--keep-one-line-statements

#
# The option max?code?length will break a line if the code exceeds # characters.
# The valid values are 50 thru 200. Lines without logical conditionals will break on a logical conditional (||, &&, ...), comma, paren, semicolon, or space.
# Some code will not be broken, such as comments, quotes, and arrays. If used with keep?one?line?blocks or add-one-line-brackets the blocks will NOT be broken.
# If used with keep?one?line?statements the statements will be broken at a semicolon if the line goes over the maximum length.
# If there is no available break point within the max code length, the line will be broken at the first available break point after the max code length.
#
--max-code-length=128

#
# By default logical conditionals will be placed first on the new line.
# The option break?after?logical will cause the logical conditionals to be placed last on the previous line. This option has no effect without max?code?length.
#
#--break-after-logical

#
# Indent a C type, C#, or Java file. C type files are C, C++, C++/CLI, and Objective-C. The option is usually set from the file extension for each file.
#
--mode=c

#
# Verbose display mode. Display optional information, such as release number, date, option file locations, and statistical data.
#
--verbose

#
# Formatted files display mode. Display only the files that have been formatted. Do not display files that are unchanged.
#
--formatted

#
# Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR).
# MacOld style is the format for Mac OS 9 and earlier. OS X uses the Linux style.
# If one of these options is not used the line ends will be determined automatically from the input file.
# When redirection is used on Windows the output will always have Windows line ends. This option will be ignored.
#
--lineend=linux

#
# Insert space padding around operators. This will also pad commas. Any end of line comments will remain
# in the original column, if possible. Note that there is no option to unpad. Once padded, they stay padded.
#
--pad-oper

#
# Insert space padding between a header (e.g. 'if', 'for', 'while'...) and the following paren.
# Any end of line comments will remain in the original column, if possible.
# This can be used with unpad-paren to remove unwanted spaces.
#
--pad-header

#
# Remove extra space padding around parens on the inside and outside. Any end of line comments will remain in the original
# column, if possible. This option can be used in combination with the paren padding options pad-paren, pad-paren-out,
# pad-paren-in, and pad-header above. Only padding that has not been requested by other options will be removed.
# For example, if a source has parens padded on both the inside and outside, and you want inside only.
# You need to use unpad-paren to remove the outside padding, and pad-paren-in to retain the inside padding.
# Using only pad-paren-in> would not remove the outside padding.
#
--unpad-paren

#
# Remove padding around square brackets on both the outside and the inside.
#
--unpad-brackets

#
# Remove superfluous empty lines exceeding the given number.
#
--squeeze-lines=1

#
# Remove superfluous whitespace
#
--squeeze-ws

#
# Attach the return type to the function name. The two options are for the function definitions (-xf),
# and the function declarations or signatures (-xh). They are intended to undo the --break-return-type options.
# If used with --break-return-type, the result will be to break the return type.
# This option has no effect on Objective-C functions.
#
--attach-return-type

#
# Closes whitespace between the ending angle brackets of template definitions.
# Closing the ending angle brackets is now allowed by the C++11 standard.
# Be sure your compiler supports this before making the changes.
#
--close-templates

#
# Do not retain a backup of the original file. The original file is purged after it is formatted.
#
--suffix=none

#
# Preserve the original file's date and time modified.
# The time modified will be changed a few microseconds to force the changed files to compile.
# This option is not effective if redirection is used to rename the input file.
#
--preserve-date
38 changes: 30 additions & 8 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ Standard: c++20
UseTab: Always
TabWidth: 4
IndentWidth: 4
ColumnLimit: 0
ColumnLimit: 128
PointerAlignment: Left
DerivePointerAlignment: false
SpacesInSquareBrackets: false
SpacesInParentheses: false
SpacesInCStyleCastParentheses: false
Expand All @@ -14,6 +16,7 @@ SpacesInConditionalStatement: false
SpacesInAngles: false
SpaceInEmptyParentheses: false
SpaceInEmptyBlock: false
SpacesInParens: Never
SpaceBeforeSquareBrackets: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeParens: ControlStatements
Expand All @@ -23,13 +26,14 @@ SpaceBeforeCpp11BracedList: true
SpaceBeforeAssignmentOperators: true
SpaceAfterTemplateKeyword: false
SpaceAfterLogicalNot: false
PointerAlignment: Left
PackConstructorInitializers: BinPack
NamespaceIndentation: All
LambdaBodyIndentation: Signature
#LambdaBodyIndentation: Signature
IndentExternBlock: Indent
IndentCaseLabels: true
IndentCaseBlocks: false
IndentCaseLabels: false
IndentAccessModifiers: false
IndentRequiresClause: false
IncludeBlocks: Regroup
FixNamespaceComments: false
EmptyLineBeforeAccessModifier: LogicalBlock
Expand All @@ -38,17 +42,35 @@ CompactNamespaces: false
BreakConstructorInitializers: BeforeColon
BreakBeforeBraces: Attach
AlwaysBreakTemplateDeclarations: Yes
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: AllIfsAndElse
AlwaysBreakAfterReturnType: None
PenaltyReturnTypeOnItsOwnLine: 10
BreakBeforeConceptDeclarations: Always
AllowShortLambdasOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortEnumsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AlignTrailingComments: true
AllowShortBlocksOnASingleLine: Empty
AllowShortCompoundRequirementOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortLoopsOnASingleLine: false
AlignTrailingComments:
Kind: Never
OverEmptyLines: 0
AlignEscapedNewlines: DontAlign
AlignAfterOpenBracket: BlockIndent
AlignOperands: DontAlign
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
AlignCaseColons: false
BinPackArguments: true
BinPackParameters: true
IndentRequiresClause: false
AccessModifierOffset: -4
InsertNewlineAtEOF: true
InsertBraces: true
MaxEmptyLinesToKeep: 2
RequiresClausePosition: OwnLine
IncludeCategories:
- Regex: <[[:alnum:]_]+>
Priority: 1
Expand Down
13 changes: 13 additions & 0 deletions astyle.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

echo "\n\nFormatting openvic-extension with astyle:\n"
astyle --options=.astylesrc --recursive ./extension/src/*.?pp

if [ -d ./extension/deps/openvic-simulation ]; then
cd ./extension/deps/openvic-simulation
if [ -f ./astyle.sh ]; then
./astyle.sh
fi
fi

exit 0
13 changes: 13 additions & 0 deletions clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#/usr/bin/env bash

echo "\n\nFormatting openvic-extension with clang-format:\n"
find ./extension/src/ -iname *.hpp -o -iname *.cpp | xargs clang-format --verbose -i

if [ -d ./extension/deps/openvic-simulation ]; then
cd ./extension/deps/openvic-simulation
if [ -f ./clang-format.sh ]; then
./clang-format.sh
fi
fi

exit 0
2 changes: 1 addition & 1 deletion extension/deps/openvic-simulation
Submodule openvic-simulation updated 97 files
+217 −0 .astylesrc
+34 −10 .clang-format
+0 −4 .github/workflows/builds.yml
+23 −0 README.md
+6 −0 astyle.sh
+6 −0 clang-format.sh
+1 −1 deps/lexy-vdf
+1 −1 deps/openvic-dataloader
+1 −1 scripts
+103 −47 src/headless/main.cpp
+16 −16 src/openvic-simulation/GameAdvancementHook.cpp
+6 −3 src/openvic-simulation/GameAdvancementHook.hpp
+68 −112 src/openvic-simulation/GameManager.cpp
+25 −33 src/openvic-simulation/GameManager.hpp
+213 −37 src/openvic-simulation/Modifier.cpp
+83 −22 src/openvic-simulation/Modifier.hpp
+243 −0 src/openvic-simulation/country/Country.cpp
+111 −0 src/openvic-simulation/country/Country.hpp
+663 −118 src/openvic-simulation/dataloader/Dataloader.cpp
+70 −13 src/openvic-simulation/dataloader/Dataloader.hpp
+170 −0 src/openvic-simulation/dataloader/Dataloader_Windows.hpp
+210 −147 src/openvic-simulation/dataloader/NodeTools.cpp
+184 −71 src/openvic-simulation/dataloader/NodeTools.hpp
+312 −0 src/openvic-simulation/economy/Building.cpp
+40 −44 src/openvic-simulation/economy/Building.hpp
+27 −0 src/openvic-simulation/economy/EconomyManager.hpp
+39 −38 src/openvic-simulation/economy/Good.cpp
+12 −6 src/openvic-simulation/economy/Good.hpp
+86 −77 src/openvic-simulation/economy/ProductionType.cpp
+30 −32 src/openvic-simulation/economy/ProductionType.hpp
+73 −0 src/openvic-simulation/history/Bookmark.cpp
+52 −0 src/openvic-simulation/history/Bookmark.hpp
+158 −0 src/openvic-simulation/history/CountryHistory.cpp
+85 −0 src/openvic-simulation/history/CountryHistory.hpp
+24 −0 src/openvic-simulation/history/HistoryManager.hpp
+15 −0 src/openvic-simulation/history/HistoryMap.cpp
+110 −0 src/openvic-simulation/history/HistoryMap.hpp
+171 −0 src/openvic-simulation/history/ProvinceHistory.cpp
+71 −0 src/openvic-simulation/history/ProvinceHistory.hpp
+0 −292 src/openvic-simulation/map/Building.cpp
+106 −69 src/openvic-simulation/map/Map.cpp
+9 −10 src/openvic-simulation/map/Map.hpp
+63 −35 src/openvic-simulation/map/Province.cpp
+33 −9 src/openvic-simulation/map/Province.hpp
+6 −2 src/openvic-simulation/map/Region.cpp
+64 −80 src/openvic-simulation/map/TerrainType.cpp
+14 −7 src/openvic-simulation/map/TerrainType.hpp
+182 −0 src/openvic-simulation/military/Deployment.cpp
+110 −0 src/openvic-simulation/military/Deployment.hpp
+56 −0 src/openvic-simulation/military/LeaderTrait.cpp
+61 −0 src/openvic-simulation/military/LeaderTrait.hpp
+19 −0 src/openvic-simulation/military/MilitaryManager.hpp
+116 −59 src/openvic-simulation/military/Unit.cpp
+42 −29 src/openvic-simulation/military/Unit.hpp
+118 −0 src/openvic-simulation/misc/Define.cpp
+50 −0 src/openvic-simulation/misc/Define.hpp
+130 −0 src/openvic-simulation/politics/Government.cpp
+48 −0 src/openvic-simulation/politics/Government.hpp
+36 −36 src/openvic-simulation/politics/Ideology.cpp
+13 −7 src/openvic-simulation/politics/Ideology.hpp
+23 −20 src/openvic-simulation/politics/Issue.cpp
+24 −23 src/openvic-simulation/politics/Issue.hpp
+38 −0 src/openvic-simulation/politics/NationalValue.cpp
+35 −0 src/openvic-simulation/politics/NationalValue.hpp
+26 −0 src/openvic-simulation/politics/PoliticsManager.hpp
+54 −59 src/openvic-simulation/pop/Culture.cpp
+26 −12 src/openvic-simulation/pop/Culture.hpp
+71 −66 src/openvic-simulation/pop/Pop.cpp
+29 −17 src/openvic-simulation/pop/Pop.hpp
+24 −31 src/openvic-simulation/pop/Religion.cpp
+9 −4 src/openvic-simulation/pop/Religion.hpp
+40 −14 src/openvic-simulation/testing/Requirement.cpp
+1 −2 src/openvic-simulation/testing/Requirement.hpp
+46 −17 src/openvic-simulation/testing/TestScript.cpp
+6 −4 src/openvic-simulation/testing/TestScript.hpp
+8 −4 src/openvic-simulation/testing/Testing.cpp
+8 −9 src/openvic-simulation/testing/Testing.hpp
+95 −67 src/openvic-simulation/testing/test_scripts/A_001_file_tests.cpp
+198 −148 src/openvic-simulation/testing/test_scripts/A_002_economy_tests.cpp
+4 −6 src/openvic-simulation/testing/test_scripts/A_003_military_unit_tests.cpp
+4 −6 src/openvic-simulation/testing/test_scripts/A_004_networking_tests.cpp
+4 −6 src/openvic-simulation/testing/test_scripts/A_005_nation_tests.cpp
+4 −6 src/openvic-simulation/testing/test_scripts/A_006_politics_tests.cpp
+2 −2 src/openvic-simulation/types/Colour.hpp
+170 −54 src/openvic-simulation/types/Date.cpp
+12 −6 src/openvic-simulation/types/Date.hpp
+6 −22 src/openvic-simulation/types/IdentifierRegistry.cpp
+257 −144 src/openvic-simulation/types/IdentifierRegistry.hpp
+3 −4 src/openvic-simulation/types/Vector.cpp
+7 −5 src/openvic-simulation/types/Vector.hpp
+46 −9 src/openvic-simulation/types/fixed_point/FixedPoint.hpp
+10 −5 src/openvic-simulation/utility/BMP.cpp
+58 −0 src/openvic-simulation/utility/ConstexprIntToStr.hpp
+66 −0 src/openvic-simulation/utility/Getters.hpp
+0 −22 src/openvic-simulation/utility/Logger.cpp
+64 −31 src/openvic-simulation/utility/Logger.hpp
+96 −14 src/openvic-simulation/utility/StringUtils.hpp
6 changes: 4 additions & 2 deletions extension/src/openvic-extension/Checksum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ namespace OpenVic {
GDCLASS(Checksum, godot::Object)

// BEGIN BOILERPLATE
inline static Checksum* _checksum = nullptr;
static inline Checksum* _checksum = nullptr;

protected:
static void _bind_methods() {
godot::ClassDB::bind_method(godot::D_METHOD("get_checksum_text"), &Checksum::get_checksum_text);
}

public:
inline static Checksum* get_singleton() { return _checksum; }
static inline Checksum* get_singleton() {
return _checksum;
}

inline Checksum() {
ERR_FAIL_COND(_checksum != nullptr);
Expand Down
Loading

0 comments on commit f8da086

Please sign in to comment.