2024-04-25 09:08 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000641Spring engineGeneralpublic2007-10-29 21:57
ReporterKDR_11k 
Assigned Toimbaczek 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000641: set HEADING doesn't seem to update piece positions for emit-sfx
DescriptionA unit that is turned with a set HEADING command and uses an emit-sfx effect will have the effect appear at the position and orientation the piece had before the unit was turned. The position gets corrected a moment later (probably at slowupdate) but it's enough to make e.g. fixedlauncher missiles fire off in the wrong direction.
Additional InformationI've attached a WIP version of Lolimod that often has the error, units are turned in their AimWeapon function (and don't shoot while moving). When a unit moves, stops and fires the first few shots will often exhibit this issue. The bunny unit is the most affected. Try spawning a few units for the enemy team and run a bunny around them.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • ? file icon Lolimod_Mantis.sd7 (1,380,375 bytes) 2007-09-21 10:43
  • patch file icon cobheadingissuepatch.patch (2,288 bytes) 2007-10-10 15:28 -
    Index: COB/CobInstance.cpp
    ===================================================================
    --- COB/CobInstance.cpp	(revision 4535)
    +++ COB/CobInstance.cpp	(working copy)
    @@ -1272,6 +1272,7 @@
     		}
     		case HEADING: {
     			unit->heading = param % COBSCALE;
    +			unit->SetDirectionFromHeading();
     			break;
     		}
     		case LOS_RADIUS: {
    Index: Unit.cpp
    ===================================================================
    --- Unit.cpp	(revision 4535)
    +++ Unit.cpp	(working copy)
    @@ -684,21 +684,7 @@
     
     		// aircraft and ScriptMoveType do not want this
     		if (moveType->useHeading) {
    -			frontdir=GetVectorFromHeading(heading);
    -			if(transporter && transporter->unitDef->holdSteady) {
    -				updir = transporter->updir;
    -				rightdir=frontdir.cross(updir);
    -				rightdir.Normalize();
    -				frontdir=updir.cross(rightdir);
    -			} else if(upright || !unitDef->canmove){
    -				updir=UpVector;
    -				rightdir=frontdir.cross(updir);
    -			} else  {
    -				updir=ground->GetNormal(pos.x,pos.z);
    -				rightdir=frontdir.cross(updir);
    -				rightdir.Normalize();
    -				frontdir=updir.cross(rightdir);
    -			}
    +			SetDirectionFromHeading();
     		}
     
     		if(!dontFire){
    @@ -727,6 +713,25 @@
     	UpdateTerrainType();
     }
     
    +void CUnit::SetDirectionFromHeading(void)
    +{
    +	frontdir=GetVectorFromHeading(heading);
    +	if(transporter && transporter->unitDef->holdSteady) {
    +		updir = transporter->updir;
    +		rightdir=frontdir.cross(updir);
    +		rightdir.Normalize();
    +		frontdir=updir.cross(rightdir);
    +	} else if(upright || !unitDef->canmove){
    +		updir=UpVector;
    +		rightdir=frontdir.cross(updir);
    +	} else  {
    +		updir=ground->GetNormal(pos.x,pos.z);
    +		rightdir=frontdir.cross(updir);
    +		rightdir.Normalize();
    +		frontdir=updir.cross(rightdir);
    +	}
    +}	
    +
     void CUnit::DoDamage(const DamageArray& damages, CUnit *attacker,const float3& impulse, int weaponId)
     {
     	if(isDead)
    Index: Unit.h
    ===================================================================
    --- Unit.h	(revision 4535)
    +++ Unit.h	(working copy)
    @@ -93,6 +93,7 @@
     	void DrawBeingBuilt();
     	void DrawWithLists(unsigned int preList, unsigned int postList);
     	void DrawRawWithLists(unsigned int preList, unsigned int postList);
    +	void SetDirectionFromHeading();
     
     	void ApplyTransformMatrix() const;
     	void GetTransformMatrix(CMatrix44f& matrix) const;
    
    patch file icon cobheadingissuepatch.patch (2,288 bytes) 2007-10-10 15:28 +

-Relationships
+Relationships

-Notes

~0001315

imbaczek (reporter)

Failed to load armorDefs
error = 2, gamedata/defs.lua, [string "gamedata/defs.lua"]:36: [string "gamedata/defs.lua"]:24: error = 2, gamedata/armorDefs.lua, [string "gamedata/armorDefs.lua"]:19: Error parsing armor.txt: missing file

will try to put a dummy armor.txt in, hopefully there are no more errors.

~0001316

imbaczek (reporter)

after adding [FOO] {} it worked, i don't know what's wrong and what's right.

~0001334

tombom (reporter)

This happens because direction is only updated from the heading in SlowUpdate. I've attached a patch which forces an update whenever heading is changed in COB.

~0001340

imbaczek (reporter)

applied the patch in r4543, KDR please test.

~0001380

KDR_11k (reporter)

it works
+Notes

-Issue History
Date Modified Username Field Change
2007-09-21 10:43 KDR_11k New Issue
2007-09-21 10:43 KDR_11k File Added: Lolimod_Mantis.sd7
2007-09-27 18:18 imbaczek Note Added: 0001315
2007-09-27 18:29 imbaczek Note Added: 0001316
2007-10-10 15:28 tombom Note Added: 0001334
2007-10-10 15:28 tombom File Added: cobheadingissuepatch.patch
2007-10-11 20:55 imbaczek Note Added: 0001340
2007-10-29 20:56 tvo Status new => feedback
2007-10-29 21:14 KDR_11k Note Added: 0001380
2007-10-29 21:57 imbaczek Status feedback => resolved
2007-10-29 21:57 imbaczek Resolution open => fixed
2007-10-29 21:57 imbaczek Assigned To => imbaczek
+Issue History