Kaynağa Gözat

Merge branch 'master' of github.com:taylor001/crown

Daniele Bartolini 10 yıl önce
ebeveyn
işleme
8dc42898b3

+ 2 - 2
src/lua/lua_device.cpp

@@ -56,8 +56,8 @@ static int device_resolution(lua_State* L)
 	LuaStack stack(L);
 	uint16_t w, h;
 	device()->resolution(w, h);
-	stack.push_int32(w);
-	stack.push_int32(h);
+	stack.push_int(w);
+	stack.push_int(h);
 	return 2;
 }
 

+ 2 - 2
src/lua/lua_gui.cpp

@@ -19,8 +19,8 @@ static int gui_resolution(lua_State* L)
 {
 	LuaStack stack(L);
 	const Vector2 resolution = stack.get_gui(1)->resolution();
-	stack.push_int32((uint32_t)resolution.x);
-	stack.push_int32((uint32_t)resolution.y);
+	stack.push_int(resolution.x);
+	stack.push_int(resolution.y);
 	return 2;
 }
 

+ 7 - 7
src/lua/lua_input.cpp

@@ -257,14 +257,14 @@ static int input_device_connected(lua_State* L, InputDevice& id)
 static int input_device_num_buttons(lua_State* L, InputDevice& id)
 {
 	LuaStack stack(L);
-	stack.push_uint32(id.num_buttons());
+	stack.push_int(id.num_buttons());
 	return 1;
 }
 
 static int input_device_num_axes(lua_State* L, InputDevice& id)
 {
 	LuaStack stack(L);
-	stack.push_uint32(id.num_axes());
+	stack.push_int(id.num_axes());
 	return 1;
 }
 
@@ -306,35 +306,35 @@ static int input_device_axis(lua_State* L, InputDevice& id)
 static int keyboard_button_id(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(name_to_keyboard_button(stack, stack.get_string(1)));
+	stack.push_int(name_to_keyboard_button(stack, stack.get_string(1)));
 	return 1;
 }
 
 static int mouse_button_id(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(name_to_mouse_button(stack, stack.get_string(1)));
+	stack.push_int(name_to_mouse_button(stack, stack.get_string(1)));
 	return 1;
 }
 
 static int mouse_axis_id(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(name_to_mouse_axis(stack, stack.get_string(1)));
+	stack.push_int(name_to_mouse_axis(stack, stack.get_string(1)));
 	return 1;
 }
 
 static int pad_button_id(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(name_to_pad_button(stack, stack.get_string(1)));
+	stack.push_int(name_to_pad_button(stack, stack.get_string(1)));
 	return 1;
 }
 
 static int pad_axis_id(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(name_to_pad_axis(stack, stack.get_string(1)));
+	stack.push_int(name_to_pad_axis(stack, stack.get_string(1)));
 	return 1;
 }
 

+ 9 - 5
src/lua/lua_stack.h

@@ -138,12 +138,12 @@ struct LuaStack
 		lua_pushboolean(L, value);
 	}
 
-	void push_int32(int32_t value)
+	void push_int(int value)
 	{
 		lua_pushinteger(L, value);
 	}
 
-	void push_uint32(uint32_t value)
+	void push_id(uint32_t value)
 	{
 		lua_pushinteger(L, value);
 	}
@@ -186,6 +186,11 @@ struct LuaStack
 		return (int)CHECKINTEGER(L, i);
 	}
 
+	uint32_t get_id(int i)
+	{
+		return (uint32_t)CHECKINTEGER(L, i);
+	}
+
 	StringId32 get_string_id(int i)
 	{
 		return StringId32(uint32_t(CHECKINTEGER(L, i)));
@@ -381,13 +386,12 @@ struct LuaStack
 
 	void push_sound_instance_id(const SoundInstanceId id)
 	{
-		uintptr_t enc = id.encode();
-		lua_pushlightuserdata(L, (void*)enc);
+		push_id(id.encode());
 	}
 
 	SoundInstanceId get_sound_instance_id(int i)
 	{
-		uint32_t enc = (uintptr_t) CHECKLIGHTDATA(L, i, always_true, "SoundInstanceId");
+		uint32_t enc = get_id(i);
 		SoundInstanceId id;
 		id.decode(enc);
 		return id;

+ 1 - 1
src/lua/lua_world.cpp

@@ -40,7 +40,7 @@ static int world_destroy_unit(lua_State* L)
 static int world_num_units(lua_State* L)
 {
 	LuaStack stack(L);
-	stack.push_uint32(stack.get_world(1)->num_units());
+	stack.push_int(stack.get_world(1)->num_units());
 	return 1;
 }