1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-04 00:15:53 +02:00
vcmi/lib/battle
Alexander Wilms 73019c204d Replace redundant types with auto for the lvalues of template factory functions for smart pointers
grep -r --include \*.h --include \*.cpp "= std::" * | grep -v auto | grep -Po ".*[^ ]+ [^ ]+ [^ ]*[ ]*=.*;" | grep -v "auto\|int\|char\|bool\|float|\double\|for\|if\|googletest\|fuzzylite\|size_t\|using\|return" | grep -v double | grep -v si64 | grep -v si32 | grep -v ui32 | grep \< | grep -v float | tr -d '\t' | grep -v assert > 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 = ":".join(line.split(":")[1:]).strip()

        print()
        print(path)
        print(original_code)
        prefix = "auto "
        if original_code.startswith("static"):
            static = True
        else:
            static = False

        cpp_type = " ".join(original_code.split("=")[0].strip().split(" ")[0:-1])
        print(cpp_type)

        if static:
            new_code = "static auto "+ " ".join(original_code.split(" ")[2:])
        else:
            new_code = "auto "+ " ".join(original_code.split(" ")[1:])
        print(new_code)

        if True:
            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-17 12:50:00 +00:00
..
AccessibilityInfo.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
AccessibilityInfo.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
AutocombatPreferences.h Comment out unused OH3 options so they do not clutter code suggestions 2023-08-20 19:11:36 +02:00
BattleAction.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
BattleAction.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
BattleAttackInfo.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
BattleAttackInfo.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
BattleHex.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
BattleHex.h Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
BattleInfo.cpp Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
BattleInfo.h Define each identifier in a dedicated statement 2024-01-10 00:22:23 +00:00
BattleProxy.cpp Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
BattleProxy.h Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
BattleStateInfoForRetreat.cpp vcmi: massive refactoring v1 2023-04-05 22:33:12 +03:00
BattleStateInfoForRetreat.h BattleAI: avoid selfblocking on siege 2023-04-09 16:22:37 +03:00
CBattleInfoCallback.cpp Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
CBattleInfoCallback.h Fixed Genie spellcasting logic to account for spell immunities 2023-12-24 01:13:19 +02:00
CBattleInfoEssentials.cpp Do not allow fleeing from cities without fort 2023-11-21 20:32:07 +02:00
CBattleInfoEssentials.h Replace redundant types with auto for the lvalues of template factory functions for smart pointers 2024-01-17 12:50:00 +00:00
CObstacleInstance.cpp Split off some netpack structures into separate files 2023-10-23 13:59:15 +03:00
CObstacleInstance.h Split off some netpack structures into separate files 2023-10-23 13:59:15 +03:00
CPlayerBattleCallback.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
CPlayerBattleCallback.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
CUnitState.cpp Call cheap to compute conditions before costly conditions 2023-11-18 19:42:45 +02:00
CUnitState.h Remove explicit convesion to int in operators 2023-11-15 15:55:19 +02:00
DamageCalculator.cpp Slayer spell should only affect creatures with KING bonus 2023-12-10 19:17:09 +02:00
DamageCalculator.h
Destination.cpp
Destination.h
IBattleInfoCallback.h Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
IBattleState.cpp
IBattleState.h Pass functor via reference to avoid costly copies 2023-11-18 19:43:11 +02:00
IUnitInfo.h
PossiblePlayerBattleAction.h Fix spellcasters with massive spells 2023-03-25 01:23:49 +02:00
ReachabilityInfo.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
ReachabilityInfo.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
SideInBattle.cpp Explicitly convert identifier to underlying enumeration 2023-11-03 16:03:29 +02:00
SideInBattle.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
SiegeInfo.cpp convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
SiegeInfo.h convert line endings from CRLF (Windows) to LF (Linux/Unix) 2023-10-19 16:23:21 +02:00
Unit.cpp Remove magic number 2023-11-07 22:47:11 +02:00
Unit.h Renamed MetaString methods to more logical names 2023-06-20 19:37:27 +03:00