electronicarts / CnC_Remastered_Collection

Other
18.31k stars 4.74k forks source link

Byte character parse problem? #56

Open kotoricon opened 4 years ago

kotoricon commented 4 years ago

`

ifndef FUNCTION_H

define FUNCTION_H

ifdef NEVER

Map(screen) class heirarchy.

MapeditClass(most derived class) --scenario editor ? MouseClass -- handles mouse animation and display control ? ScrollClass -- map scroll handler ? HelpClass -- pop - up help text handler ? TabClass -- file folder tab screen mode control dispatcher ? SidebarClass -- displays and controls construction list sidebar ? PowerClass -- display power production / consumption bargraph ? RadarClass -- displays and controls radar map ? DisplayClass -- general tactical map display handler ? MapClass -- general tactical map data handler ? GScreenClass(pure virtual base class)-- generic screen control

AbstractClass ? ? ? ? ObjectClass ? 谀哪哪穆哪哪哪哪哪履哪哪哪呐哪哪哪哪履哪哪哪哪哪哪哪穆哪哪哪哪哪目 AnimClass ? TemplateClass ? 媚 FuseClass ? TerrainClass ? ? 媚 FlyClass ? ? ? BulletClass ? OverlayClass MissionClass SmudgeClass ? RadioClass ? 媚 CrewClass 媚 FlasherClass 媚 StageClass 媚 CargoClass TechnoClass ? 谀哪哪哪哪哪哪哪哪哪哪哪牧哪哪哪哪哪哪哪哪哪哪哪哪哪哪 ? FootClass BuildingClass ? 媚哪哪哪哪哪哪穆哪哪哪哪哪哪目 DriveClass InfantryClass 媚 FlyClass ? AircraftClass TurretClass ? TarComClass ? UnitClass

AbstractTypeClass ? ObjectTypeClass ? 谀哪哪哪哪哪哪哪哪哪哪呐哪哪哪哪哪哪履哪哪哪哪哪哪哪哪 ? ? ? ? ? TechnoTypeClass ? ? ? ? BulletTypeClass ? ? ? TemplateTypeClass ? 谀哪哪哪牧哪哪穆哪哪哪哪哪穆哪哪哪哪哪哪哪 ? TerrainTypeClass ? ? ? ? UnitTypeClass ? BuildingTypeClass ? ? InfantryTypeClass AircraftTypeClass

endif

`

I got so many of them in many file when i trying to compile my dll file, any help to fix it?

abergmeier commented 4 years ago

Maybe have a look at https://github.com/abergmeier/CnC_Remastered_Multiplatform. We have converted the files to UTF-8.

kotoricon commented 4 years ago

Maybe have a look at https://github.com/abergmeier/CnC_Remastered_Multiplatform. We have converted the files to UTF-8.

Thanks but still no luck, and now i got double error count(from 159 to about 400)

P.S:I'm using VS2019

khm1600 commented 4 years ago

What errors are you getting?

kotoricon commented 4 years ago

What errors are you getting?

Example:

C2338 Windows headers require the default packing option. Changing this can lead to memory corruption. This diagnostic can be disabled by building with WINDOWS_IGNORE_PACKING_MISMATCH defined. (编译源文件 ABSTRACT.CPP) RedAlert E:\Windows Kits\10\Include\10.0.18362.0\um\winnt.h 2482

also get officel version error C2220/C2065/C2001/C2143

khm1600 commented 4 years ago

C2338: define WINDOWS_IGNORE_PACKING_MISMATCH C2220, C2001, C2143: converting the encoding from CP437 to UTF-8 should work.

C2220 is caused by C4819. C2001 and C3143 are given because the character before a " and the " happen to form something valid in your current code page (which I'm assuming to be 936).

kotoricon commented 4 years ago

C2338: define WINDOWS_IGNORE_PACKING_MISMATCH C2220, C2001, C2143: converting the encoding from CP437 to UTF-8 should work.

C2220 is caused by C4819. C2001 and C3143 are given because the character before a " and the " happen to form something valid in your current code page (which I'm assuming to be 936).

Thanks, but I think these fix should be update to that git by someone else not by me, it's too much error and need a lot of time :(

khm1600 commented 4 years ago

Writing and running an encoding converter only takes a few minutes, defining a symbol takes seconds. Doing both solved all the errors for me.

kotoricon commented 4 years ago

Writing and running an encoding converter only takes a few minutes, defining a symbol takes seconds. Doing both solved all the errors for me.

Are you sure you only need few minutes for it? or you're using batch operation?

A simple example here:

C2220 need re-save all file to Unicode (UTF-8 with BOM)-65001, you have to open all the file and click "advanced save options" save to "Unicode (UTF-8 with BOM) 65001)". every files need about 1-1.5 minutes, and there's about 150 files need to do it.

kotoricon commented 4 years ago

Also there's other strange error from both git:

C2065: undeclared identifier TXT_ABORT, TXT_CHRONOSHIFT, TXT_CHRONOSPHERE, TXT_CIV15, TXT_IRON_CURTAIN, TXT_SPECIAL_WARNING, TXT_THEME_2ND_HAND, TXT_THEME_RPT, TXT_V2_LAUNCHER

khm1600 commented 4 years ago

Are you sure you only need few minutes for it?

I just wrote one and it took ~5 min to write and 30 seconds to run. So yes, I'm sure it only takes a few minutes. If you REALLY don't want to write one yourself, here's the code (in C#) I just wrote.

static void ConvertEncoding(string repoPath)
{
    var di = new DirectoryInfo(repoPath);
    ConvertRec(di);

    void ConvertRec(DirectoryInfo dir)
    {
        foreach (var file in dir.GetFiles())
        {
            if (file.Extension.Equals(".h", StringComparison.OrdinalIgnoreCase) || 
                file.Extension.Equals(".cpp", StringComparison.OrdinalIgnoreCase))
            {
                var text = "";
                {
                    using var fs = file.OpenRead();
                    using var sr = new StreamReader(fs, Encoding.GetEncoding(437));
                    text = sr.ReadToEnd();
                }
                {
                    using var fs = file.OpenWrite();
                    using var sw = new StreamWriter(fs, Encoding.Unicode);
                    sw.WriteLine(text);
                }
            }
        }
        foreach (var d in dir.GetDirectories())
        {
            if (!d.Name.StartsWith("."))
            {
                ConvertRec(d);
            }
        }
    }
}

Also, just tested on master, running this and defining WINDOWS_IGNORE_PACKING_MISMATCH solved all errors for me.

leeleee commented 4 years ago

Thanks to @khm1600 , I built it successfully. And in additional, don't use the latest Windows SDK, use the version before 10.0.17763.0, or the WINDOWS_IGNORE_PACKING_MISMATCH will not work.