Anonymous Login
2017-07-28 08:35 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0001904OpenClonkEnginepublic2017-04-19 09:49
ReporterIsilkor 
Assigned ToIsilkor 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0001904: Sort_Speed is completely broken
DescriptionAdding Sort_Speed as a sorting criterion in FindObjects does nothing useful and returns the objects in arbitrary order.
Steps To Reproducevar a = [];
for (var i = 0; i < 10; ++i)
{
    a[i] = CreateObjectAbove(Dummy, 100, 100, NO_OWNER);
    // Use Cos for fake random velocities in the absence of a way to
    // manually seed the PRNG
    a[i]->SetXDir(Abs(Cos(i * 66, 100)));
}

for (var o in FindObjects(Find_ID(Dummy), Sort_Speed()))
    Log("%v: %d", o, o->GetXDir());

/*
Expected result:
Object(5): 10
Object(8): 21
Object(2): 41
Object(10): 59
Object(3): 67
Object(7): 81
Object(6): 87
Object(4): 95
Object(9): 98
Object(1): 100
****
Actual result:
Object(10): 59
Object(9): 98
Object(8): 21
Object(7): 81
Object(6): 87
Object(5): 10
Object(4): 95
Object(3): 67
Object(2): 41
Object(1): 100
*/
TagsNo tags attached.
Attached Files

-Relationships
+Relationships

-Notes

~0005648

Isilkor (developer)

Reason is a non-explicit operator bool inside C4Fixed, which gets used for implicit conversion to int. C4SortObjectSpeed::CompareGetValue should use fixtoi instead.

~0005657

occ (reporter)

Hi! There's been a check-in that references this bug. For more information you can visit the repository browser at this address:
https://git.openclonk.org/openclonk.git/commitdiff/81e49fe0f583798464a14085b106c266bfb12f35

Changeset 81e49fe by Nicolas Hake <isilkor@openclonk.org>
Fix several broken conversions from C4Fixed->bool->int (0001904)

This is why non-explicit operator bool is bad.

+Notes

-Issue History
Date Modified Username Field Change
2017-04-11 17:31 Isilkor New Issue
2017-04-11 18:56 Isilkor Note Added: 0005648
2017-04-19 09:49 occ Note Added: 0005657
2017-04-19 09:49 Isilkor Assigned To => Isilkor
2017-04-19 09:49 Isilkor Status new => resolved
2017-04-19 09:49 Isilkor Resolution open => fixed
+Issue History