Fix a regression causing a display glitch in the secret ending. lua-changes
authorachurch
Thu, 06 Jan 2011 01:43:08 +0900
branchlua-changes
changeset 636 2169c06cb6ad
parent 628 e7a8acfce3d6
child 637 628f25c13eca
child 644 44bec246350f
Fix a regression causing a display glitch in the secret ending. This patch corrects a regression introduced with the 64-bit support patch in the Icculus repository which broke entity_msg() calls that passed entities as message parameters. This is used during the final scene of the secret ending to attach Lucien to the airship as it flies away.
Aquaria/Entity.h
Aquaria/ScriptInterface.cpp
Aquaria/ScriptInterface.h
Aquaria/ScriptedEntity.cpp
Aquaria/ScriptedEntity.h
--- a/Aquaria/Entity.h	Sat Dec 25 10:20:17 2010 +0900
+++ b/Aquaria/Entity.h	Thu Jan 06 01:43:08 2011 +0900
@@ -271,6 +271,7 @@
 	bool canSetState(int state);
 	
 	virtual void message(const std::string &msg, int v);
+	virtual void message(const std::string &msg, void *v) {}
 	bool isUnderWater(const Vector &o=Vector());
 
 	//virtual void onHitBySpell(Spell *spell) {}
--- a/Aquaria/ScriptInterface.cpp	Sat Dec 25 10:20:17 2010 +0900
+++ b/Aquaria/ScriptInterface.cpp	Thu Jan 06 01:43:08 2011 +0900
@@ -3569,7 +3569,10 @@
 	Entity *e = entity(L);
 	if (e)
 	{
-		e->message(getString(L, 2), lua_tonumber(L, 3));
+		if (lua_isuserdata(L, 3))
+			e->message(getString(L, 2), lua_touserdata(L, 3));
+		else
+			e->message(getString(L, 2), lua_tonumber(L, 3));
 	}
 	luaReturnNum(0);
 }
@@ -9197,6 +9200,15 @@
 	return doCall(3);
 }
 
+bool Script::call(const char *name, void *param1, const char *param2, void *param3)
+{
+	lookupFunc(name);
+	luaPushPointer(L, param1);
+	lua_pushstring(L, param2);
+	luaPushPointer(L, param3);
+	return doCall(3);
+}
+
 bool Script::call(const char *name, void *param1, void *param2, void *param3)
 {
 	lookupFunc(name);
--- a/Aquaria/ScriptInterface.h	Sat Dec 25 10:20:17 2010 +0900
+++ b/Aquaria/ScriptInterface.h	Thu Jan 06 01:43:08 2011 +0900
@@ -49,6 +49,8 @@
 	bool call(const char *name, void *param1, float param2, float param3, bool *ret1);
 	// function(pointer, string, number)
 	bool call(const char *name, void *param1, const char *param2, float param3);
+	// function(pointer, string, pointer)
+	bool call(const char *name, void *param1, const char *param2, void *param3);
 	// function(pointer, pointer, pointer)
 	bool call(const char *name, void *param1, void *param2, void *param3);
 	// function(pointer, number, number, number)
--- a/Aquaria/ScriptedEntity.cpp	Sat Dec 25 10:20:17 2010 +0900
+++ b/Aquaria/ScriptedEntity.cpp	Thu Jan 06 01:43:08 2011 +0900
@@ -102,6 +102,16 @@
 	Entity::message(msg, v);
 }
 
+void ScriptedEntity::message(const std::string &msg, void *v)
+{
+	if (script)
+	{
+		if (!script->call("msg", this, msg.c_str(), v))
+			luaDebugMsg("msg", script->getLastError());
+	}
+	Entity::message(msg, v);
+}
+
 void ScriptedEntity::warpSegments()
 {
 	Segmented::warpSegments(position);
--- a/Aquaria/ScriptedEntity.h	Sat Dec 25 10:20:17 2010 +0900
+++ b/Aquaria/ScriptedEntity.h	Thu Jan 06 01:43:08 2011 +0900
@@ -48,6 +48,7 @@
 	void lightFlare();
 	void entityDied(Entity *e);
 	void message(const std::string &msg, int v);
+	void message(const std::string &msg, void *v);
 	
 	static bool runningActivation;