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

Squirrel 64bit Integer is parsed wrong into strings #6194

Closed
DorpsGek opened this issue Dec 27, 2014 · 3 comments
Closed

Squirrel 64bit Integer is parsed wrong into strings #6194

DorpsGek opened this issue Dec 27, 2014 · 3 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

The_Dude opened the ticket and wrote:

This is continuation of bug report #5942 (fixed in r26585).

Squirell now handles int64 well, but when I want to display number higher than uint32_max in gui as string, it fails.

Savegame, sample game script and screenshot enclosed. String code used in example is CURRENCY_LONG, CURENCY_SHORT and COMMA.

I did little research and the results are

in src/script/api/script_text.cpp in function SQInteger ScriptText::_SetParam(int parameter, HSQUIRRELVM vm)
are GSText integer parametres save into this->parami[parameter] = value; (LINE 95)

in src/script/api/script_text.hpp
is parami declared as int parami[SCRIPT_TEXT_MAX_PARAMETERS]; (LINE 132)

So every int64 passed here is cut to int32 (at least on 32-bit system)

Furthermore back in script_text.cpp in function char *ScriptText::_GetEncodedText(char *p, char *lastofp, int &param_count)
are int64 parameters made as uint32 p += seprintf(p, lastofp,":%X", (uint32)this->parami[i]); (LINE 204)

Declaring parami to int64 and removint the (uint32) change type itself does not help though, there is more to that, which I have not discovered.

Attachments

Reported version: 1.5.0-beta1
Operating system: All


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

Rubidium wrote:

I think the attached patch solves the issue; it seems to do so for me, but I don't have a 32 bits environment to properly test it. Could you please test it?

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6194#comment13678

@DorpsGek
Copy link
Member Author

DorpsGek commented Jan 1, 2015

The_Dude wrote:

Thanks. That's it, it works good!

strtoull is unknown to MSVCRT, so there is needed some define in stdafx.cpp. (diff 1)

Also I found out, that GSList stores again only 32 bit values. As GSList is often used to store various values like scores, it would be good to make it store int64 too. (diff 2)

Both patches works with 32 and 64bit compiled executable on win7 64bit and 32bit works the same on winXP 32bit for me.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/6194#comment13683

@DorpsGek
Copy link
Member Author

DorpsGek commented Jan 1, 2015

Rubidium closed the ticket.

Reason for closing: Fixed

In r27102 and r27104


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

@DorpsGek DorpsGek closed this as completed Jan 1, 2015
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant