Skip to content

fix effect_set_category#811

Merged
mercury233 merged 3 commits into
Fluorohydride:masterfrom
mercury233:patch-uint64-category
Jan 12, 2026
Merged

fix effect_set_category#811
mercury233 merged 3 commits into
Fluorohydride:masterfrom
mercury233:patch-uint64-category

Conversation

@mercury233

Copy link
Copy Markdown
Collaborator

effect->category was changed from uint32 to uint64 in #660 , but effect_set_category still uses uint32.

lua_Integer is long long and don't support uint64 fully.

@salix5 should we simply use

uint64_t v = (uint64_t)lua_tointeger(L, 2);

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a type mismatch issue in effect_set_category where the function parameter handling wasn't updated when effect->category was changed from uint32_t to uint64_t. The implementation now uses int64_t to receive the value from Lua, validates that it's non-negative, and then casts it to uint64_t before assignment.

Key Changes

  • Changed parameter handling from uint32_t cast to int64_t with validation
  • Added negative value check with error message
  • Cast to uint64_t for assignment to match the field type

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread libeffect.cpp Outdated
@salix5

salix5 commented Jan 10, 2026

Copy link
Copy Markdown
Collaborator

https://www.lua.org/manual/5.4/manual.html#lua_Integer

typedef ... lua_Integer;

The type of integers in Lua.

By default this type is long long, (usually a 64-bit two-complement integer), but that can be changed to long or int (usually a 32-bit two-complement integer). (See LUA_INT_TYPE in luaconf.h.)

Lua also defines the constants LUA_MININTEGER and LUA_MAXINTEGER, with the minimum and the maximum values that fit in this type.


lua_Integer is typically int64_t, so it should be cast to uint64_t if treated as a 64-bit bit field.

salix5 and others added 2 commits January 10, 2026 14:05
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@mercury233 mercury233 merged commit 60c3c4f into Fluorohydride:master Jan 12, 2026
2 checks passed
@mercury233 mercury233 added this to the 0x1363 milestone Jan 12, 2026
github-actions Bot pushed a commit to evolutionygo/pre-release-database-cdb that referenced this pull request Jan 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants