Implement healing. Fixes #999.

This was SVN commit r11536.
This commit is contained in:
leper
2012-04-17 20:22:13 +00:00
parent 80277e3da9
commit c56f96040e
37 changed files with 697 additions and 41 deletions
+16 -1
View File
@@ -1,4 +1,4 @@
/* Copyright (C) 2011 Wildfire Games.
/* Copyright (C) 2012 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@@ -90,6 +90,16 @@ template<> bool ScriptInterface::FromJSVal<u16>(JSContext* cx, jsval v, u16& out
return true;
}
template<> bool ScriptInterface::FromJSVal<u8>(JSContext* cx, jsval v, u8& out)
{
uint16 ret;
WARN_IF_NOT(JSVAL_IS_NUMBER(v), v);
if (!JS_ValueToUint16(cx, v, &ret))
return false;
out = (u8)ret;
return true;
}
// NOTE: we can't define a jsval specialisation, because that conflicts with integer types
template<> bool ScriptInterface::FromJSVal<CScriptVal>(JSContext* UNUSED(cx), jsval v, CScriptVal& out)
{
@@ -196,6 +206,11 @@ template<> jsval ScriptInterface::ToJSVal<u16>(JSContext* UNUSED(cx), const u16&
return INT_TO_JSVAL(val);
}
template<> jsval ScriptInterface::ToJSVal<u8>(JSContext* UNUSED(cx), const u8& val)
{
return INT_TO_JSVAL(val);
}
template<> jsval ScriptInterface::ToJSVal<u32>(JSContext* cx, const u32& val)
{
if (val <= JSVAL_INT_MAX)