Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[zscript] Decompiler does not correctly handle if ... else with nested ifs #1

Open
lmichaelis opened this issue Mar 29, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@lmichaelis
Copy link
Member

Originally mentioned by @auronen in the GMC Discord (also see auronen/DecDat#2).

Original

func void B_SetNpcVisual (var C_NPC slf, var int gender, var string headMesh, var int faceTex, var int bodyTex, var int armorInstance)
{
	slf.aivar[AIV_Gender] = gender;

	Mdl_SetVisual (slf,"HUMANS.MDS");

	if (gender == MALE)
	{
               Mdl_SetVisualBody (slf,	"hum_body_Naked0", 	bodyTex,	0,			headMesh, 	faceTex,	0, 			armorInstance);
		
		if (slf.attribute[ATR_STRENGTH] < 50)
		{
			Mdl_SetModelScale		(slf, 0.9, 1, 1); 			//BREITE / Höhe / Tiefe
		};

		if (slf.attribute[ATR_STRENGTH] > 100)
		{
			Mdl_SetModelScale		(slf, 1.1, 1, 1);			//BREITE / Höhe / Tiefe
		};
	}
	else //gender == FEMALE
	{
		if (bodyTex >= 0) && (bodyTex <= 3) //MännerBodyTex angegeben
		{
			bodyTex = bodyTex + 4; // Females haben Variation 4-7 (Males 0-3)
		};
		Mdl_SetVisualBody (slf,	"Hum_Body_Babe0", 	bodyTex,	0,			headMesh, 	faceTex,  	0,			armorInstance);
	};
};

Decompiled

func void B_SETNPCVISUAL(var C_NPC SLF, var int GENDER, var string HEADMESH, var int FACETEX, var int BODYTEX, var int ARMORINSTANCE) {
    SLF.AIVAR[17] = GENDER;
    MDL_SETVISUAL(SLF, "HUMANS.MDS");
    if ((GENDER) == (MALE)) {
        MDL_SETVISUALBODY(SLF, "hum_body_Naked0", BODYTEX, 0, HEADMESH, FACETEX, 0, ARMORINSTANCE);
        if ((SLF.ATTRIBUTE[4]) < (50)) {
            MDL_SETMODELSCALE(SLF, 1063675494, 1065353216, 1065353216);
        };
        if ((SLF.ATTRIBUTE[4]) > (100)) {
            MDL_SETMODELSCALE(SLF, 1066192077, 1065353216, 1065353216);
        };
    };

    // -----------------------------------------------------
    if (((BODYTEX) >= (0)) && ((BODYTEX) <= (3))) {
        BODYTEX = (BODYTEX) + (4);
    };
    MDL_SETVISUALBODY(SLF, "Hum_Body_Babe0", BODYTEX, 0, HEADMESH, FACETEX, 0, ARMORINSTANCE);
}
@lmichaelis lmichaelis added the bug Something isn't working label Mar 29, 2023
@lmichaelis lmichaelis self-assigned this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant