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

Add Platform.AvailableRAM #1640

Open
sprunk opened this issue Aug 8, 2024 · 1 comment · May be fixed by #1840
Open

Add Platform.AvailableRAM #1640

sprunk opened this issue Aug 8, 2024 · 1 comment · May be fixed by #1840
Labels
area: Lua API enhancement New feature or request good first issue Good for newcomers

Comments

@sprunk
Copy link
Collaborator

sprunk commented Aug 8, 2024

Add RAM to https://github.com/beyond-all-reason/spring/blob/BAR105/rts/Lua/LuaConstPlatform.cpp

User story: this fragile hax https://github.com/beyond-all-reason/Beyond-All-Reason/blob/master/luaintro/Addons/main.lua#L63-L66 (there's also a lot of other terrible string parsing hax above the RAM line but afaict things like Platform.glVendor, Platform.glslVersion and Platform.glRenderer all already exist)

@sprunk sprunk added enhancement New feature or request area: Lua API labels Aug 8, 2024
@sprunk
Copy link
Collaborator Author

sprunk commented Oct 1, 2024

Probably extract these two snippets to a function that returns a pair of optional ints (ram, pagefile), and then use that in the existing place and whatever place adds that info to Lua.

if (memInfo != nullptr) {
while (fgets(buf, sizeof(buf), memInfo) != nullptr) {
if (strstr(buf, "MemTotal") != nullptr) {

MEMORYSTATUSEX statex;
constexpr int div = 1024 * 1024;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);

@sprunk sprunk added the good first issue Good for newcomers label Oct 1, 2024
@sprunk sprunk linked a pull request Dec 20, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Lua API enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant