Thread overview | |||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
July 11, 2020 Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Hello all, I found source code for an old game written in D, I'm talking circa 2004 here. It seems like it was written against D v0.110 according to the documentation I found. My project is to modernise it, maybe make it multiplatform, or even compile to wasm and browser based. But first, I'm trying to compile it as is and I found something odd. > private void calcIndex(in float z, out int idx, out float ofs) { > idx = slice.length + 99999; > for (int i = 1; i < slice.length; i++) { > if (z < slice[i].depth) { > idx = i - 1; > ofs = (z - slice[idx].depth) / (slice[idx + 1].depth - slice[idx].depth); > break; > } > } > if (idx < 0) { > idx = 0; > ofs = 0; > } else if (idx >= slice.length - 1) { > idx = slice.length - 2; > ofs = 0.99; > } > if (ofs !>= 0) > ofs = 0; > else if (ofs >= 1) > ofs = 0.99; > } Trying to compile this, it complains about: > Error: template argument expected following ! This is from the line with "if (ofs !>= 0)". Would anyone know what this operator was for back in v0.110? I'm assuming it's been removed some time ago... Thanks, Remi. |
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remi | On Saturday, 11 July 2020 at 09:37:42 UTC, Remi wrote:
>
> This is from the line with "if (ofs !>= 0)".
>
Not greater than or equal to?
|
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to aberba | On Saturday, 11 July 2020 at 09:47:36 UTC, aberba wrote:
> On Saturday, 11 July 2020 at 09:37:42 UTC, Remi wrote:
>>
>> This is from the line with "if (ofs !>= 0)".
>>
>
> Not greater than or equal to?
Just a guess by the way
|
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remi | On Saturday, 11 July 2020 at 09:37:42 UTC, Remi wrote:
> Hello all,
>
> I found source code for an old game written in D, I'm talking circa 2004 here. It seems like it was written against D v0.110 according to the documentation I found.
>
> My project is to modernise it, maybe make it multiplatform, or even compile to wasm and browser based. But first, I'm trying to compile it as is and I found something odd.
>
>> [...]
>
> Trying to compile this, it complains about:
>
>> [...]
>
> This is from the line with "if (ofs !>= 0)".
>
> Would anyone know what this operator was for back in v0.110? I'm assuming it's been removed some time ago...
>
> Thanks, Remi.
It's lesser, i.e "<". The code in itself looks like a wrap(0.0,0.99).
Maybe 0.99 and not 1 is because of FP comparison ?
|
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remi | On 11/07/2020 9:37 PM, Remi wrote: > > This is from the line with "if (ofs !>= 0)". > > Would anyone know what this operator was for back in v0.110? I'm assuming it's been removed some time ago... https://digitalmars.com/d/1.0/operatoroverloading.html#Binary After hunting for dmd 0.110, it looks like it just means a < b for integrals. For floats it checks for NaN instead. http://ftp.digitalmars.com/dmd.110.zip |
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remi | On 7/11/2020 2:37 AM, Remi wrote: > This is from the line with "if (ofs !>= 0)". > > Would anyone know what this operator was for back in v0.110? I'm assuming it's been removed some time ago... Here's a truth table for it: https://www.digitalmars.com/ctg/ctgNumerics.html#comparisons and !>= means "unordered or less than". Unordered means if one of the operands is a NaN. So, you can rewrite it as: if (std.math.isNaN(ofs) || ofs < 0) |
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Saturday, 11 July 2020 at 10:14:05 UTC, Walter Bright wrote: > Here's a truth table for it: > > https://www.digitalmars.com/ctg/ctgNumerics.html#comparisons > [...] I checked some of the articles there and it seems some were not ported to the new website. This one especially on memory management is very well articulated. https://digitalmars.com/d/2.0/memory.html#realtime |
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright | On Saturday, 11 July 2020 at 10:14:05 UTC, Walter Bright wrote:
> On 7/11/2020 2:37 AM, Remi wrote:
>> This is from the line with "if (ofs !>= 0)".
>>
>> Would anyone know what this operator was for back in v0.110? I'm assuming it's been removed some time ago...
>
>
> Here's a truth table for it:
>
> https://www.digitalmars.com/ctg/ctgNumerics.html#comparisons
>
> and !>= means "unordered or less than".
>
> Unordered means if one of the operands is a NaN. So, you can rewrite it as:
>
> if (std.math.isNaN(ofs) || ofs < 0)
That's great thanks! I didn't think of checking in that original docs, duh! It now compiles the game code but not some dependencies, I'll need to resolve issues regarding the std it seems as I think that changed since then.
|
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Remi | On Saturday, 11 July 2020 at 10:42:20 UTC, Remi wrote:
> That's great thanks! I didn't think of checking in that original docs, duh! It now compiles the game code but not some dependencies, I'll need to resolve issues regarding the std it seems as I think that changed since then.
Undead package contains code from old phobos for such cases.
|
July 11, 2020 Re: Question regarding D v.0110 | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Saturday, 11 July 2020 at 14:58:31 UTC, Kagamin wrote:
> On Saturday, 11 July 2020 at 10:42:20 UTC, Remi wrote:
>> That's great thanks! I didn't think of checking in that original docs, duh! It now compiles the game code but not some dependencies, I'll need to resolve issues regarding the std it seems as I think that changed since then.
>
> Undead package contains code from old phobos for such cases.
I did indeed get most of the code to compile with undead! Thanks for the pointer! I'm now trying to find docs on the "bit" type.
|
Copyright © 1999-2021 by the D Language Foundation