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

Assignment ( = ) Registering as Bitwise Op #5408

Closed
DorpsGek opened this issue Dec 26, 2012 · 8 comments
Closed

Assignment ( = ) Registering as Bitwise Op #5408

DorpsGek opened this issue Dec 26, 2012 · 8 comments
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

MinchinWeb opened the ticket and wrote:

I have a list of TileIndexes and want to assign the value of one to a separate variable. The code I use is:

LastTile = AllTiles.top();

however, the error that comes up is:

Your script made an error: bitwise op between 'bool' and 'bool'

However, LastTile is currently an integer, and AllTiles is an array of integers. I have attached my whole AI and library in hope that you can reproduce the bug. The 'error' is in line 172 of Dominion.Roads.nut in the library.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5408
@DorpsGek
Copy link
Member Author

MinchinWeb wrote:

One clue I have found is that is I try and add a temporary variable, it errors out on the line where I try to assign the value to LastTile and the temporary variable doesn't show up in the list of variables OpenTTD dumps when a script crashes.

Example code:

local temp = AllTiles.top();
LastTile = temp;


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11806

@DorpsGek
Copy link
Member Author

frosch wrote:

Got some other issue for now:

dbg: [script] [1] [S] Your script made an error: parameter 1 has an invalid type 'null' ; expected: 'integer'
dbg: [script] [1] [S]
dbg: [script] [1] [S] *FUNCTION [GridPoints()] library/openttd-metalibrary/Dominion.Roads.nut line [90]
dbg: [script] [1] [S] *FUNCTION [FindPath()] library/openttd-metalibrary/Dominion.Roads.nut line [157]
dbg: [script] [1] [S] *FUNCTION [RunPathfinder()] openttd-wmdot/OpDOT.nut line [881]
dbg: [script] [1] [S] *FUNCTION [Run()] openttd-wmdot/OpDOT.nut line [314]
dbg: [script] [1] [S] FUNCTION [Start()] openttd-wmdot/main.nut line [132]
dbg: [script] [1] [S]
dbg: [script] [1] [S] [End2] 8776
dbg: [script] [1] [S] [End1] NULL
dbg: [script] [1] [S] [this] INSTANCE
dbg: [script] [1] [S] [StartArray] ARRAY
dbg: [script] [1] [S] [StartTile] NULL
dbg: [script] [1] [S] [LastTile] NULL
dbg: [script] [1] [S] [LastTile] 10703
dbg: [script] [1] [S] [AllTiles] ARRAY
dbg: [script] [1] [S] [cycles] 10000
dbg: [script] [1] [S] [this] INSTANCE
dbg: [script] [1] [S] [CycleCounter] 0
dbg: [script] [1] [S] [path] false
dbg: [script] [1] [S] [pathfinder] INSTANCE
dbg: [script] [1] [S] [End] 8776
dbg: [script] [1] [S] [Start] 10703
dbg: [script] [1] [S] [this] INSTANCE
dbg: [script] [1] [S] [BuildCost] 0
dbg: [script] [1] [S] [PathFinder] NULL
dbg: [script] [1] [S] [Tries] 1
dbg: [script] [1] [S] [KeepTrying] true
dbg: [script] [1] [S] [tick] 25
dbg: [script] [1] [S] [TestAtlas] ARRAY
dbg: [script] [1] [S] [this] INSTANCE
dbg: [script] [1] [S] [Time] 4
dbg: [script] [1] [S] [HQTown] 0
dbg: [script] [1] [S] [Debug_1] "/
v.11, r.252 // r.24864 // 1950-1-2 start // 128x128 map - 3 towns /"
dbg: [script] [1] [S] [Debug_2] "/
Settings: 0-0 - dl3 // OpDOT: 1 - 500 - 50 - 2 // OpHibernia: 1 */"
dbg: [script] [1] [S] [this] INSTANCE


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11807

@DorpsGek
Copy link
Member Author

MinchinWeb wrote:

Here's the file that fixes the issue you posted Frosch.

I have discovered the issue (the bitwise op error) is actually with the following line, rather than the one reported. So maybe that's the real error. Here's a simplified test code:

  1. do {
  2.    local Nothing = null;
    
  3. } while (true & false)

The error will be reported in line 2, but changing line 3 to "while (true && false)" (double ampersand) will fix the error.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11813

@DorpsGek
Copy link
Member Author

krinn wrote:

It's an expected feature no?
http://www.squirrel-lang.org/doc/squirrel2.html# d0e993

Bitwise Operators
Squirrel supports the standard c-like bit wise operators &,|,^,~,<<,>> plus the unsigned right shift operator >>>. The unsigned right shift works exactly like the normal right shift operator(>>) except for treating the left operand as an unsigned integer, so is not affected by the sign. Those operators only work on integers values, passing of any other operand type to these operators will cause an exception.

-> only work on integers values, passing of any other operand type to these operators will cause an exception.


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11816

@DorpsGek
Copy link
Member Author

krinn wrote:

And for your original report i would say the error came from that line
} while ((LastTile != this._endtile) & (this._running == true));

Doing again a bitwise operation on boolean

Don't you mean ? } while ((LastTile != this._endtile) && (this._running == true));

And this line should get check too, wouldn't you were wishing to do that instead ?
local SomethingElse = (LastTile == AllTiles.top()); // assign boolean if LastTile equal AllTiles.top()


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11817

@DorpsGek
Copy link
Member Author

MinchinWeb wrote:

@krinn,

I'm beginning to think the issue might actually be the line number where the error is reported. It seems that the error is reported in the line before the one where it actually appears.

So my fixed line reads: } while ((LastTile != this._endtile) && (this._running == true));


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11819

@DorpsGek
Copy link
Member Author

frosch closed the ticket.

Reason for closing: Fixed

in r24928


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408

@DorpsGek
Copy link
Member Author

frosch wrote:

For further reference:
http://forum.squirrel-lang.org/default.aspx?g=posts&t=2758


This comment was imported from FlySpray: https://bugs.openttd.org/task/5408#comment11882

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: AI/Game script (squirrel) This issue is related to Squirrel (Scripting language) flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant