Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
illuna-minetest
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Illuna-Minetest
illuna-minetest
Commits
2de8c22a
Commit
2de8c22a
authored
8 years ago
by
SmallJoker
Committed by
kwolekr
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Make getStackMax return the correct maximal stack size
parent
aa331663
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/inventory.h
+2
-3
2 additions, 3 deletions
src/inventory.h
src/itemdef.h
+1
-1
1 addition, 1 deletion
src/itemdef.h
src/script/common/c_content.cpp
+2
-3
2 additions, 3 deletions
src/script/common/c_content.cpp
with
5 additions
and
7 deletions
src/inventory.h
+
2
−
3
View file @
2de8c22a
...
@@ -80,15 +80,14 @@ struct ItemStack
...
@@ -80,15 +80,14 @@ struct ItemStack
// Maximum size of a stack
// Maximum size of a stack
u16
getStackMax
(
IItemDefManager
*
itemdef
)
const
u16
getStackMax
(
IItemDefManager
*
itemdef
)
const
{
{
s16
max
=
itemdef
->
get
(
name
).
stack_max
;
return
itemdef
->
get
(
name
).
stack_max
;
return
(
max
>=
0
)
?
max
:
0
;
}
}
// Number of items that can be added to this stack
// Number of items that can be added to this stack
u16
freeSpace
(
IItemDefManager
*
itemdef
)
const
u16
freeSpace
(
IItemDefManager
*
itemdef
)
const
{
{
u16
max
=
getStackMax
(
itemdef
);
u16
max
=
getStackMax
(
itemdef
);
if
(
count
>
max
)
if
(
count
>
=
max
)
return
0
;
return
0
;
return
max
-
count
;
return
max
-
count
;
}
}
...
...
This diff is collapsed.
Click to expand it.
src/itemdef.h
+
1
−
1
View file @
2de8c22a
...
@@ -61,7 +61,7 @@ struct ItemDefinition
...
@@ -61,7 +61,7 @@ struct ItemDefinition
/*
/*
Item stack and interaction properties
Item stack and interaction properties
*/
*/
s
16
stack_max
;
u
16
stack_max
;
bool
usable
;
bool
usable
;
bool
liquids_pointable
;
bool
liquids_pointable
;
// May be NULL. If non-NULL, deleted by destructor
// May be NULL. If non-NULL, deleted by destructor
...
...
This diff is collapsed.
Click to expand it.
src/script/common/c_content.cpp
+
2
−
3
View file @
2de8c22a
...
@@ -65,9 +65,8 @@ ItemDefinition read_item_definition(lua_State* L,int index,
...
@@ -65,9 +65,8 @@ ItemDefinition read_item_definition(lua_State* L,int index,
}
}
lua_pop
(
L
,
1
);
lua_pop
(
L
,
1
);
def
.
stack_max
=
getintfield_default
(
L
,
index
,
"stack_max"
,
def
.
stack_max
);
int
stack_max
=
getintfield_default
(
L
,
index
,
"stack_max"
,
def
.
stack_max
);
if
(
def
.
stack_max
==
0
)
def
.
stack_max
=
rangelim
(
stack_max
,
1
,
U16_MAX
);
def
.
stack_max
=
1
;
lua_getfield
(
L
,
index
,
"on_use"
);
lua_getfield
(
L
,
index
,
"on_use"
);
def
.
usable
=
lua_isfunction
(
L
,
-
1
);
def
.
usable
=
lua_isfunction
(
L
,
-
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment