From b8fc8cf9b66455ae5b1e22db9de59ea3791c890a Mon Sep 17 00:00:00 2001
From: cremno <cremno@mail.ru>
Date: Sun, 31 Aug 2014 09:31:18 +0200
Subject: [PATCH 1/2] fix Bitmap's object to string conversion

Calling #to_s might not return a string (it should though).
---
 binding-mri/bitmap-binding.cpp | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/binding-mri/bitmap-binding.cpp b/binding-mri/bitmap-binding.cpp
index 1461e74..a49d3e5 100644
--- a/binding-mri/bitmap-binding.cpp
+++ b/binding-mri/bitmap-binding.cpp
@@ -29,6 +29,12 @@
 
 DEF_TYPE(Bitmap);
 
+static const char *objAsStringPtr(VALUE obj)
+{
+	VALUE str = rb_obj_as_string(obj);
+	return RSTRING_PTR(str);
+}
+
 void bitmapInitProps(Bitmap *b, VALUE self)
 {
 	/* Wrap properties */
@@ -258,10 +264,7 @@ RB_METHOD(bitmapDrawText)
 			VALUE strObj;
 			rb_get_args(argc, argv, "oo|i", &rectObj, &strObj, &align RB_ARG_END);
 
-			if (!RB_TYPE_P(strObj, RUBY_T_STRING))
-				strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
-
-			str = RSTRING_PTR(strObj);
+			str = objAsStringPtr(strObj);
 		}
 		else
 		{
@@ -281,10 +284,7 @@ RB_METHOD(bitmapDrawText)
 			VALUE strObj;
 			rb_get_args(argc, argv, "iiiio|i", &x, &y, &width, &height, &strObj, &align RB_ARG_END);
 
-			if (!RB_TYPE_P(strObj, RUBY_T_STRING))
-				strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
-
-			str = RSTRING_PTR(strObj);
+			str = objAsStringPtr(strObj);
 		}
 		else
 		{
@@ -308,10 +308,7 @@ RB_METHOD(bitmapTextSize)
 		VALUE strObj;
 		rb_get_args(argc, argv, "o", &strObj RB_ARG_END);
 
-		if (!RB_TYPE_P(strObj, RUBY_T_STRING))
-			strObj = rb_funcallv(strObj, rb_intern("to_s"), 0, 0);
-
-		str = RSTRING_PTR(strObj);
+		str = objAsStringPtr(strObj);
 	}
 	else
 	{
-- 
2.43.0


From 4b08eee81ff87913c1f1b568d772e483284e2626 Mon Sep 17 00:00:00 2001
From: cremno <cremno@mail.ru>
Date: Tue, 2 Sep 2014 19:11:56 +0200
Subject: [PATCH 2/2] add RGSS2/3 Input.repeat?

---
 src/input.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/input.cpp b/src/input.cpp
index 5e1085b..9e38436 100644
--- a/src/input.cpp
+++ b/src/input.cpp
@@ -599,8 +599,13 @@ void Input::update()
 	{
 		p->repeatCount++;
 
-		/* Repeatsequence is [r...............(r...)+] */
-		if (p->repeatCount > 15 && ((p->repeatCount % 4) == 0))
+		bool repeated;
+		if (rgssVer >= 2)
+			repeated = p->repeatCount >= 24 && (p->repeatCount % 6) == 0;
+		else
+			repeated = p->repeatCount >= 16 && (p->repeatCount % 4) == 0;
+
+		if (repeated)
 			p->getState(p->repeating).repeated = true;
 
 		return;
-- 
2.43.0