Vinifera-Developers / Vinifera

Vinifera is a C&C: Tiberian Sun engine extension implementing new logics and fixing bugs.
GNU General Public License v3.0
44 stars 10 forks source link

[Vanilla Bug] Sync logs don't list types of all objects in map/logic layers #812

Open Rampastring opened 2 years ago

Rampastring commented 2 years ago

First Check

Description

Looking at sync logs, the game writes the types of most objects into the log, like this:

Object 1769: 7f3070c Anim (Type:136(BLDGFIRE)) Owner: NONE

However, the game doesn't do this for all objects.

Object 1770: 6f305a6 Owner: NONE

It would be good to know more about these objects for debugging sync issues.

Required Code (optional)

No response

Steps To Reproduce

-

Expected Behaviour

The game should write out the type of the object.

Actual Behaviour

The game doesn't write out the type of the object.

Additional Context

No response

Rampastring commented 2 years ago

The logic layer printing code only checks for specific RTTI types and lacks an else case for everything else.

From Red Alert 1 source code, in function Print_CRCs in QUEUE.CPP:

if (objp->What_Am_I() == RTTI_AIRCRAFT)
    fprintf(fp,"Aircraft  (Type:%d) ",
        (AircraftType)(*((AircraftClass *)objp)));
else if (objp->What_Am_I() == RTTI_ANIM)
    fprintf(fp,"Anim      (Type:%d) ",
        (AnimType)(*((AnimClass *)objp)));
else if (objp->What_Am_I() == RTTI_BUILDING)
    fprintf(fp,"Building  (Type:%d) ",
        (StructType)(*((BuildingClass *)objp)));
else if (objp->What_Am_I() == RTTI_BULLET)
    fprintf(fp,"Bullet    (Type:%d) ",
        (BulletType)(*((BulletClass *)objp)));
else if (objp->What_Am_I() == RTTI_INFANTRY)
    fprintf(fp,"Infantry  (Type:%d) ",
        (InfantryType)(*((InfantryClass *)objp)));
else if (objp->What_Am_I() == RTTI_OVERLAY)
    fprintf(fp,"Overlay   (Type:%d) ",
        (OverlayType)(*((OverlayClass *)objp)));
else if (objp->What_Am_I() == RTTI_SMUDGE)
    fprintf(fp,"Smudge    (Type:%d) ",
        (SmudgeType)(*((SmudgeClass *)objp)));
else if (objp->What_Am_I() == RTTI_TEMPLATE)
    fprintf(fp,"Template  (Type:%d) ",
        (TemplateType)(*((TemplateClass *)objp)));
else if (objp->What_Am_I() == RTTI_TERRAIN)
    fprintf(fp,"Terrain   (Type:%d) ",
        (TerrainType)(*((TerrainClass *)objp)));
else if (objp->What_Am_I() == RTTI_UNIT)
    fprintf(fp,"Unit      (Type:%d) ",
        (UnitType)(*((UnitClass *)objp)));

Adding an else case like this

else
    fprintf(fp, "RTTI:%d ", objp->What_Am_I());

would give us at least the RTTI value of that object.

In TS we could add this in a patch at 0x005B6B35, which contains the else if (objp->What_Am_I() == RTTI_UNIT) check.