TheSuperHackers / GeneralsGamePatch

Community Patch to fix and improve original Generals Zero Hour 1.04
Other
60 stars 19 forks source link

Fix all indentation in INI files #805

Open xezon opened 2 years ago

xezon commented 2 years ago

Fix all indentation and spacing in all INI files. Maybe also unify linefeeds between definition blocks. Build a script and apply to original and edited INI files for both Zero Hour and Generals. Ideally the result increases readability.

xezon commented 2 years ago

Before

  ExperienceValue = 20 20 40 60    ;Experience point value at each level
  ExperienceRequired = 0 100 200 400  ;Experience points needed to gain each level
  IsTrainable = Yes             ;Can gain experience
  CrushableLevel         = 0  ;What am I?:        0 = for infantry, 1 = for trees, 2 = general vehicles
  CommandSet      = ChinaInfantryTankHunterCommandSet

  ; *** AUDIO Parameters ***
  VoiceSelect = TankHunterVoiceSelect
  VoiceMove = TankHunterVoiceMove
  VoiceAttack = TankHunterVoiceAttack
  VoiceAttackAir = TankHunterVoiceAttack
  VoiceGuard = TankHunterVoiceMove
  VoiceFear = TankHunterVoiceFear
  UnitSpecificSounds
    VoiceCreate          = TankHunterVoiceCreate
    VoiceGarrison = TankHunterVoiceGarrison
    VoiceEnter = TankHunterVoiceMove
    VoiceEnterHostile = TankHunterVoiceMove
    VoiceGetHealed      = TankHunterVoiceMove
  End

After

  ExperienceValue    = 20 20 40 60                       ; Experience point value at each level
  ExperienceRequired = 0 100 200 400                     ; Experience points needed to gain each level
  IsTrainable        = Yes                               ; Can gain experience
  CrushableLevel     = 0                                 ; What am I?:        0 = for infantry, 1 = for trees, 2 = general vehicles
  CommandSet         = ChinaInfantryTankHunterCommandSet

  ; *** AUDIO Parameters ***
  VoiceSelect    = TankHunterVoiceSelect
  VoiceMove      = TankHunterVoiceMove
  VoiceAttack    = TankHunterVoiceAttack
  VoiceAttackAir = TankHunterVoiceAttack
  VoiceGuard     = TankHunterVoiceMove
  VoiceFear      = TankHunterVoiceFear

  UnitSpecificSounds
    VoiceCreate       = TankHunterVoiceCreate
    VoiceGarrison     = TankHunterVoiceGarrison
    VoiceEnter        = TankHunterVoiceMove
    VoiceEnterHostile = TankHunterVoiceMove
    VoiceGetHealed    = TankHunterVoiceMove
  End
commy2 commented 2 years ago

Normally not a fan of aligned assignments in programming, because they cause big diffs if a key was added that is longer than the previous keys. Since the names are hardcoded instead of variables, I guess it can work here.


Wild idea, ccgzh.ini is essentially some custom data format rather than a language. Could these be represented by some modern object notation that is then transpiled to .ini? I think it would be neat to make use of inheritance:

{
    "GLAVehicleQuadCannon": {
        "Module_Tag1": {blah},
        ...
        "Faction": "GLA",
        "Cost": 700,
    },
    "Chem_GLAVehicleQuadCannon": {
        "#inherits": "GLAVehicleQuadCannon",
        "Faction": "GLAToxinGeneral",
        "Cost": 750,
    }
}

It would get rid of a shitton of duplicated code and be less error prone.

xezon commented 2 years ago

Ouf. I do see the benefit of doing that. The JSON Format you used above would lose all comments though.

xezon commented 2 years ago

Perhaps instead of introducing entirely new format, the INI syntax could be just extended and then transformed from Modified INI source into game INI format on build step. This way you could add that inheritance feature selectively. And no one has to relearn INI syntax because of it.

alanblack166 commented 2 years ago

Or just stop trying to reinvent the wheel?

xezon commented 2 years ago

As for pure formatting, there are probably ways to define a format rule set for Visual Studio Code and then just apply that to all files.

ZekeDlyoung commented 2 years ago

Rather than aligning all the "=", I'd prefer to just clean/group the lines better so that they're easier to find like so:

   ExperienceValue = 20 20 40 60
   ExperienceRequired = 0 100 200 400
   IsTrainable = Yes

   CrushableLevel = 0 ; 0 = for infantry, 1 = for trees, 2 = general vehicles

   CommandSet = ChinaInfantryTankHunterCommandSet

   ; *** AUDIO PARAMETERS ***
   VoiceSelect = TankHunterVoiceSelect
   VoiceMove = TankHunterVoiceMove
   VoiceAttack = TankHunterVoiceAttack
   VoiceAttackAir = TankHunterVoiceAttack
   VoiceGuard = TankHunterVoiceMove
   VoiceFear = TankHunterVoiceFear

   UnitSpecificSounds
     VoiceCreate = TankHunterVoiceCreate
     VoiceGarrison = TankHunterVoiceGarrison
     VoiceEnter = TankHunterVoiceMove
     VoiceEnterHostile = TankHunterVoiceMove
     VoiceGetHealed = TankHunterVoiceMove
   End

A lot of these lines are their own parameter and don't really need to be compared to the ones around them, so there's not much point in aligning all the "="s imo

EnigmaZift commented 2 years ago

I much prefer the '=' aligned for readability, but that's just me