1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-14 10:12:59 +02:00
vcmi/AI/Nullkiller
Alexander Wilms 1b85abb508 Use auto instead of redundant type in initializations using new
grep -r --include \*.h --include \*.cpp "=" * | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return\|{\|}\|= \"\|= tr(\|virtual\|void" | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "float\|nullptr" | grep "new" | grep -v "AI/FuzzyLite" | grep \( | grep "= new" > redundant_types.txt

import re

with open("redundant_types.txt") as f:
    for line in f:
        line = line.strip()
        path = line.split(":", 1)[0]
        original_code = line.split(":")[1].strip()
        if "new " in original_code:

            cpp_type = original_code.split(" ")[0]
            if original_code.count(cpp_type) == 2:
                print()
                print(path)
                print(original_code)
                new_code = "auto "+" ".join(original_code.split(" ")[1:])
                print(new_code)

                with open(path, "r") as f:
                    filedata = f.read()

                filedata = filedata.replace(original_code, new_code)

                with open(path, "w") as f:
                    f.write(filedata)
2024-01-16 21:40:53 +00:00
..
Analyzers Re-add const that was erronously removed with 88ec4fa 2023-12-30 11:01:21 +01:00
Behaviors Remove more subID access 2023-11-01 14:44:05 +02:00
Engine Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
Goals Fix review comments 2023-10-12 13:30:01 +02:00
Helpers Another build fix 2023-07-31 22:01:11 +03:00
Markers Replaced boost::thread_specific_ptr with thread_local 2023-08-23 16:32:29 +03:00
Pathfinding Use auto instead of redundant type in initializations using new 2024-01-16 21:40:53 +00:00
AIGateway.cpp Remove trailing semicolon from NET_EVENT_HANDLER macro 2024-01-14 14:49:25 +00:00
AIGateway.h Add query for dwellings dialog 2023-10-04 17:47:12 +03:00
AIUtility.cpp Converted several namespace enums to enum class 2023-08-25 13:38:02 +03:00
AIUtility.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
CMakeLists.txt NKAI: mana recovery 2023-09-30 10:37:36 +03:00
main.cpp NKAI: namespace 2022-10-04 08:40:14 +03:00
StdInc.cpp Nullkiller: copy VCAI 2021-07-26 21:02:50 +03:00
StdInc.h wrap all library code into namespace if VCMI_LIB_NAMESPACE is defined 2022-09-24 15:55:21 +03:00